Skip to content

Commit 45f3826

Browse files
authored
Merge pull request #123 from mattsb42-aws/fixit
Fix upstream tests
2 parents a709872 + c2fd39d commit 45f3826

File tree

6 files changed

+41
-25
lines changed

6 files changed

+41
-25
lines changed

test/integration/encrypted/test_client.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def test_ephemeral_item_cycle(ddb_table_name, some_cmps, parametrized_actions, p
3636
)
3737

3838

39-
def test_ephemeral_item_cycle_kms(ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item):
39+
def test_ephemeral_item_cycle_kms(ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item):
4040
"""Test the AWS KMS CMP against a small number of curated items."""
4141
functional_test_utils.client_cycle_single_item_check(
42-
all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name
42+
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
4343
)
4444

4545

@@ -50,10 +50,12 @@ def test_ephemeral_batch_item_cycle(ddb_table_name, some_cmps, parametrized_acti
5050
)
5151

5252

53-
def test_ephemeral_batch_item_cycle_kms(ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item):
53+
def test_ephemeral_batch_item_cycle_kms(
54+
ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item
55+
):
5456
"""Test the AWS KMS CMP against a small number of curated items."""
5557
functional_test_utils.client_cycle_batch_items_check(
56-
all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name
58+
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
5759
)
5860

5961

