Skip to content

Commit

Permalink
chore: Add examples to source code (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
farleyb-amazon authored Jul 12, 2021
1 parent 87ed6a8 commit 2650f01
Show file tree
Hide file tree
Showing 49 changed files with 907 additions and 25 deletions.
1 change: 1 addition & 0 deletions api_compatibility_tests/compatibility-requirements/3.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aws-encryption-sdk-cli==3.1.0
1 change: 1 addition & 0 deletions api_compatibility_tests/compatibility-requirements/4.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aws-encryption-sdk-cli==4.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def is_windows():
{
"==1.7.0|~=1.8": SUCCESS,
"==2.0.0 ": 'error: Discovery must be set to True or False',
"~=2.1|~=3.0 ": 'error: the following arguments are required: -w/--wrapping-keys'
"~=2.1|>=3.0 ": 'error: the following arguments are required: -w/--wrapping-keys'
}
),
(
Expand All @@ -93,31 +93,31 @@ def is_windows():
"==1.7.0": SHOULD_HAVE_BEEN_AN_ERROR,
"~=1.8 ": 'error: Commitment policy is only supported when using the --wrapping-keys parameter',
"==2.0.0": 'error: Discovery must be set to True or False',
"~=2.1|~=3.0": 'error: the following arguments are required: -w/--wrapping-keys'
"~=2.1|>=3.0": 'error: the following arguments are required: -w/--wrapping-keys'
}
),
(
"--commitment-policy forbid-encrypt-allow-decrypt --discovery true",
{
"==1.7.0|==2.0.0": SHOULD_HAVE_BEEN_AN_ERROR,
"~=1.8 ": 'unrecognized arguments: --discovery',
"~=2.1|~=3.0 ": 'error: the following arguments are required: -w/--wrapping-keys'
"~=2.1|>=3.0 ": 'error: the following arguments are required: -w/--wrapping-keys'
}
),
# discovery-related parameters accidentally implemented in 1.7 and 2.0, removed in 1.8 and 2.1
(
"--commitment-policy forbid-encrypt-allow-decrypt --discovery true --wrapping-keys discovery=true",
{
"==1.7.0|==2.0.0": SHOULD_HAVE_BEEN_AN_ERROR,
"~=1.8|~=2.1|~=3.0": "unrecognized arguments: --discovery"
"~=1.8|~=2.1|>=3.0": "unrecognized arguments: --discovery"
}
),
# discovery filter was also configured through top level parameters and hit an internal error when used :(
(
"--commitment-policy forbid-encrypt-allow-decrypt --discovery true --discovery-partition aws --discovery-account 111222333444 --wrapping-keys discovery=true",
{
"==1.7.0|==2.0.0": "TypeError(\"'discovery_filter' must be <class",
"~=1.8|~=2.1|~=3.0": "unrecognized arguments: --discovery"
"~=1.8|~=2.1|>=3.0": "unrecognized arguments: --discovery"
}
),
# Disabling discovery on wrapping keys was accepted but non-functional in 1.7 and 2.0, fixed in 1.8 and 2.1
Expand All @@ -126,14 +126,14 @@ def is_windows():
{
"==1.7.0 ": 'error: Exact wrapping keys cannot be specified for aws-kms wrapping key provider on decrypt in discovery mode',
"==2.0.0 ": 'error: Discovery must be set to True or False',
"~=1.8|~=2.1|~=3.0": 'DecryptKeyError("Unable to decrypt any data key")'
"~=1.8|~=2.1|>=3.0": 'DecryptKeyError("Unable to decrypt any data key")'
}
),
(
"--commitment-policy forbid-encrypt-allow-decrypt --discovery false --wrapping-keys key=" + OTHER_CMK_ARN_VALUE,
{
"==1.7.0|==2.0.0": SHOULD_HAVE_BEEN_AN_ERROR,
"~=1.8 |~=2.1|~=3.0": 'unrecognized arguments: --discovery'
"~=1.8 |~=2.1|>=3.0": 'unrecognized arguments: --discovery'
}
),
# --commitment-policy should have been required in 1.7 when using --wrapping-keys, fixed in 1.8
Expand All @@ -143,7 +143,7 @@ def is_windows():
"==1.7.0": SHOULD_HAVE_BEEN_AN_ERROR,
"~=1.8 ": 'error: Commitment policy is required when specifying the --wrapping-keys parameter',
"==2.0.0": 'error: Discovery must be set to True or False',
"~=2.1|~=3.0": 'Cannot decrypt due to CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT requiring only committed messages'
"~=2.1|>=3.0": 'Cannot decrypt due to CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT requiring only committed messages'
}
),
]
Expand Down
4 changes: 3 additions & 1 deletion api_compatibility_tests/tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py38-awses_cli_{1.7.0,1.8.0,1.9.0,2.0.0,2.1.0,2.2.0,3.0.0}
py38-awses_cli_{1.7.0,1.8.0,1.9.0,2.0.0,2.1.0,2.2.0,3.0.0,3.1.0,4.0.0}

