Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion internal/app/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ func gitConfigForReviewerAuth(profile config.Profile) config.GitConfig {
AuthMode: profile.ReviewerCredentials.AuthMode,
Credential: profile.ReviewerCredentials.Credential,
GitHubApp: githubApp,
CredentialRef: profile.ReviewerCredentials.CredentialRef,
IdentityCache: profile.ReviewerCredentials.IdentityCache,
}
}
Expand Down
29 changes: 12 additions & 17 deletions internal/app/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ func TestOpenUsesReviewerCredentialsAsRuntimeProvider(t *testing.T) {
cfg := testConfig()
profile := cfg.Profiles["home"]
profile.ReviewerCredentials = &config.ReviewerCredentials{
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/home-reviewer"},
CredentialRef: "codereview/home-reviewer",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/home-reviewer"},
}
cfg.Profiles["home"] = profile

Expand All @@ -85,7 +84,7 @@ func TestOpenUsesReviewerCredentialsAsRuntimeProvider(t *testing.T) {
Dependencies: testDependencies(t,
func(git config.GitConfig, _ credentials.Reader, _ githubprovider.Options) (gitprovider.GitProvider, gitprovider.Credential, error) {
providerCalls = append(providerCalls, git)
if git.CredentialRef == "codereview/home-reviewer" {
if git.Credential.Name == "codereview/home-reviewer" {
return reviewerProvider, gitprovider.Credential{Type: "pat", Token: "reviewer-token"}, nil
}
return repoProvider, gitprovider.Credential{Type: "pat", Token: "repo-token"}, nil
Expand All @@ -108,8 +107,8 @@ func TestOpenUsesReviewerCredentialsAsRuntimeProvider(t *testing.T) {
defer runtime.Cleanup()
}
if len(providerCalls) != 2 ||
providerCalls[0].CredentialRef != "codereview/home" ||
providerCalls[1].CredentialRef != "codereview/home-reviewer" {
providerCalls[0].Credential.Name != "codereview/home" ||
providerCalls[1].Credential.Name != "codereview/home-reviewer" {
t.Fatalf("provider calls = %#v, want repository read then reviewer posting providers", providerCalls)
}
runner, ok := runtime.Runner.(reviewRunner)
Expand Down Expand Up @@ -414,11 +413,9 @@ func TestOpenSelectionPassesGitHubAppInstallationLookupAndPinnedID(t *testing.T)
profile := cfg.Profiles["home"]
profile.Git.AuthMode = config.GitAuthModeGitHubApp
profile.Git.Credential = credential
profile.Git.CredentialRef = "codereview/cr-reviewer"
profile.ReviewerCredentials = &config.ReviewerCredentials{ // #nosec G101 -- test credential reference, not secret material.
AuthMode: config.GitAuthModeGitHubApp,
Credential: credential,
CredentialRef: "codereview/cr-reviewer",
AuthMode: config.GitAuthModeGitHubApp,
Credential: credential,
}
profile.Reviewer = config.ProfileReviewer{
Kind: config.ProfileReviewerKindEntity,
Expand Down Expand Up @@ -611,7 +608,6 @@ func TestOpenInjectsCachedReaderIntoProviderAndAdapter(t *testing.T) {
profile.LLM.Auth = config.LLMAuthAPIKey
profile.LLM.Adapter = config.LLMAdapterOpenAIAPI
profile.LLM.Credential = config.CredentialLocation{Store: "test-memory", Name: "codereview/home"}
profile.LLM.CredentialRef = "codereview/home"
cfg.Profiles["home"] = profile

var providerReader credentials.Reader
Expand All @@ -624,7 +620,7 @@ func TestOpenInjectsCachedReaderIntoProviderAndAdapter(t *testing.T) {
PRRef: testPRRef(),
Dependencies: testDependencies(t,
func(git config.GitConfig, reader credentials.Reader, _ githubprovider.Options) (gitprovider.GitProvider, gitprovider.Credential, error) {
if git.CredentialRef == "codereview/home" && providerReader == nil {
if git.Credential.Name == "codereview/home" && providerReader == nil {
providerReader = reader
} else {
postingReader = reader
Expand Down Expand Up @@ -670,7 +666,7 @@ func TestOpenSelectionInjectsCachedReaderIntoProviderAndAdapter(t *testing.T) {
profile.LLM.Auth = config.LLMAuthAPIKey
profile.LLM.Adapter = config.LLMAdapterOpenAIAPI
profile.LLM.Credential = config.CredentialLocation{Store: "test-memory", Name: "codereview/home"}
profile.LLM.CredentialRef = "codereview/home"
profile.LLM.Credential.Name = "codereview/home"
cfg.Profiles["home"] = profile

var providerReader credentials.Reader
Expand Down Expand Up @@ -937,10 +933,9 @@ func testConfig() config.File {
configtest.WithoutRepositoryProfiles(),
configtest.HomeProfile(config.Profile{
Git: config.GitConfig{
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory"},
CredentialRef: "codereview/home",
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/home"},
},
LLM: config.LLMConfig{
Provider: config.LLMProviderAnthropic,
Expand Down
30 changes: 15 additions & 15 deletions internal/cmd/agentscmd/agentscmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestAgentsListWithPRUsesRepositoryProfileRoute(t *testing.T) {
fake, ref := fakeProviderWithRepoAgent(t, "repo", "reviewer", "repo desc")
cfg := testConfig("")
work := cfg.Profiles["home"]
work.Git.CredentialRef = "codereview/work"
work.Git.Credential.Name = "codereview/work"
cfg.Profiles["work"] = work
cfg.RepositoryProfiles = []config.RepositoryProfile{{
Profile: "work",
Expand All @@ -115,8 +115,8 @@ func TestAgentsListWithPRUsesRepositoryProfileRoute(t *testing.T) {
},
}}
cmd, out := newTestCommand(t, cfg, func(_ *cobra.Command, _ *root.Options, _ config.File, profile config.Profile) (gitprovider.GitProvider, func(), error) {
if profile.Git.CredentialRef != "codereview/work" {
t.Fatalf("provider profile credential ref = %q, want work route", profile.Git.CredentialRef)
if profile.Git.Credential.Name != "codereview/work" {
t.Fatalf("provider profile credential ref = %q, want work route", profile.Git.Credential.Name)
}
return fake, nil, nil
})
Expand All @@ -137,7 +137,7 @@ func TestAgentsListWithPRRejectsAmbiguousRepositoryProfileRoute(t *testing.T) {
fake, ref := fakeProviderWithRepoAgent(t, "repo", "reviewer", "repo desc")
cfg := testConfig("")
work := cfg.Profiles["home"]
work.Git.CredentialRef = "codereview/work"
work.Git.Credential.Name = "codereview/work"
cfg.Profiles["work"] = work
cfg.RepositoryProfiles = []config.RepositoryProfile{
{
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestAgentsListExplicitProfileBypassesRepositoryRoute(t *testing.T) {
fake, ref := fakeProviderWithRepoAgent(t, "repo", "reviewer", "repo desc")
cfg := testConfig("")
work := cfg.Profiles["home"]
work.Git.CredentialRef = "codereview/work"
work.Git.Credential.Name = "codereview/work"
cfg.Profiles["work"] = work
cfg.RepositoryProfiles = []config.RepositoryProfile{{
Profile: "work",
Expand All @@ -186,8 +186,8 @@ func TestAgentsListExplicitProfileBypassesRepositoryRoute(t *testing.T) {
},
}}
cmd, _ := newTestCommand(t, cfg, func(_ *cobra.Command, _ *root.Options, _ config.File, profile config.Profile) (gitprovider.GitProvider, func(), error) {
if profile.Git.CredentialRef != "codereview/home" {
t.Fatalf("provider profile credential ref = %q, want explicit home", profile.Git.CredentialRef)
if profile.Git.Credential.Name != "codereview/home" {
t.Fatalf("provider profile credential ref = %q, want explicit home", profile.Git.Credential.Name)
}
return fake, nil, nil
})
Expand All @@ -201,7 +201,7 @@ func TestAgentsShowWithPRUsesRepositoryProfileRoute(t *testing.T) {
fake, ref := fakeProviderWithRepoAgent(t, "repo", "reviewer", "repo desc")
cfg := testConfig("")
work := cfg.Profiles["home"]
work.Git.CredentialRef = "codereview/work"
work.Git.Credential.Name = "codereview/work"
cfg.Profiles["work"] = work
cfg.RepositoryProfiles = []config.RepositoryProfile{{
Profile: "work",
Expand All @@ -212,8 +212,8 @@ func TestAgentsShowWithPRUsesRepositoryProfileRoute(t *testing.T) {
},
}}
cmd, out := newTestCommand(t, cfg, func(_ *cobra.Command, _ *root.Options, _ config.File, profile config.Profile) (gitprovider.GitProvider, func(), error) {
if profile.Git.CredentialRef != "codereview/work" {
t.Fatalf("provider profile credential ref = %q, want work route", profile.Git.CredentialRef)
if profile.Git.Credential.Name != "codereview/work" {
t.Fatalf("provider profile credential ref = %q, want work route", profile.Git.Credential.Name)
}
return fake, nil, nil
})
Expand All @@ -234,7 +234,7 @@ func TestAgentsListExplicitEmptyProfileFailsBeforeRepositoryRoute(t *testing.T)
fake, ref := fakeProviderWithRepoAgent(t, "repo", "reviewer", "repo desc")
cfg := testConfig("")
work := cfg.Profiles["home"]
work.Git.CredentialRef = "codereview/work"
work.Git.Credential.Name = "codereview/work"
cfg.Profiles["work"] = work
cfg.RepositoryProfiles = []config.RepositoryProfile{{
Profile: "work",
Expand Down Expand Up @@ -264,7 +264,7 @@ func TestAgentsListExplicitProfileHostMismatch(t *testing.T) {
cfg.RepositoryProfiles = nil
work := home
work.Git.Host = "github.com"
work.Git.CredentialRef = "codereview/work"
work.Git.Credential.Name = "codereview/work"
cfg.Profiles["work"] = work
cfg.RepositoryProfiles = []config.RepositoryProfile{{
Profile: "work",
Expand Down Expand Up @@ -452,9 +452,9 @@ func providerFactory(provider gitprovider.GitProvider) ProviderFactory {
func testConfig(agentSource string) config.File {
profile := config.Profile{
Git: config.GitConfig{
Host: "github.com",
AuthMode: config.GitAuthModePAT,
CredentialRef: "codereview/home",
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: config.LocalOSCredentialStoreID, Name: "codereview/home"},
},
LLM: config.LLMConfig{
Provider: config.LLMProviderAnthropic,
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/benchmarkcmd/benchmarkcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ func testConfig() config.File {
Git: config.GitConfig{
Host: "github.com",
AuthMode: config.GitAuthModePAT,
CredentialRef: "codereview/home",
Credential: config.CredentialLocation{Store: config.LocalOSCredentialStoreID, Name: "codereview/home"},
IdentityCache: "review-bot",
},
LLM: config.LLMConfig{
Expand Down
38 changes: 17 additions & 21 deletions internal/cmd/configcmd/configcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ func TestConfigShowGitHubAppGitCredentialStatus(t *testing.T) {
work := cfg.Profiles["work"]
work.Git.AuthMode = config.GitAuthModeGitHubApp
work.Git.GitHubApp = &config.GitHubAppConfig{AppID: "12345"}
work.Git.CredentialRef = "codereview/work-app"
work.Git.Credential.Name = "codereview/work-app"
work.Git.Credential.Name = "codereview/work-app"
cfg.Profiles["work"] = work
path := saveTestConfig(t, cfg)
Expand Down Expand Up @@ -2492,7 +2492,7 @@ func TestConfigClearGitHubAppCredentialMatrix(t *testing.T) {
work := cfg.Profiles["work"]
work.Git.AuthMode = config.GitAuthModeGitHubApp
work.Git.GitHubApp = &config.GitHubAppConfig{AppID: "12345"}
work.Git.CredentialRef = "codereview/work-app"
work.Git.Credential.Name = "codereview/work-app"
work.Git.Credential.Name = "codereview/work-app"
cfg.Profiles["work"] = work
path := saveTestConfig(t, cfg)
Expand Down Expand Up @@ -2601,11 +2601,11 @@ func TestConfigClearAllDryRunTextReportsPredictedReset(t *testing.T) {
func TestConfigClearAllClearsOnlySelectedProfileAndRemovesCache(t *testing.T) {
cfg := fileBackendConfig(t)
alpha := cfg.Profiles["home"]
alpha.Git.CredentialRef = "codereview/alpha"
alpha.Git.Credential.Name = "codereview/alpha"
alpha.Git.Credential.Name = "codereview/alpha"
cfg.Profiles["alpha"] = alpha
beta := cfg.Profiles["home"]
beta.Git.CredentialRef = "codereview/beta"
beta.Git.Credential.Name = "codereview/beta"
beta.Git.Credential.Name = "codereview/beta"
cfg.Profiles["beta"] = beta
path := saveTestConfig(t, cfg)
Expand Down Expand Up @@ -2901,7 +2901,7 @@ func TestConfigClearProfileAllClearsOnlySelectedProfile(t *testing.T) {
func TestConfigClearProfileAllPrunesSelectedProfileRoutes(t *testing.T) {
cfg := fileBackendConfig(t)
alpha := cfg.Profiles["home"]
alpha.Git.CredentialRef = "codereview/alpha"
alpha.Git.Credential.Name = "codereview/alpha"
alpha.Git.Credential.Name = "codereview/alpha"
cfg.Profiles["alpha"] = alpha
cfg.RepositoryProfiles = []config.RepositoryProfile{
Expand Down Expand Up @@ -3411,32 +3411,28 @@ func testConfig() config.File {
configtest.WithoutRepositoryProfiles(),
configtest.HomeProfile(config.Profile{
Git: config.GitConfig{
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/home"},
CredentialRef: "codereview/home",
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/home"},
},
LLM: config.LLMConfig{Provider: config.LLMProviderAnthropic, Auth: config.LLMAuthSubscription, Adapter: config.LLMAdapterClaudeCLI},
ReviewPolicy: config.ReviewPolicy{MajorEvent: config.ReviewMajorEventComment},
}),
configtest.Profile("work", config.Profile{
Git: config.GitConfig{
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/work"},
CredentialRef: "codereview/work",
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/work"},
},
ReviewerCredentials: &config.ReviewerCredentials{
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/work-reviewer"},
CredentialRef: "codereview/work-reviewer",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/work-reviewer"},
},
LLM: config.LLMConfig{
Provider: config.LLMProviderAnthropic,
Auth: config.LLMAuthAPIKey,
Adapter: config.LLMAdapterAnthropicAPI,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/work-llm"},
CredentialRef: "codereview/work-llm",
Provider: config.LLMProviderAnthropic,
Auth: config.LLMAuthAPIKey,
Adapter: config.LLMAdapterAnthropicAPI,
Credential: config.CredentialLocation{Store: "test-memory", Name: "codereview/work-llm"},
},
ReviewPolicy: config.ReviewPolicy{MajorEvent: config.ReviewMajorEventRequestChanges},
}),
Expand Down
19 changes: 8 additions & 11 deletions internal/cmd/credentialcmd/credentialcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ func TestSetCredentialUsesGitHubAppCredentialMatrix(t *testing.T) {
Store: testFileCredentialStoreID,
Name: "codereview/work-reviewer",
},
GitHubApp: &config.GitHubAppConfig{AppID: "12345"},
CredentialRef: "codereview/work-reviewer",
GitHubApp: &config.GitHubAppConfig{AppID: "12345"},
}
cfg.Profiles["work"] = work
saveCredentialTestConfig(t, path, cfg)
Expand Down Expand Up @@ -597,10 +596,9 @@ func basicProfile(profile string) config.Profile {
}
return config.Profile{
Git: config.GitConfig{
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: config.LocalOSCredentialStoreID, Name: ref},
CredentialRef: ref,
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: config.LocalOSCredentialStoreID, Name: ref},
},
LLM: config.LLMConfig{
Provider: config.LLMProviderAnthropic,
Expand All @@ -614,11 +612,10 @@ func apiKeyProfile(profile string, provider config.LLMProvider) config.Profile {
p := basicProfile(profile)
ref := "codereview/" + profile + "-llm"
p.LLM = config.LLMConfig{
Provider: provider,
Auth: config.LLMAuthAPIKey,
Adapter: config.LLMAdapterAnthropicAPI,
Credential: config.CredentialLocation{Store: config.LocalOSCredentialStoreID, Name: ref},
CredentialRef: ref,
Provider: provider,
Auth: config.LLMAuthAPIKey,
Adapter: config.LLMAdapterAnthropicAPI,
Credential: config.CredentialLocation{Store: config.LocalOSCredentialStoreID, Name: ref},
}
if provider == config.LLMProviderOpenAI {
p.LLM.Adapter = config.LLMAdapterOpenAIAPI
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/datacmd/datacmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ func TestDataPruneDefaultIgnoresConfiguredRetention(t *testing.T) {
Profiles: map[string]config.Profile{
"home": {
Git: config.GitConfig{
Host: "github.com",
AuthMode: config.GitAuthModePAT,
CredentialRef: "codereview/home",
Host: "github.com",
AuthMode: config.GitAuthModePAT,
Credential: config.CredentialLocation{Store: config.LocalOSCredentialStoreID, Name: "codereview/home"},
},
LLM: config.LLMConfig{
Provider: config.LLMProviderAnthropic,
Expand Down
Loading
Loading