@@ -65,9 +67,9 @@ def test_ephemeral_batch_item_cycle_scan_paginator(ddb_table_name, some_cmps, pa
6567

6668

6769
def test_ephemeral_batch_item_cycle_scan_paginator_kms(
68-
ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item
70+
ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item
6971
):
7072
"""Test a the AWS KMS CMP against a small number of curated items using the scan paginator."""
7173
functional_test_utils.client_cycle_batch_items_check_scan_paginator(
72-
all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name
74+
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
7375
)

test/integration/encrypted/test_resource.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ def test_ephemeral_batch_item_cycle(ddb_table_name, some_cmps, parametrized_acti
3636
)
3737

3838

39-
def test_ephemeral_batch_item_cycle_kms(ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item):
39+
def test_ephemeral_batch_item_cycle_kms(
40+
ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item
41+
):
4042
"""Test the AWS KMS CMP against a small number of curated items."""
4143
functional_test_utils.resource_cycle_batch_items_check(
42-
all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name
44+
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
4345
)

test/integration/encrypted/test_table.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def test_ephemeral_item_cycle_batch_writer(ddb_table_name, some_cmps, parametriz
4141
)
4242

4343

44-
def test_ephemeral_item_cycle_kms(ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item):
44+
def test_ephemeral_item_cycle_kms(ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item):
4545
"""Test the AWS KMS CMP against a small number of curated items."""
46-
functional_test_utils.table_cycle_check(all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name)
46+
functional_test_utils.table_cycle_check(
47+
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
48+
)

test/integration/integration_test_utils.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313
"""Helper utilities for integration tests."""
1414
import os
15+
from functools import partial
1516

1617
import pytest
1718

@@ -48,15 +49,21 @@ def cmk_arn():
4849
return cmk_arn_value()
4950

5051

51-
def set_parameterized_kms_cmps(metafunc, require_attributes=True):
52+
def _build_kms_cmp(require_attributes):
5253
inner_cmp = AwsKmsCryptographicMaterialsProvider(key_id=cmk_arn_value())
5354
if require_attributes:
54-
outer_cmp = functional_test_utils.PassThroughCryptographicMaterialsProviderThatRequiresAttributes(inner_cmp)
55+
return functional_test_utils.PassThroughCryptographicMaterialsProviderThatRequiresAttributes(inner_cmp)
5556
else:
56-
outer_cmp = inner_cmp
57+
return inner_cmp
58+
5759

58-
if "all_aws_kms_cmps" in metafunc.fixturenames:
59-
metafunc.parametrize("all_aws_kms_cmps", (pytest.param(outer_cmp, id="Standard KMS CMP"),))
60+
def set_parameterized_kms_cmps(metafunc, require_attributes=True):
61+
62+
if "all_aws_kms_cmp_builders" in metafunc.fixturenames:
63+
metafunc.parametrize(
64+
"all_aws_kms_cmp_builders",
65+
(pytest.param(partial(_build_kms_cmp, require_attributes), id="Standard KMS CMP"),),
66+
)
6067

6168

6269
@pytest.fixture

test/integration/material_providers/test_aws_kms.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def pytest_generate_tests(metafunc):
3636
set_parameterized_kms_cmps(metafunc, require_attributes=False)
3737

3838

39-
def test_verify_user_agent(all_aws_kms_cmps, caplog):
39+
def test_verify_user_agent(all_aws_kms_cmp_builders, caplog):
4040
caplog.set_level(level=logging.DEBUG)
4141

42-
all_aws_kms_cmps.encryption_materials(EncryptionContext())
42+
all_aws_kms_cmp_builders().encryption_materials(EncryptionContext())
4343

4444
assert USER_AGENT_SUFFIX in caplog.text
4545

@@ -54,10 +54,10 @@ def _many_items():
5454

5555

5656
@pytest.mark.parametrize("item", _many_items())
57-
def test_aws_kms_diverse_indexes(all_aws_kms_cmps, item):
57+
def test_aws_kms_diverse_indexes(all_aws_kms_cmp_builders, item):
5858
"""Verify that AWS KMS cycle works for items with all possible combinations for primary index attribute types."""
5959
crypto_config = CryptoConfig(
60-
materials_provider=all_aws_kms_cmps,
60+
materials_provider=all_aws_kms_cmp_builders(),
6161
encryption_context=EncryptionContext(
6262
partition_key_name="partition_key", sort_key_name="sort_key", attributes=dict_to_ddb(item)
6363
),
@@ -68,9 +68,9 @@ def test_aws_kms_diverse_indexes(all_aws_kms_cmps, item):
6868
functional_test_utils.cycle_item_check(item, crypto_config)
6969

7070

71-
def test_aws_kms_item_cycle(all_aws_kms_cmps, parametrized_actions, parametrized_item):
71+
def test_aws_kms_item_cycle(all_aws_kms_cmp_builders, parametrized_actions, parametrized_item):
7272
crypto_config = CryptoConfig(
73-
materials_provider=all_aws_kms_cmps,
73+
materials_provider=all_aws_kms_cmp_builders(),
7474
encryption_context=EncryptionContext(),
7575
attribute_actions=parametrized_actions,
7676
)
@@ -80,9 +80,9 @@ def test_aws_kms_item_cycle(all_aws_kms_cmps, parametrized_actions, parametrized
8080
@pytest.mark.slow
8181
@hypothesis_strategies.SLOW_SETTINGS
8282
@hypothesis.given(item=hypothesis_strategies.ddb_items)
83-
def test_aws_kms_item_cycle_hypothesis_slow(all_aws_kms_cmps, hypothesis_actions, item):
83+
def test_aws_kms_item_cycle_hypothesis_slow(all_aws_kms_cmp_builders, hypothesis_actions, item):
8484
crypto_config = CryptoConfig(
85-
materials_provider=all_aws_kms_cmps,
85+
materials_provider=all_aws_kms_cmp_builders(),
8686
encryption_context=EncryptionContext(),
8787
attribute_actions=hypothesis_actions,
8888
)
@@ -92,9 +92,9 @@ def test_aws_kms_item_cycle_hypothesis_slow(all_aws_kms_cmps, hypothesis_actions
9292
@pytest.mark.veryslow
9393
@hypothesis_strategies.VERY_SLOW_SETTINGS
9494
@hypothesis.given(item=hypothesis_strategies.ddb_items)
95-
def test_aws_kms_item_cycle_hypothesis_veryslow(all_aws_kms_cmps, hypothesis_actions, item):
95+
def test_aws_kms_item_cycle_hypothesis_veryslow(all_aws_kms_cmp_builders, hypothesis_actions, item):
9696
crypto_config = CryptoConfig(
97-
materials_provider=all_aws_kms_cmps,
97+
materials_provider=all_aws_kms_cmp_builders(),
9898
encryption_context=EncryptionContext(),
9999
attribute_actions=hypothesis_actions,
100100
)

tox.ini

+3
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,13 @@ commands = {[testenv:freeze-upstream-requirements-base]commands} test/upstream-r
119119
[testenv:test-upstream-requirements-base]
120120
sitepackages = False
121121
recreate = True
122+
passenv =
122123
commands = {[testenv:base-command]commands} -m "local and not slow and not veryslow and not nope"
123124

124125
# Test frozen upstream requirements for Python 2.7
125126
[testenv:test-upstream-requirements-py27]
126127
basepython = python2.7
128+
passenv =
127129
deps = -rtest/upstream-requirements-py27.txt
128130
sitepackages = {[testenv:test-upstream-requirements-base]sitepackages}
129131
recreate = {[testenv:test-upstream-requirements-base]recreate}
@@ -132,6 +134,7 @@ commands = {[testenv:test-upstream-requirements-base]commands}
132134
# Test frozen upstream requirements for Python 3.7
133135
[testenv:test-upstream-requirements-py37]
134136
basepython = python3.7
137+
passenv =
135138
deps = -rtest/upstream-requirements-py37.txt
136139
sitepackages = {[testenv:test-upstream-requirements-base]sitepackages}
137140
recreate = {[testenv:test-upstream-requirements-base]recreate}

0 commit comments

Comments
 (0)