[testenv:base-command]
commands = pytest --basetemp={envtmpdir} -l test/ {posargs}
Expand Down Expand Up @@ -32,6 +32,8 @@ deps =
awses_cli_2.1.0: -rcompatibility-requirements/2.1.0
awses_cli_2.2.0: -rcompatibility-requirements/2.2.0
awses_cli_3.0.0: -rcompatibility-requirements/3.0.0
awses_cli_3.1.0: -rcompatibility-requirements/3.1.0
awses_cli_4.0.0: -rcompatibility-requirements/4.0.0
awses_cli_local: -e {env:AWSES_CLI_LOCAL_PATH}
commands =
{[testenv:base-command]commands}
39 changes: 29 additions & 10 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,35 @@ version: 0.2
batch:
fast-fail: false
build-list:
- identifier: python_27
buildspec: codebuild/python_27.yml
- identifier: python_35
buildspec: codebuild/python_35.yml
- identifier: python_36
buildspec: codebuild/python_36.yml
- identifier: python_37
buildspec: codebuild/python_37.yml
- identifier: python_38
buildspec: codebuild/python_38.yml
- identifier: py27_integ
buildspec: codebuild/py27/integ.yml
- identifier: py27_examples
buildspec: codebuild/py27/examples.yml

- identifier: py35_integ
buildspec: codebuild/py35/integ.yml
- identifier: py35_examples
buildspec: codebuild/py35/examples.yml

- identifier: py36_integ
buildspec: codebuild/py36/integ.yml
- identifier: py36_examples
buildspec: codebuild/py36/examples.yml

- identifier: py37_integ
buildspec: codebuild/py37/integ.yml
- identifier: py37_examples
buildspec: codebuild/py37/examples.yml

- identifier: py38_integ
buildspec: codebuild/py38/integ.yml
- identifier: py38_examples
buildspec: codebuild/py38/examples.yml

- identifier: py39_integ
buildspec: codebuild/py39/integ.yml
- identifier: py39_examples
buildspec: codebuild/py39/examples.yml

- identifier: code_coverage
buildspec: codebuild/coverage.yml
20 changes: 20 additions & 0 deletions codebuild/py27/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.2

env:
variables:
TOXENV: "py27-examples"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
phases:
install:
runtime-versions:
python: latest
build:
commands:
- pip install tox
- tox
File renamed without changes.
34 changes: 34 additions & 0 deletions codebuild/py35/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 0.2

env:
variables:
TOXENV: "py35-examples"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
phases:
install:
runtime-versions:
python: latest
build:
commands:
# The specific versions are manually installed
# because they are not installed
# by default in CodeBuild containers.
# `pyenv` does not have
# a nice way to just install
# the latest patch version.
# I have selected the current latest patch
# rather than try
# and manage a one-liner or script.
# Testing every minor version
# is too extreme at this time.
# The choice of versions should be reviewed.
- pyenv install 3.5.9
- pyenv local 3.5.9
- pip install tox tox-pyenv
- tox
File renamed without changes.
20 changes: 20 additions & 0 deletions codebuild/py36/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.2

