@@ -63,6 +63,56 @@ def api_with_default_settings(
63
63
factory .delete_all_stacks ()
64
64
65
65
66
+ @pytest .fixture ()
67
+ def api_with_full_settings (
68
+ api_infrastructure_s3_uri ,
69
+ api_definition_s3_uri ,
70
+ policies_uri ,
71
+ request ,
72
+ region ,
73
+ resource_bucket ,
74
+ api_permissions_boundary_policy_arn ,
75
+ ):
76
+ """Deploy the ParallelCluster API infrastructure with all the stack parameters being set"""
77
+ factory = CfnStacksFactory (request .config .getoption ("credential" ))
78
+
79
+ params = []
80
+ if api_definition_s3_uri :
81
+ params .append ({"ParameterKey" : "ApiDefinitionS3Uri" , "ParameterValue" : api_definition_s3_uri })
82
+ if policies_uri :
83
+ params .append ({"ParameterKey" : "PoliciesTemplateUri" , "ParameterValue" : policies_uri })
84
+ if resource_bucket :
85
+ params .append ({"ParameterKey" : "CustomBucket" , "ParameterValue" : resource_bucket })
86
+
87
+ params .append ({"ParameterKey" : "CreateApiUserRole" , "ParameterValue" : "true" })
88
+ params .append ({"ParameterKey" : "EnableFSxS3Access" , "ParameterValue" : "true" })
89
+ params .append ({"ParameterKey" : "EnableIamAdminAccess" , "ParameterValue" : "true" })
90
+ params .append ({"ParameterKey" : "FsxS3Buckets" , "ParameterValue" : "*" })
91
+ params .append ({"ParameterKey" : "IAMRoleAndPolicyPrefix" , "ParameterValue" : "abcdefghij" })
92
+ params .append ({"ParameterKey" : "PermissionsBoundaryPolicy" , "ParameterValue" : api_permissions_boundary_policy_arn })
93
+ params .append ({"ParameterKey" : "Region" , "ParameterValue" : region })
94
+
95
+ template = (
96
+ api_infrastructure_s3_uri
97
+ or f"https://{ resource_bucket } .s3.{ region } .amazonaws.com{ '.cn' if region .startswith ('cn' ) else '' } "
98
+ f"/parallelcluster/{ get_installed_parallelcluster_version ()} /api/parallelcluster-api.yaml"
99
+ )
100
+ logging .info (f"Creating API Server stack in { region } with template { template } " )
101
+ stack = CfnStack (
102
+ name = generate_stack_name ("integ-tests-api" , request .config .getoption ("stackname_suffix" )),
103
+ region = region ,
104
+ parameters = params ,
105
+ capabilities = ["CAPABILITY_NAMED_IAM" , "CAPABILITY_AUTO_EXPAND" ],
106
+ template = template ,
107
+ )
108
+ try :
109
+ factory .create_stack (stack )
110
+ yield stack
111
+ finally :
112
+ if not request .config .getoption ("no_delete" ):
113
+ factory .delete_all_stacks ()
114
+
115
+
66
116
def test_api_infrastructure_with_default_parameters (region , api_with_default_settings ):
67
117
"""Test that creating the API Infrastructure stack with the defaults correctly sets up the Lambda and APIGateway API
68
118
@@ -82,6 +132,27 @@ def test_api_infrastructure_with_default_parameters(region, api_with_default_set
82
132
_test_api_deletion (api_with_default_settings )
83
133
84
134
135
+ def test_api_infrastructure_with_full_parameters (region , api_with_full_settings ):
136
+ """
137
+ Test that creating the API Infrastructure stack with the all the parameters being set with custom values
138
+ correctly sets up the Lambda and APIGateway API
139
+
140
+ :param region: the region where the stack is run
141
+ :api_with_full_settings: factory that deploys a ParallelCluster API
142
+ """
143
+ parallelcluster_lambda_name = api_with_full_settings .cfn_resources ["ParallelClusterFunction" ]
144
+ parallelcluster_lambda_arn = api_with_full_settings .cfn_outputs ["ParallelClusterLambdaArn" ]
145
+
146
+ parallelcluster_api_id = api_with_full_settings .cfn_resources ["ApiGatewayApiWithoutCustomDomain" ]
147
+ parallelcluster_api_url = api_with_full_settings .cfn_outputs ["ParallelClusterApiInvokeUrl" ]
148
+ parallelcluster_user_role = api_with_full_settings .cfn_outputs ["ParallelClusterApiUserRole" ]
149
+
150
+ _assert_parallelcluster_lambda (lambda_name = parallelcluster_lambda_name , lambda_arn = parallelcluster_lambda_arn )
151
+ _assert_parallelcluster_api (api_id = parallelcluster_api_id , api_url = parallelcluster_api_url )
152
+ _test_auth (region , parallelcluster_user_role , parallelcluster_api_url )
153
+ _test_api_deletion (api_with_full_settings )
154
+
155
+
85
156
def _assert_parallelcluster_lambda (lambda_name , lambda_arn ):
86
157
"""Check that the ParallelCluster Lambda is correctly configured
87
158
0 commit comments