Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions test/integration/encrypted/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def test_ephemeral_item_cycle(ddb_table_name, some_cmps, parametrized_actions, p
)


def test_ephemeral_item_cycle_kms(ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item):
def test_ephemeral_item_cycle_kms(ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item):
"""Test the AWS KMS CMP against a small number of curated items."""
functional_test_utils.client_cycle_single_item_check(
all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
)


Expand All @@ -50,10 +50,12 @@ def test_ephemeral_batch_item_cycle(ddb_table_name, some_cmps, parametrized_acti
)


def test_ephemeral_batch_item_cycle_kms(ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item):
def test_ephemeral_batch_item_cycle_kms(
ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item
):
"""Test the AWS KMS CMP against a small number of curated items."""
functional_test_utils.client_cycle_batch_items_check(
all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
)


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


def test_ephemeral_batch_item_cycle_scan_paginator_kms(
ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item
ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item
):
"""Test a the AWS KMS CMP against a small number of curated items using the scan paginator."""
functional_test_utils.client_cycle_batch_items_check_scan_paginator(
all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
)
6 changes: 4 additions & 2 deletions test/integration/encrypted/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def test_ephemeral_batch_item_cycle(ddb_table_name, some_cmps, parametrized_acti
)


def test_ephemeral_batch_item_cycle_kms(ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item):
def test_ephemeral_batch_item_cycle_kms(
ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item
):
"""Test the AWS KMS CMP against a small number of curated items."""
functional_test_utils.resource_cycle_batch_items_check(
all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
)
6 changes: 4 additions & 2 deletions test/integration/encrypted/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def test_ephemeral_item_cycle_batch_writer(ddb_table_name, some_cmps, parametriz
)


def test_ephemeral_item_cycle_kms(ddb_table_name, all_aws_kms_cmps, parametrized_actions, parametrized_item):
def test_ephemeral_item_cycle_kms(ddb_table_name, all_aws_kms_cmp_builders, parametrized_actions, parametrized_item):
"""Test the AWS KMS CMP against a small number of curated items."""
functional_test_utils.table_cycle_check(all_aws_kms_cmps, parametrized_actions, parametrized_item, ddb_table_name)
functional_test_utils.table_cycle_check(
all_aws_kms_cmp_builders(), parametrized_actions, parametrized_item, ddb_table_name
)
17 changes: 12 additions & 5 deletions test/integration/integration_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# language governing permissions and limitations under the License.
"""Helper utilities for integration tests."""
import os
from functools import partial

import pytest

Expand Down Expand Up @@ -48,15 +49,21 @@ def cmk_arn():
return cmk_arn_value()


def set_parameterized_kms_cmps(metafunc, require_attributes=True):
def _build_kms_cmp(require_attributes):
inner_cmp = AwsKmsCryptographicMaterialsProvider(key_id=cmk_arn_value())
if require_attributes:
outer_cmp = functional_test_utils.PassThroughCryptographicMaterialsProviderThatRequiresAttributes(inner_cmp)
return functional_test_utils.PassThroughCryptographicMaterialsProviderThatRequiresAttributes(inner_cmp)
else:
outer_cmp = inner_cmp
return inner_cmp


if "all_aws_kms_cmps" in metafunc.fixturenames:
metafunc.parametrize("all_aws_kms_cmps", (pytest.param(outer_cmp, id="Standard KMS CMP"),))
def set_parameterized_kms_cmps(metafunc, require_attributes=True):

if "all_aws_kms_cmp_builders" in metafunc.fixturenames:
metafunc.parametrize(
"all_aws_kms_cmp_builders",
(pytest.param(partial(_build_kms_cmp, require_attributes), id="Standard KMS CMP"),),
)


@pytest.fixture
Expand Down
20 changes: 10 additions & 10 deletions test/integration/material_providers/test_aws_kms.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def pytest_generate_tests(metafunc):
set_parameterized_kms_cmps(metafunc, require_attributes=False)


def test_verify_user_agent(all_aws_kms_cmps, caplog):
def test_verify_user_agent(all_aws_kms_cmp_builders, caplog):
caplog.set_level(level=logging.DEBUG)

all_aws_kms_cmps.encryption_materials(EncryptionContext())
all_aws_kms_cmp_builders().encryption_materials(EncryptionContext())

assert USER_AGENT_SUFFIX in caplog.text

Expand All @@ -54,10 +54,10 @@ def _many_items():


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


def test_aws_kms_item_cycle(all_aws_kms_cmps, parametrized_actions, parametrized_item):
def test_aws_kms_item_cycle(all_aws_kms_cmp_builders, parametrized_actions, parametrized_item):
crypto_config = CryptoConfig(
materials_provider=all_aws_kms_cmps,
materials_provider=all_aws_kms_cmp_builders(),
encryption_context=EncryptionContext(),
attribute_actions=parametrized_actions,
)
Expand All @@ -80,9 +80,9 @@ def test_aws_kms_item_cycle(all_aws_kms_cmps, parametrized_actions, parametrized
@pytest.mark.slow
@hypothesis_strategies.SLOW_SETTINGS
@hypothesis.given(item=hypothesis_strategies.ddb_items)
def test_aws_kms_item_cycle_hypothesis_slow(all_aws_kms_cmps, hypothesis_actions, item):
def test_aws_kms_item_cycle_hypothesis_slow(all_aws_kms_cmp_builders, hypothesis_actions, item):
crypto_config = CryptoConfig(
materials_provider=all_aws_kms_cmps,
materials_provider=all_aws_kms_cmp_builders(),
encryption_context=EncryptionContext(),
attribute_actions=hypothesis_actions,
)
Expand All @@ -92,9 +92,9 @@ def test_aws_kms_item_cycle_hypothesis_slow(all_aws_kms_cmps, hypothesis_actions
@pytest.mark.veryslow
@hypothesis_strategies.VERY_SLOW_SETTINGS
@hypothesis.given(item=hypothesis_strategies.ddb_items)
def test_aws_kms_item_cycle_hypothesis_veryslow(all_aws_kms_cmps, hypothesis_actions, item):
def test_aws_kms_item_cycle_hypothesis_veryslow(all_aws_kms_cmp_builders, hypothesis_actions, item):
crypto_config = CryptoConfig(
materials_provider=all_aws_kms_cmps,
materials_provider=all_aws_kms_cmp_builders(),
encryption_context=EncryptionContext(),
attribute_actions=hypothesis_actions,
)
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ commands = {[testenv:freeze-upstream-requirements-base]commands} test/upstream-r
[testenv:test-upstream-requirements-base]
sitepackages = False
recreate = True
passenv =
commands = {[testenv:base-command]commands} -m "local and not slow and not veryslow and not nope"

# Test frozen upstream requirements for Python 2.7
[testenv:test-upstream-requirements-py27]
basepython = python2.7
passenv =
deps = -rtest/upstream-requirements-py27.txt
sitepackages = {[testenv:test-upstream-requirements-base]sitepackages}
recreate = {[testenv:test-upstream-requirements-base]recreate}
Expand All @@ -132,6 +134,7 @@ commands = {[testenv:test-upstream-requirements-base]commands}
# Test frozen upstream requirements for Python 3.7
[testenv:test-upstream-requirements-py37]
basepython = python3.7
passenv =
deps = -rtest/upstream-requirements-py37.txt
sitepackages = {[testenv:test-upstream-requirements-base]sitepackages}
recreate = {[testenv:test-upstream-requirements-base]recreate}
Expand Down