Skip to content

Commit a8fb0ed

Browse files
chore: Change MPL branch, remove PYTHONPATH workarounds (#683)
1 parent 23084a0 commit a8fb0ed

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

examples/src/branch_key_id_supplier_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ def get_branch_key_id(
2525
"""Returns branch key ID from the tenant ID in input's encryption context."""
2626
encryption_context: Dict[str, str] = param.encryption_context
2727

28-
if b"tenant" not in encryption_context:
28+
if "tenant" not in encryption_context:
2929
raise ValueError("EncryptionContext invalid, does not contain expected tenant key value pair.")
3030

31-
tenant_key_id: str = encryption_context.get(b"tenant")
31+
tenant_key_id: str = encryption_context.get("tenant")
3232
branch_key_id: str
3333

34-
if tenant_key_id == b"TenantA":
34+
if tenant_key_id == "TenantA":
3535
branch_key_id = self.branch_key_id_for_tenant_A
36-
elif tenant_key_id == b"TenantB":
36+
elif tenant_key_id == "TenantB":
3737
branch_key_id = self.branch_key_id_for_tenant_B
3838
else:
3939
raise ValueError(f"Item does not contain valid tenant ID: {tenant_key_id=}")

examples/src/default_cryptographic_materials_manager_example.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
For more information on Cryptographic Material Managers, see
1919
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#crypt-materials-manager
2020
"""
21-
import sys
22-
2321
import boto3
2422
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
2523
from aws_cryptographic_materialproviders.mpl.config import MaterialProvidersConfig
@@ -33,11 +31,6 @@
3331
import aws_encryption_sdk
3432
from aws_encryption_sdk import CommitmentPolicy
3533

36-
# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
37-
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])
38-
39-
sys.path.append(MODULE_ROOT_DIR)
40-
4134
EXAMPLE_DATA: bytes = b"Hello World"
4235

4336

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
aws-cryptographic-material-providers @ git+https://github.com/aws/aws-cryptographic-material-providers-library.git@lucmcdon/python-mpl#subdirectory=AwsCryptographicMaterialProviders/runtimes/python
1+
aws-cryptographic-material-providers @ git+https://github.com/aws/aws-cryptographic-material-providers-library.git@lucmcdon/python-mpl-v2#subdirectory=AwsCryptographicMaterialProviders/runtimes/python

test_vector_handlers/src/awses_test_vectors/manifests/full_message/decrypt.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import json
99
import os
1010
from enum import Enum
11+
import contextlib
12+
import io
1113

1214
import attr
1315
import aws_encryption_sdk
@@ -126,8 +128,19 @@ def match(self, name, decrypt_fn):
126128
# The ESDK implementations are not consistent in the types of errors they produce
127129
# or the exact error messages they use. The most important thing to test is that decryption
128130
# fails in some way, and hence the overly-broad implicit try/catch here.
131+
129132
with pytest.raises(Exception):
130-
decrypt_fn()
133+
# Here, an exception is expected.
134+
# However, when the expected exception is raised,
135+
# the Python environment will write stderrs to console.
136+
# Redirect stderr to null-like sink
137+
# so local and CI build logs are cleaner,
138+
# and any actual issues are easier to see.
139+
# If an exception is not raised as expected,
140+
# `pytest.raises` will fail.
141+
tmp_file = io.StringIO()
142+
with contextlib.redirect_stderr(tmp_file):
143+
decrypt_fn()
131144
except BaseException:
132145
# Translate the exception just to attach context.
133146
raise RuntimeError(

test_vector_handlers/src/awses_test_vectors/manifests/mpl_keyring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from aws_cryptographic_materialproviders.mpl.models import CreateMultiKeyringInput
3232

3333
import _dafny
34-
import UTF8
34+
from standard_library.internaldafny.generated import UTF8
3535

3636
# Ignore pylint not being able to read a module that requires the MPL
3737
# pylint: disable=no-name-in-module

0 commit comments

Comments
 (0)