Skip to content

Commit d0892b6

Browse files
committed
Use stored credentials from config file when env var is given
1 parent ddffe6d commit d0892b6

1 file changed

Lines changed: 7 additions & 20 deletions

File tree

internal/tiger/cmd/integration_test.go

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,14 +2187,18 @@ func findProjectRoot() (string, error) {
21872187
}
21882188

21892189
// buildTestEnv creates environment variables for PTY test binary
2190-
func buildTestEnv(tmpDir string) []string {
2190+
func buildTestEnv(tmpDir, publicKey, secretKey string) []string {
21912191
env := os.Environ()
21922192
// Override config directory to use test temp dir
21932193
env = append(env, "TIGER_CONFIG_DIR="+tmpDir)
21942194
// Disable analytics for tests
21952195
env = append(env, "TIGER_ANALYTICS=false")
21962196
// Use pgpass storage for easier testing (no keyring interaction)
21972197
env = append(env, "TIGER_PASSWORD_STORAGE=pgpass")
2198+
// Pass credentials via environment so subprocess uses them directly
2199+
// (bypasses keyring which may have different credentials)
2200+
env = append(env, "TIGER_PUBLIC_KEY="+publicKey)
2201+
env = append(env, "TIGER_SECRET_KEY="+secretKey)
21982202
return env
21992203
}
22002204

@@ -2296,23 +2300,6 @@ func TestDbConnectPasswordResetIntegration(t *testing.T) {
22962300
binaryPath := buildTigerBinary(t, tmpDir)
22972301
t.Logf("Built tiger binary at: %s", binaryPath)
22982302

2299-
t.Run("SubprocessLogin", func(t *testing.T) {
2300-
// Run tiger auth login in subprocess environment to store credentials
2301-
// in the system keyring (which subprocess will use)
2302-
t.Logf("Running tiger auth login in subprocess environment")
2303-
2304-
cmd := exec.Command(binaryPath, "auth", "login",
2305-
"--public-key", publicKey,
2306-
"--secret-key", secretKey,
2307-
)
2308-
cmd.Env = buildTestEnv(tmpDir)
2309-
output, err := cmd.CombinedOutput()
2310-
if err != nil {
2311-
t.Fatalf("Subprocess auth login failed: %v\nOutput: %s", err, output)
2312-
}
2313-
t.Logf("Subprocess auth login output: %s", output)
2314-
})
2315-
23162303
t.Run("VerifyInitialConnection", func(t *testing.T) {
23172304
if serviceID == "" {
23182305
t.Skip("No service ID available")
@@ -2335,7 +2322,7 @@ func TestDbConnectPasswordResetIntegration(t *testing.T) {
23352322
cmd.Stdin = c.Tty()
23362323
cmd.Stdout = c.Tty()
23372324
cmd.Stderr = c.Tty()
2338-
cmd.Env = buildTestEnv(tmpDir)
2325+
cmd.Env = buildTestEnv(tmpDir, publicKey, secretKey)
23392326

23402327
if err := cmd.Start(); err != nil {
23412328
t.Fatalf("Failed to start command: %v", err)
@@ -2422,7 +2409,7 @@ func TestDbConnectPasswordResetIntegration(t *testing.T) {
24222409
cmd.Stdin = c.Tty()
24232410
cmd.Stdout = c.Tty()
24242411
cmd.Stderr = c.Tty()
2425-
cmd.Env = buildTestEnv(tmpDir)
2412+
cmd.Env = buildTestEnv(tmpDir, publicKey, secretKey)
24262413

24272414
if err := cmd.Start(); err != nil {
24282415
t.Fatalf("Failed to start command: %v", err)

0 commit comments

Comments
 (0)