env:
variables:
TOXENV: "py36-examples"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
phases:
install:
runtime-versions:
python: latest
build:
commands:
- pip install tox
- tox
File renamed without changes.
34 changes: 34 additions & 0 deletions codebuild/py37/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 0.2

env:
variables:
TOXENV: "py37-examples"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
phases:
install:
runtime-versions:
python: latest
build:
commands:
# The specific versions are manually installed
# because they are not installed
# by default in CodeBuild containers.
# `pyenv` does not have
# a nice way to just install
# the latest patch version.
# I have selected the current latest patch
# rather than try
# and manage a one-liner or script.
# Testing every minor version
# is too extreme at this time.
# The choice of versions should be reviewed.
- pyenv install 3.7.9
- pyenv local 3.7.9
- pip install tox tox-pyenv
- tox
File renamed without changes.
20 changes: 20 additions & 0 deletions codebuild/py38/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.2

env:
variables:
TOXENV: "py38-examples"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
phases:
install:
runtime-versions:
python: latest
build:
commands:
- pip install tox
- tox
File renamed without changes.
22 changes: 22 additions & 0 deletions codebuild/py39/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 0.2

env:
variables:
TOXENV: "py39-examples"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
phases:
install:
runtime-versions:
python: latest
build:
commands:
- pyenv install 3.9.0
- pyenv local 3.9.0
- pip install tox tox-pyenv
- tox
20 changes: 20 additions & 0 deletions codebuild/py39/integ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.2

env:
variables:
TOXENV: "py39-integ"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
phases:
install:
runtime-versions:
python: latest
build:
commands:
- pyenv install 3.9.0
- pyenv local 3.9.0
- pip install tox tox-pyenv
- tox
11 changes: 9 additions & 2 deletions codebuild/release/prod-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ batch:
fast-fail: true
build-graph:
- identifier: release_to_prod
- identifier: validate_prod_release
- identifier: validate_prod_release_api_compatibility
depend-on:
- release_to_prod
buildspec: codebuild/release/validate.yml
buildspec: codebuild/release/validate-api-compatibility.yml
env:
variables:
PIP_INDEX_URL: https://pypi.python.org/simple/
- identifier: validate_prod_release_examples
depend-on:
- release_to_prod
buildspec: codebuild/release/validate-examples.yml
env:
variables:
PIP_INDEX_URL: https://pypi.python.org/simple/
12 changes: 10 additions & 2 deletions codebuild/release/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,18 @@ batch:
fast-fail: true
build-graph:
- identifier: release_to_staging
- identifier: validate_staging_release
- identifier: validate_staging_release_api_compatibility
depend-on:
- release_to_staging
buildspec: codebuild/release/validate.yml
buildspec: codebuild/release/validate-api-compatibility.yml
env:
variables:
PIP_INDEX_URL: https://test.pypi.org/simple/
PIP_EXTRA_INDEX_URL: https://pypi.python.org/simple/
- identifier: validate_staging_release_examples
depend-on:
- release_to_staging
buildspec: codebuild/release/validate-examples.yml
env:
variables:
PIP_INDEX_URL: https://test.pypi.org/simple/
Expand Down
File renamed without changes.
38 changes: 38 additions & 0 deletions codebuild/release/validate-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: 0.2

env:
variables:
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
phases:
install:
commands:
- pip install tox
runtime-versions:
python: latest
pre_build:
commands:
- cd examples
- sed -i "s/aws-encryption-sdk-cli/aws-encryption-sdk-cli==$VERSION/" test/requirements.txt
build:
commands:
- NUM_RETRIES=3
- |
while [ $NUM_RETRIES -gt 0 ]
do
tox -e py38-examples
if [ $? -eq 0 ]; then
break
fi
NUM_RETRIES=$((NUM_RETRIES-1))
if [ $NUM_RETRIES -eq 0 ]; then
echo "All validation attempts failed, stopping"
exit 1;
else
echo "Validation failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60
fi
done
Loading

0 comments on commit 2650f01

Please sign in to comment.