Skip to content

Commit 18f38cd

Browse files
committed
move cognita userpool to test-infra bootstrap
1 parent 87d42b0 commit 18f38cd

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

test/e2e/bootstrap_resources.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
from acktest.bootstrapping import Resources
2020
from e2e import bootstrap_directory
2121
from acktest.bootstrapping.elbv2 import NetworkLoadBalancer
22+
from acktest.bootstrapping.cognito_identity import UserPool
2223

2324

2425
@dataclass
2526
class BootstrapResources(Resources):
2627
NetworkLoadBalancer: NetworkLoadBalancer
28+
AuthorizerUserPool1: UserPool
29+
AuthorizerUserPool2: UserPool
2730

2831
_bootstrap_resources = None
2932

test/e2e/service_bootstrap.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# not use this file except in compliance with the License. A copy of the
55
# License is located at
66
#
7-
# http://aws.amazon.com/apache2.0/
7+
# http://aws.amazon.com/apache2.0/
88
#
99
# or in the "license" file accompanying this file. This file is distributed
1010
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
@@ -13,19 +13,27 @@
1313
"""Bootstraps the resources required to run the API Gateway integration tests.
1414
"""
1515
import logging
16+
import os
1617

1718
from acktest.bootstrapping import Resources, BootstrapFailureException
1819

1920
from e2e import bootstrap_directory
2021
from e2e.bootstrap_resources import BootstrapResources
2122
from acktest.bootstrapping.elbv2 import NetworkLoadBalancer
23+
from acktest.bootstrapping.cognito_identity import UserPool
2224

2325

2426
def service_bootstrap() -> Resources:
2527
logging.getLogger().setLevel(logging.INFO)
2628

29+
user_pool_1 = UserPool(name_prefix="ack-apigw-auth-pool-1")
30+
user_pool_2 = UserPool(name_prefix="ack-apigw-auth-pool-2")
31+
2732
resources = BootstrapResources(
28-
NetworkLoadBalancer=NetworkLoadBalancer(name_prefix='vpc-link-test', scheme='internal')
33+
NetworkLoadBalancer=NetworkLoadBalancer(
34+
name_prefix='vpc-link-test', scheme='internal'),
35+
AuthorizerUserPool1=user_pool_1,
36+
AuthorizerUserPool2=user_pool_2,
2937
)
3038

3139
try:
@@ -35,6 +43,7 @@ def service_bootstrap() -> Resources:
3543

3644
return resources
3745

46+
3847
if __name__ == "__main__":
3948
config = service_bootstrap()
4049
# Write config to current directory by default

test/e2e/tests/authorizer_test.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from acktest.resources import random_suffix_name
2424
from acktest.k8s import resource as k8s
25+
from e2e.bootstrap_resources import get_bootstrap_resources
2526
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_apigateway_resource
2627
from e2e.replacement_values import REPLACEMENT_VALUES
2728
from .rest_api_test import simple_rest_api
@@ -32,24 +33,18 @@
3233

3334

3435
@pytest.fixture(scope="function")
35-
def authorizer_test_resources(cognito_client, simple_rest_api):
36+
def authorizer_test_resources(simple_rest_api):
3637
_, rest_api_cr = simple_rest_api
3738
rest_api_id = rest_api_cr["status"].get("id")
3839
assert rest_api_id is not None
3940

40-
user_pool_name_1 = random_suffix_name("user-pool-1", 32)
41-
user_pool_name_2 = random_suffix_name("user-pool-2", 32)
42-
authorizer_name = random_suffix_name("authorizer", 32)
41+
bootstrap_resources = get_bootstrap_resources()
4342

44-
pool1_resp = cognito_client.create_user_pool(PoolName=user_pool_name_1)
45-
user_pool_id_1 = pool1_resp['UserPool']['Id']
46-
user_pool_arn_1 = pool1_resp['UserPool']['Arn']
43+
user_pool_arn_1 = bootstrap_resources.AuthorizerUserPool1.user_pool_arn
44+
user_pool_arn_2 = bootstrap_resources.AuthorizerUserPool2.user_pool_arn
4745

48-
pool2_resp = cognito_client.create_user_pool(PoolName=user_pool_name_2)
49-
user_pool_id_2 = pool2_resp['UserPool']['Id']
50-
user_pool_arn_2 = pool2_resp['UserPool']['Arn']
46+
authorizer_name = random_suffix_name("authorizer", 32)
5147

52-
# Create Authorizer CR using prerequisites
5348
replacements_authorizer = REPLACEMENT_VALUES.copy()
5449
replacements_authorizer["AUTHORIZER_NAME"] = authorizer_name
5550
replacements_authorizer["REST_API_ID"] = rest_api_id
@@ -75,9 +70,6 @@ def authorizer_test_resources(cognito_client, simple_rest_api):
7570
authorizer_ref, wait_periods=3, period_length=DEFAULT_WAIT_SECS)
7671
assert deleted_auth
7772

78-
cognito_client.delete_user_pool(UserPoolId=user_pool_id_1)
79-
cognito_client.delete_user_pool(UserPoolId=user_pool_id_2)
80-
8173

8274
@service_marker
8375
@pytest.mark.canary

0 commit comments

Comments
 (0)