-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalized an parametrized tests to be applied to ExampleDataBucket,…
… too
- Loading branch information
Showing
3 changed files
with
99 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 20 additions & 12 deletions
32
test/unit/aws/test_deploy_vm_bucket_waf.py → test/unit/aws/test_deploy_waf.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
import pytest | ||
from typing import Union | ||
from unittest.mock import Mock, create_autospec | ||
|
||
from exasol.ds.sandbox.lib.aws_access.aws_access import AwsAccess | ||
from exasol.ds.sandbox.lib.cloudformation_templates import VmBucketCfTemplate | ||
from exasol.ds.sandbox.lib.cloudformation_templates import ( | ||
VmBucketCfTemplate, | ||
ExampleDataCfTemplate, | ||
) | ||
from test.aws.templates import TEST_IP, TEST_ACL_ARN | ||
from test.aws.mock_data import get_waf_cloudformation_mock_data | ||
from test.aws.mock_data import ( | ||
cf_stack_mock, | ||
cf_stack_outputs, | ||
) | ||
from test.mock_cast import mock_cast | ||
|
||
|
||
# To enable running this test case for ExampleDataCfTemplate | ||
# would require to create modified copies of | ||
# - get_s3_cloudformation_mock_data | ||
# - get_waf_cloudformation_mock_data | ||
# - TEST_BUCKET_ID | ||
# | ||
# Is this worth the effort and/or code duplication? | ||
def test_find_acl_arn(test_config): | ||
@pytest.fixture(params=(VmBucketCfTemplate, ExampleDataCfTemplate)) | ||
def cf_template_testee(request): | ||
return request.param | ||
|
||
|
||
def test_find_acl_arn(test_config, cf_template_testee): | ||
""" | ||
This test uses a mock to validate the correct finding of the ACL Arn | ||
in the mocked cloudformation stack. | ||
""" | ||
aws: Union[AwsAccess, Mock] = create_autospec(AwsAccess, spec_set=True) | ||
mock_cast(aws.describe_stacks).return_value = get_waf_cloudformation_mock_data() | ||
mock_cast(aws.instantiate_for_region).return_value = aws | ||
testee = VmBucketCfTemplate(aws).waf(config=test_config) | ||
testee = cf_template_testee(aws).waf(config=test_config) | ||
mock_cast(aws.describe_stacks).return_value = cf_stack_mock( | ||
testee.stack_name, | ||
cf_stack_outputs(cf_template_testee.__name__, "waf"), | ||
) | ||
testee.setup(TEST_IP) | ||
mock_cast(aws.upload_cloudformation_stack).assert_called_once() | ||
assert TEST_ACL_ARN == testee.acl_arn |