Skip to content

Migrate IAM AWS managed policy tests from moto to LS#13767

Open
dfangl wants to merge 2 commits intoiam/moto-migrationfrom
daniel/unc-240
Open

Migrate IAM AWS managed policy tests from moto to LS#13767
dfangl wants to merge 2 commits intoiam/moto-migrationfrom
daniel/unc-240

Conversation

@dfangl
Copy link
Member

@dfangl dfangl commented Feb 13, 2026

Motivation

We also want to migrate the IAM managed policy tests. As with the other PRs, this will for now skip most of the new tests, and the tests are migrated to LocalStack standards.

Changes

Moto Source File Moto Test Function LocalStack File LocalStack Class LocalStack Test Method Notes
test_iam.py:789 test_get_aws_managed_policy test_iam_managed_policies.py TestGetAwsManagedPolicy test_get_aws_managed_policy Replaced region parametrization with partition fixture
test_iam.py:830 test_get_aws_managed_policy_version test_iam_managed_policies.py TestGetAwsManagedPolicy test_get_aws_managed_policy_version Same coverage (error + success for v1)
test_iam.py:853 test_get_aws_managed_policy_v8_version test_iam_managed_policies.py TestGetAwsManagedPolicy test_get_aws_managed_policy_higher_version Uses dynamic version discovery instead of hardcoded v8
test_iam.py:2036 test_managed_policy (list scope parts) test_iam_managed_policies.py TestListPoliciesScope test_list_policies_scope_local, test_list_policies_scope_aws, test_list_policies_scope_all Split into focused tests; uses MaxItems and assertions to avoid brittle large snapshots
test_iam.py:2036 test_managed_policy (attach/detach parts) test_iam_managed_policies.py TestListPoliciesScope test_list_policies_only_attached OnlyAttached filter with attach/detach verification
test_iam.py:2036 test_managed_policy (role attach/detach + errors) test_iam_roles.py TestRoleManagedPolicies test_attach_detach_aws_managed_policy_role Moved to roles module; includes error cases for detaching already-detached and non-existent policies
test_iam_groups.py:217 test_attach_group_policies test_iam_groups.py TestAttachAwsManagedPolicyToGroup test_attach_detach_aws_managed_policy_group Same coverage with snapshot testing
test_iam_resets.py:11 test_policies_are_not_kept_after_mock_ends - - - Skipped: moto-specific (tests mock reset behavior)
test_iam_resets.py:46 test_policies_are_loaded_when_using_env_variable - - - Skipped: moto-specific (tests env variable config)
test_iam.py:2449 test_get_account_authorization_details - - - Skipped: out of scope for this migration

Tests

Tests are manually verified, and run against AWS both with and without snapshot updates.

Related

Closes UNC-240

@dfangl dfangl added the semver: patch Non-breaking changes which can be included in patch releases label Feb 13, 2026
@dfangl dfangl requested a review from pinzon as a code owner February 13, 2026 14:57
@dfangl dfangl added docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases labels Feb 13, 2026
@github-actions
Copy link

Test Results - Preflight, Unit

23 099 tests   - 12   21 237 ✅  - 12   6m 49s ⏱️ +38s
     1 suites ± 0    1 862 💤 ± 0 
     1 files   ± 0        0 ❌ ± 0 

Results for commit 3bbdfe0. ± Comparison against base commit e0bfa14.

@github-actions
Copy link

LocalStack Community integration with Pro

  2 files    2 suites   1m 2s ⏱️
413 tests 216 ✅ 197 💤 0 ❌
415 runs  216 ✅ 199 💤 0 ❌

Results for commit 3bbdfe0.

@github-actions
Copy link

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   2m 53s ⏱️ -6s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 3bbdfe0. ± Comparison against base commit e0bfa14.

@github-actions
Copy link

Test Results (amd64) - Integration, Bootstrap

  5 files    5 suites   9m 38s ⏱️
437 tests 240 ✅ 197 💤 0 ❌
443 runs  240 ✅ 203 💤 0 ❌

Results for commit 3bbdfe0.

Copy link
Member

@pinzon pinzon left a comment

Choose a reason for hiding this comment

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

LGTM but there is one change request to be addressed.

Comment on lines +134 to +136
paginator = aws_client.iam.get_paginator("list_policies")
result = paginator.paginate().build_full_result()
all_policy_names = {p["PolicyName"] for p in result["Policies"]}
Copy link
Member

Choose a reason for hiding this comment

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

comment: 😅 I guess we're not snapshoting this

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, not for now 😅

Comment on lines +194 to +195
class TestAttachAwsManagedPolicyToGroup:
"""Tests for attaching/detaching AWS-managed policies to/from groups."""
Copy link
Member

Choose a reason for hiding this comment

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

Change: I think that at some point this was the original location of test_attach_detach_aws_managed_policy_group that now is in the test_iam_groups.py file. Lets remove this class if it's not necessary anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I forgot about that one when moving, will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants