Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

IAM: Fix user renaming propagation#13889

Merged
dfangl merged 6 commits into
iam/moto-migrationfrom
daniel/unc-280
Mar 5, 2026
Merged

IAM: Fix user renaming propagation#13889
dfangl merged 6 commits into
iam/moto-migrationfrom
daniel/unc-280

Conversation

@dfangl

@dfangl dfangl commented Mar 5, 2026

Copy link
Copy Markdown
Member

Motivation

When renaming an IAM user via update_user, the UserName field in associated resources (access keys, login profiles, SSH public keys,
etc.) was not being updated. This caused inconsistencies where resources would still reference the old username in API responses.

Changes

Provider fixes (localstack-core/localstack/services/iam/provider.py)

  • Update access key index after user rename to maintain correct lookup
  • Update group memberships when users are renamed
  • Update any underlying resources containing the username with the right username

Test refactoring

  • Move public_key fixture from test_iam_ssh_public_keys.py to conftest.py
  • Move signing_certificate fixture (formerly create_certificate) to conftest.py

Tests

  • tests/aws/services/iam/test_iam_users.py::TestUserRename
  • tests/aws/services/iam/test_iam_groups.py::TestIAMGroupsMembership::test_user_rename_preserves_group_membership

Related

Closes UNC-280

@dfangl dfangl requested a review from pinzon as a code owner March 5, 2026 13:36
@dfangl dfangl added semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Mar 5, 2026
@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown

Test Results - Preflight, Unit

23 104 tests  ±0   21 217 ✅ ±0   6m 14s ⏱️ -2s
     1 suites ±0    1 887 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit a7fad67. ± Comparison against base commit a492fcd.

@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 4s ⏱️ +11s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit a7fad67. ± Comparison against base commit a492fcd.

@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown

Test Results (amd64) - Integration, Bootstrap

  5 files  ±    0    5 suites  ±0   11m 52s ⏱️ - 2h 28m 46s
552 tests  - 5 506  538 ✅  - 4 991  11 💤  - 517  3 ❌ +2 
558 runs   - 5 506  538 ✅  - 4 991  17 💤  - 517  3 ❌ +2 

For more details on these failures, see this check.

Results for commit a7fad67. ± Comparison against base commit a492fcd.

@pinzon pinzon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix, the changes look good.

]
return ListServiceSpecificCredentialsResponse(ServiceSpecificCredentials=result)
return ListServiceSpecificCredentialsResponse(
ServiceSpecificCredentials=result, IsTruncated=False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: IsTruncated=False is making the tests fail due to the snapshot inconsistency

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snapshots were outdated, I updated them!

@dfangl dfangl merged commit 34b8b65 into iam/moto-migration Mar 5, 2026
5 of 7 checks passed
@dfangl dfangl deleted the daniel/unc-280 branch March 5, 2026 15:20
dfangl added a commit that referenced this pull request Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants