8000 Add additional snapshots for testing role encoding · localstack/localstack@bfb5d55 · GitHub
[go: up one dir, main page]

Skip to content

Commit bfb5d55

Browse files
committed
Add additional snapshots for testing role encoding
1 parent 4c623ae commit bfb5d55

File tree

3 files changed

+79
-5
lines changed

3 files changed

+79
-5
lines changed

tests/aws/services/iam/test_iam.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,14 @@ def test_put_role_policy_encoding(self, snapshot, aws_client, create_role, regio
803803

804804
role_name = f"test-role-{short_uid()}"
805805
policy_name = f"test-policy-{short_uid()}"
806-
create_role(RoleName=role_name, AssumeRolePolicyDocument=json.dumps(assume_policy_document))
806+
path = f"/{short_uid()}/"
807+
snapshot.add_transformer(snapshot.transform.key_value("Path"))
808+
create_role_response = create_role(
809+
RoleName=role_name,
810+
AssumeRolePolicyDocument=json.dumps(assume_policy_document),
811+
Path=path,
812+
)
813+
snapshot.match("create-role-response", create_role_response)
807814

808815
aws_client.iam.put_role_policy(
809816
RoleName=role_name, PolicyName=policy_name, PolicyDocument=json.dumps(policy_document)
@@ -816,6 +823,9 @@ def test_put_role_policy_encoding(self, snapshot, aws_client, create_role, regio
816823
get_role_response = aws_client.iam.get_role(RoleName=role_name)
817824
snapshot.match("get-role-response", get_role_response)
818825

826+
list_roles_response = aws_client.iam.list_roles(PathPrefix=path)
827+
snapshot.match("list-roles-response", list_roles_response)
828+
819829
@markers.aws.validated
820830
def test_put_group_policy_encoding(self, snapshot, aws_client, region_name, cleanups):
821831
snapshot.add_transformer(snapshot.transform.iam_api())

tests/aws/services/iam/test_iam.snapshot.json

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,38 @@
415415
}
416416
},
417417
"tests/aws/services/iam/test_iam.py::TestIAMPolicyEncoding::test_put_role_policy_encoding": {
418-
"recorded-date": "25-09-2024, 15:10:46",
418+
"recorded-date": "30-09-2024, 15:17:42",
419419
"recorded-content": {
420+
"create-role-response": {
421+
"Role": {
422+
"Arn": "arn:<partition>:iam::111111111111:role<path:1><role-name:1>",
423+
"AssumeRolePolicyDocument": {
424+
"Statement": [
425+
{
426+
"Action": "sts:AssumeRole",
427+
"Condition": {
428+
"StringEquals": {
429+
"aws:SourceArn": "arn%3Aaws%3Aapigateway%3A<region>%3A%3A%2Frestapis%2Faaeeieije"
430+
}
431+
},
432+
"Effect": "Allow",
433+
"Principal": {
434+
"Service": "lambda.amazonaws.com"
435+
}
436+
}
437+
],
438+
"Version": "2012-10-17"
439+
},
440+
"CreateDate": "datetime",
441+
"Path": "<path:1>",
442+
"RoleId": "<role-id:1>",
443+
"RoleName": "<role-name:1>"
444+
},
445+
"ResponseMetadata": {
446+
"HTTPHeaders": {},
447+
"HTTPStatusCode": 200
448+
}
449+
},
420450
"get-policy-response": {
421451
"PolicyDocument": {
422452
"Statement": [
@@ -441,7 +471,7 @@
441471
},
442472
"get-role-response": {
443473
"Role": {
444-
"Arn": "arn:<partition>:iam::111111111111:role/<role-name:1>",
474+
"Arn": "arn:<partition>:iam::111111111111:role<path:1><role-name:1>",
445475
"AssumeRolePolicyDocument": {
446476
"Statement": [
447477
{
@@ -461,7 +491,7 @@
461491
},
462492
"CreateDate": "datetime",
463493
"MaxSessionDuration": 3600,
464-
"Path": "/",
494+
"Path": "<path:1>",
465495
"RoleId": "<role-id:1>",
466496
"RoleLastUsed": {},
467497
"RoleName": "<role-name:1>"
@@ -470,6 +500,40 @@
470500
"HTTPHeaders": {},
471501
"HTTPStatusCode": 200
472502
}
503+
},
504+
"list-roles-response": {
505+
"IsTruncated": false,
506+
"Roles": [
507+
{
508+
"Arn": "arn:<partition>:iam::111111111111:role<path:1><role-name:1>",
509+
"AssumeRolePolicyDocument": {
510+
"Statement": [
511+
{
512+
"Action": "sts:AssumeRole",
513+
"Condition": {
514+
"StringEquals": {
515+
"aws:SourceArn": "arn%3Aaws%3Aapigateway%3A<region>%3A%3A%2Frestapis%2Faaeeieije"
516+
}
517+
},
518+
"Effect": "Allow",
519+
"Principal": {
520+
"Service": "lambda.amazonaws.com"
521+
}
522+
}
523+
],
524+
"Version": "2012-10-17"
525+
},
526+
"CreateDate": "datetime",
527+
"MaxSessionDuration": 3600,
528+
"Path": "<path:1>",
529+
"RoleId": "<role-id:1>",
530+
"RoleName": "<role-name:1>"
531+
}
532+
],
533+
"ResponseMetadata": {
534+
"HTTPHeaders": {},
535+
"HTTPStatusCode": 200
536+
}
473537
}
474538
}
475539
},

tests/aws/services/iam/test_iam.validation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"last_validated_date": "2024-09-25T15:12:26+00:00"
2525
},
2626
"tests/aws/services/iam/test_iam.py::TestIAMPolicyEncoding::test_put_role_policy_encoding": {
27-
"last_validated_date": "2024-09-25T15:12:24+00:00"
27+
"last_validated_date": "2024-09-30T15:17:41+00:00"
2828
},
2929
"tests/aws/services/iam/test_iam.py::TestIAMPolicyEncoding::test_put_user_policy_encoding": {
3030
"last_validated_date": "2024-09-25T15:12:23+00:00"

0 commit comments

Comments
 (0)
0