Skip to content

Commit 4d6af58

Browse files
committed
fix tests
1 parent c7fc159 commit 4d6af58

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

pkg/integration_testing/assume_e2e_test.go

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ func TestAssumeCommandE2E(t *testing.T) {
6464
xdgConfigHome := filepath.Join(tempDir, "config")
6565
grantedDir := filepath.Join(xdgConfigHome, "granted")
6666

67-
for _, dir := range []string{awsDir, grantedDir} {
67+
// Create all necessary directories with proper permissions
68+
for _, dir := range []string{awsDir, grantedDir, xdgConfigHome} {
6869
err := os.MkdirAll(dir, 0755)
6970
require.NoError(t, err)
7071
}
7172

73+
// Ensure the granted directory is writable for config saves
74+
err := os.Chmod(grantedDir, 0755)
75+
require.NoError(t, err)
76+
7277
// Create AWS config with a simple IAM profile for testing
7378
awsConfig := `[profile test-iam]
7479
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
@@ -144,6 +149,30 @@ FileBackend = ""
144149
})
145150

146151
t.Run("AssumeProfileWithSSO", func(t *testing.T) {
152+
// Debug: Check if granted config exists and is readable
153+
configContent, err := os.ReadFile(grantedConfigPath)
154+
if err != nil {
155+
t.Logf("Error reading granted config: %v", err)
156+
} else {
157+
t.Logf("Granted config content:\n%s", string(configContent))
158+
}
159+
160+
// Debug environment variables
161+
t.Logf("HOME: %s", homeDir)
162+
t.Logf("XDG_CONFIG_HOME: %s", xdgConfigHome)
163+
t.Logf("Config path: %s", grantedConfigPath)
164+
165+
// List contents of granted directory
166+
files, err := os.ReadDir(grantedDir)
167+
if err != nil {
168+
t.Logf("Error reading granted dir: %v", err)
169+
} else {
170+
t.Logf("Granted dir contents:")
171+
for _, f := range files {
172+
t.Logf(" %s", f.Name())
173+
}
174+
}
175+
147176
// Create AWS config with SSO profile
148177
ssoConfig := fmt.Sprintf(`[profile test-sso]
149178
sso_account_id = 123456789012
@@ -366,7 +395,7 @@ func NewAssumeE2EMockServer() *AssumeE2EMockServer {
366395
server.URL = serverURL
367396

368397
go func() {
369-
if err := server.Server.Serve(listener); err != nil && err != http.ErrServerClosed {
398+
if err := server.Serve(listener); err != nil && err != http.ErrServerClosed {
370399
fmt.Printf("Server error: %v\n", err)
371400
}
372401
}()
@@ -377,7 +406,7 @@ func NewAssumeE2EMockServer() *AssumeE2EMockServer {
377406
func (s *AssumeE2EMockServer) Close() {
378407
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
379408
defer cancel()
380-
if err := s.Server.Shutdown(ctx); err != nil {
409+
if err := s.Shutdown(ctx); err != nil {
381410
fmt.Printf("Error shutting down server: %v\n", err)
382411
}
383412
}

0 commit comments

Comments
 (0)