Fix IAM identity loss on S3 restart migration (#8343)
* Fix IAM reload after legacy config migration Handle legacy identity.json metadata events by reloading from the credential manager instead of parsing event content, and watch the correct /etc/iam multi-file directories so identity changes are applied. Add regression tests for legacy deletion and /etc/iam/identities change events. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix auth_credentials_subscribe_test helper to not pollute global memory store The SaveConfiguration call was affecting other tests. Use local credential manager and ReplaceS3ApiConfiguration instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix IAM event watching: subscribe to IAM directories and improve directory matching - Add /etc/iam and its subdirectories (identities, policies, service_accounts) to directoriesToWatch - Fix directory matching to avoid false positives from sibling directories - Use exact match or prefix with trailing slash instead of plain HasPrefix - Prevents matching hypothetical /etc/iam/identities_backup directory This ensures IAM config change events are actually delivered to the handler. * fix tests --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -427,6 +427,13 @@ func TestNewIdentityAccessManagementWithStoreEnvVars(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Reset the memory store to avoid test pollution
|
||||
if store := credential.Stores[0]; store.GetName() == credential.StoreTypeMemory {
|
||||
if memStore, ok := store.(interface{ Reset() }); ok {
|
||||
memStore.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
// Set up environment variables
|
||||
if tt.accessKeyId != "" {
|
||||
os.Setenv("AWS_ACCESS_KEY_ID", tt.accessKeyId)
|
||||
@@ -467,6 +474,13 @@ func TestNewIdentityAccessManagementWithStoreEnvVars(t *testing.T) {
|
||||
// but contains no identities (e.g., only KMS settings), environment variables should still work.
|
||||
// This test validates the fix for issue #7311.
|
||||
func TestConfigFileWithNoIdentitiesAllowsEnvVars(t *testing.T) {
|
||||
// Reset the memory store to avoid test pollution
|
||||
if store := credential.Stores[0]; store.GetName() == credential.StoreTypeMemory {
|
||||
if memStore, ok := store.(interface{ Reset() }); ok {
|
||||
memStore.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
// Set environment variables
|
||||
testAccessKey := "AKIATEST1234567890AB"
|
||||
testSecretKey := "testSecret1234567890123456789012345678901234"
|
||||
|
||||
Reference in New Issue
Block a user