Skip to content

Commit 2ce6807

Browse files
author
Lucas McDonald
committed
m
1 parent f3ae7a1 commit 2ce6807

File tree

18 files changed

+554
-125
lines changed

18 files changed

+554
-125
lines changed

.github/workflows/ci_test_python.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# This workflow runs only Dafny-transpiled Python tests.
2+
name: test python
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: true
10+
type: string
11+
regenerate-code:
12+
description: "Regenerate code using smithy-dafny"
13+
required: false
14+
default: false
15+
type: boolean
16+
mpl-head:
17+
description: "Running on MPL HEAD"
18+
required: false
19+
default: false
20+
type: boolean
21+
22+
jobs:
23+
testPythonDafny:
24+
strategy:
25+
matrix:
26+
library: [DynamoDbEncryption]
27+
python-version: ["3.11", "3.12", "3.13"]
28+
os: [
29+
macos-13,
30+
ubuntu-22.04,
31+
# Dafny-transpiled Python tests use a PYTHONPATH hack that doesn't work on Windows.
32+
# Windows is tested with non-Dafny-transpiled Python tests.
33+
windows-latest
34+
]
35+
runs-on: ${{ matrix.os }}
36+
permissions:
37+
id-token: write
38+
contents: read
39+
steps:
40+
- name: Support longpaths on Git checkout
41+
run: |
42+
git config --global core.longpaths true
43+
- uses: actions/checkout@v3
44+
with:
45+
submodules: recursive
46+
47+
- name: Setup Python
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
- name: Setup Dafny
53+
uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/
54+
with:
55+
dafny-version: ${{ inputs.dafny }}
56+
57+
- name: Update MPL submodule if using MPL HEAD
58+
if: ${{ inputs.mpl-head == true }}
59+
working-directory: submodules/MaterialProviders
60+
run: |
61+
git checkout main
62+
git pull
63+
git submodule update --init --recursive
64+
git rev-parse HEAD
65+
66+
- name: Regenerate code using smithy-dafny if necessary
67+
if: ${{ inputs.regenerate-code }}
68+
uses: ./.github/actions/polymorph_codegen
69+
with:
70+
dafny: ${{ env.DAFNY_VERSION }}
71+
library: ${{ matrix.library }}
72+
diff-generated-code: false
73+
update-and-regenerate-mpl: true
74+
75+
- name: Download Dependencies
76+
working-directory: ./${{ matrix.library }}
77+
run: make setup_python
78+
79+
- name: Configure AWS Credentials
80+
uses: aws-actions/configure-aws-credentials@v4
81+
with:
82+
aws-region: us-west-2
83+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
84+
role-session-name: DDBEC-Dafny-Net-Tests
85+
86+
- name: Compile ${{ matrix.library }} implementation
87+
shell: bash
88+
working-directory: ./${{ matrix.library }}
89+
run: |
90+
# This works because `node` is installed by default on GHA runners
91+
CORES=$(node -e 'console.log(os.cpus().length)')
92+
make transpile_python CORES=$CORES
93+
94+
- name: Test ${{ matrix.library }} Dafny-transpiled Python tests
95+
# Dafny-transpiled Python tests use a PYTHONPATH hack that doesn't work on Windows.
96+
# Windows is tested with non-Dafny-transpiled Python tests.
97+
if: ${{ matrix.os != 'windows-latest' }}
98+
working-directory: ./${{ matrix.library }}
99+
shell: bash
100+
run: |
101+
tox -e dafnytests
102+
103+
- name: Test ${{ matrix.library }} Python unit tests
104+
working-directory: ./${{ matrix.library }}
105+
shell: bash
106+
run: |
107+
tox -e unit
108+
109+
- name: Test ${{ matrix.library }} Python integration tests
110+
working-directory: ./${{ matrix.library }}
111+
shell: bash
112+
run: |
113+
tox -e integ
114+
115+
- name: Test ${{ matrix.library }} Python coverage
116+
working-directory: ./${{ matrix.library }}
117+
shell: bash
118+
run: |
119+
tox -e encrypted-interface-coverage
120+
tox -e client-to-resource-conversions-coverage
121+
tox -e resource-to-client-conversions-coverage
122+

DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -891,15 +891,3 @@ structure DynamoDbEncryptionException {
891891
@required
892892
message: String,
893893
}
894-
895-
structure ExtractAttrtibutesInput {
896-
@required
897-
s: string
898-
ex: ExpressionAttributeNameMap
899-
}
900-
901-
structure ExtractAttrtibutesOutput {
902-
@required
903-
s: string
904-
ex: ExpressionAttributeNameMap
905-
}

