Skip to content

Commit

Permalink
fix(tests): fix session policy arn in arg namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarneyjr committed Oct 16, 2024
1 parent 3bd9759 commit a5f579f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/unit/awsume/awsumepy/test_default_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

def generate_namespace_with_defaults(
session_policy=None,
session_policy_arns=None,
session_tags=None,
region=None,
source_profile=None,
Expand All @@ -26,8 +27,10 @@ def generate_namespace_with_defaults(
who=None,
**kwargs
) -> argparse.Namespace:
arns = [] if session_policy_arns is None else session_policy_arns
return argparse.Namespace(
session_policy=session_policy,
session_policy_arns=arns,
session_tags=session_tags,
region=region,
source_profile=source_profile,
Expand Down Expand Up @@ -429,6 +432,7 @@ def test_assume_role_from_cli(aws_lib: MagicMock, profile_lib: MagicMock):
aws_lib.assume_role.assert_called_with(
{}, arguments.role_arn, 'awsume-cli-role',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=profile_lib.get_region.return_value,
external_id=arguments.external_id,
role_duration=0,
Expand Down Expand Up @@ -467,6 +471,7 @@ def test_assume_role_from_cli_source_profile(aws_lib: MagicMock, profile_lib: Ma
arguments.role_arn,
'awsume-cli-role',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=profile_lib.get_region.return_value,
external_id=arguments.external_id,
role_duration=0,
Expand Down Expand Up @@ -505,6 +510,7 @@ def test_assume_role_from_cli_source_profile_role_duration_mfa(aws_lib: MagicMoc
arguments.role_arn,
'awsume-cli-role',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=profile_lib.get_region.return_value,
external_id=arguments.external_id,
role_duration='43200',
Expand Down Expand Up @@ -544,6 +550,7 @@ def test_assume_role_from_cli_source_profile_role_duration_no_mfa(aws_lib: Magic
arguments.role_arn,
'awsume-cli-role',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=profile_lib.get_region.return_value,
external_id=arguments.external_id,
role_duration='43200',
Expand Down Expand Up @@ -589,6 +596,7 @@ def test_assume_role_from_cli_source_profile_no_role_duration_mfa(aws_lib: Magic
arguments.role_arn,
'awsume-cli-role',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=profile_lib.get_region.return_value,
external_id=arguments.external_id,
role_duration=0,
Expand Down Expand Up @@ -626,6 +634,7 @@ def test_assume_role_from_cli_source_profile_no_role_duration_no_mfa(aws_lib: Ma
arguments.role_arn,
'awsume-cli-role',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=profile_lib.get_region.return_value,
external_id=arguments.external_id,
role_duration=0,
Expand Down Expand Up @@ -699,6 +708,7 @@ def test_get_credentials(aws_lib: MagicMock, create_autoawsume_profile: MagicMoc
'myrolearn',
'mysessionname',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=None,
external_id='myexternalid',
role_duration=0,
Expand Down Expand Up @@ -752,6 +762,7 @@ def test_get_credentials_auto_refresh(aws_lib: MagicMock, create_autoawsume_prof
'myrolearn',
'mysessionname',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=None,
external_id='myexternalid',
role_duration=0,
Expand Down Expand Up @@ -795,6 +806,7 @@ def test_get_credentials_role_duration(aws_lib: MagicMock, create_autoawsume_pro
'myrolearn',
'mysessionname',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=None,
external_id='myexternalid',
role_duration=43200,
Expand Down Expand Up @@ -910,6 +922,7 @@ def test_get_credentials_no_mfa_role(aws_lib: MagicMock, create_autoawsume_profi
'myrolearn',
'mysessionname',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
region=None,
external_id='myexternalid',
role_duration=0,
Expand Down Expand Up @@ -1009,6 +1022,7 @@ def test_post_add_arguments_session_tags(aws_lib: MagicMock):
arguments.role_arn,
'awsume-cli-role',
session_policy=arguments.session_policy,
session_policy_arns=arguments.session_policy_arns,
external_id=arguments.external_id,
role_duration='43200',
tags=[
Expand Down

0 comments on commit a5f579f

Please sign in to comment.