DynamoDbEncryption/runtimes/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.poetry]
2-
name = "aws-database-encryption-sdk"
2+
name = "aws-dbesdk-dynamodb"
33
version = "0.1.0"
44
description = ""
55
authors = ["AWS Crypto Tools <[email protected]>"]

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/smithygenerated/aws_cryptography_dbencryptionsdk_dynamodb/dafny_to_smithy.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ def aws_cryptography_dbencryptionsdk_dynamodb_MultiKeyStore(dafny_input):
218218
if (dafny_input.cache.is_Some)
219219
else None
220220
),
221+
partition_id=(
222+
(
223+
b"".join(
224+
ord(c).to_bytes(2, "big") for c in dafny_input.partitionId.value
225+
).decode("utf-16-be")
226+
)
227+
if (dafny_input.partitionId.is_Some)
228+
else None
229+
),
221230
)
222231

223232

@@ -227,6 +236,24 @@ def aws_cryptography_dbencryptionsdk_dynamodb_SingleKeyStore(dafny_input):
227236
"utf-16-be"
228237
),
229238
cache_ttl=dafny_input.cacheTTL,
239+
cache=(
240+
(
241+
aws_cryptographic_material_providers.smithygenerated.aws_cryptography_materialproviders.dafny_to_smithy.aws_cryptography_materialproviders_CacheType(
242+
dafny_input.cache.value
243+
)
244+
)
245+
if (dafny_input.cache.is_Some)
246+
else None
247+
),
248+
partition_id=(
249+
(
250+
b"".join(
251+
ord(c).to_bytes(2, "big") for c in dafny_input.partitionId.value
252+
).decode("utf-16-be")
253+
)
254+
if (dafny_input.partitionId.is_Some)
255+
else None
256+
),
230257
)
231258

232259

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/smithygenerated/aws_cryptography_dbencryptionsdk_dynamodb/deserialize.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
CollectionOfErrors,
2121
ComAmazonawsDynamodb,
2222
DynamoDbEncryptionException,
23+
KeyStore,
2324
OpaqueError,
2425
ServiceError,
2526
StructuredEncryption,
2627
)
28+
from aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.deserialize import (
29+
_deserialize_error as aws_cryptography_keystore_deserialize_error,
30+
)
2731
from aws_cryptographic_material_providers.smithygenerated.aws_cryptography_materialproviders.deserialize import (
2832
_deserialize_error as aws_cryptography_materialproviders_deserialize_error,
2933
)
@@ -92,6 +96,10 @@ def _deserialize_error(error: Error) -> ServiceError:
9296
error.AwsCryptographyMaterialProviders
9397
)
9498
)
99+
elif error.is_AwsCryptographyKeyStore:
100+
return KeyStore(
101+
aws_cryptography_keystore_deserialize_error(error.AwsCryptographyKeyStore)
102+
)
95103
elif error.is_ComAmazonawsDynamodb:
96104
return ComAmazonawsDynamodb(
97105
message=_dafny.string_of(error.ComAmazonawsDynamodb.message)

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/smithygenerated/aws_cryptography_dbencryptionsdk_dynamodb/errors.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Do not modify this file. This file is machine generated, and any changes to it will be overwritten.
44

55
import _dafny
6+
from aws_cryptographic_material_providers.smithygenerated.aws_cryptography_keystore.errors import (
7+
_smithy_error_to_dafny_error as aws_cryptography_keystore_smithy_error_to_dafny_error,
8+
)
69
from aws_cryptographic_material_providers.smithygenerated.aws_cryptography_materialproviders.errors import (
710
_smithy_error_to_dafny_error as aws_cryptography_materialproviders_smithy_error_to_dafny_error,
811
)
@@ -113,6 +116,10 @@ class StructuredEncryption(ApiError[Literal["StructuredEncryption"]]):
113116
StructuredEncryption: Any
114117

115118

119+
class KeyStore(ApiError[Literal["KeyStore"]]):
120+
KeyStore: Any
121+
122+
116123
class CollectionOfErrors(ApiError[Literal["CollectionOfErrors"]]):
117124
code: Literal["CollectionOfErrors"] = "CollectionOfErrors"
118125
message: str
@@ -305,6 +312,11 @@ def _smithy_error_to_dafny_error(e: ServiceError):
305312
)
306313
)
307314

315+
if isinstance(e, KeyStore):
316+
return aws_dbesdk_dynamodb.internaldafny.generated.AwsCryptographyDbEncryptionSdkDynamoDbTypes.Error_AwsCryptographyKeyStore(
317+
aws_cryptography_keystore_smithy_error_to_dafny_error(e.message)
318+
)
319+
308320
if isinstance(e, CollectionOfErrors):
309321
return aws_dbesdk_dynamodb.internaldafny.generated.AwsCryptographyDbEncryptionSdkDynamoDbTypes.Error_CollectionOfErrors(
310322
message=_dafny.Seq(e.message),

0 commit comments

Comments
 (0)