Skip to content

Commit ff499ad

Browse files
authored
Merge pull request #82 from mattsb42-aws/vectors
Cleanup test vector handlers module and prepare for release
2 parents db217dd + 4a04d4f commit ff499ad

31 files changed

+206
-13
lines changed

.travis.yml

+112-1
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,116 @@ matrix:
9494
env: TOXENV=black-check
9595
- python: 3.6
9696
env: TOXENV=isort-check
97+
########################
98+
# Test Vector Handlers #
99+
########################
100+
# CPython 2.7
101+
- python: 2.7
102+
env:
103+
TEST_VECTOR_HANDLERS=1
104+
TOXENV=py27-awses_1.3.0
105+
- python: 2.7
106+
env:
107+
TEST_VECTOR_HANDLERS=1
108+
TOXENV=py27-awses_1.3.max
109+
- python: 2.7
110+
env:
111+
TEST_VECTOR_HANDLERS=1
112+
TOXENV=py27-awses_latest
113+
# CPython 3.4
114+
- python: 3.4
115+
env:
116+
TEST_VECTOR_HANDLERS=1
117+
TOXENV=py34-awses_1.3.0
118+
- python: 3.4
119+
env:
120+
TEST_VECTOR_HANDLERS=1
121+
TOXENV=py34-awses_1.3.max
122+
- python: 3.4
123+
env:
124+
TEST_VECTOR_HANDLERS=1
125+
TOXENV=py34-awses_latest
126+
# CPython 3.5
127+
- python: 3.5
128+
env:
129+
TEST_VECTOR_HANDLERS=1
130+
TOXENV=py35-awses_1.3.0
131+
- python: 3.5
132+
env:
133+
TEST_VECTOR_HANDLERS=1
134+
TOXENV=py35-awses_1.3.max
135+
- python: 3.5
136+
env:
137+
TEST_VECTOR_HANDLERS=1
138+
TOXENV=py35-awses_latest
139+
# CPython 3.6
140+
- python: 3.6
141+
env:
142+
TEST_VECTOR_HANDLERS=1
143+
TOXENV=py36-awses_1.3.0
144+
- python: 3.6
145+
env:
146+
TEST_VECTOR_HANDLERS=1
147+
TOXENV=py36-awses_1.3.max
148+
- python: 3.6
149+
env:
150+
TEST_VECTOR_HANDLERS=1
151+
TOXENV=py36-awses_latest
152+
# CPython 3.7
153+
- python: 3.7
154+
env:
155+
TEST_VECTOR_HANDLERS=1
156+
TOXENV=py37-awses_1.3.0
157+
dist: xenial
158+
sudo: true
159+
- python: 3.7
160+
env:
161+
TEST_VECTOR_HANDLERS=1
162+
TOXENV=py37-awses_1.3.max
163+
dist: xenial
164+
sudo: true
165+
- python: 3.7
166+
env:
167+
TEST_VECTOR_HANDLERS=1
168+
TOXENV=py37-awses_latest
169+
dist: xenial
170+
sudo: true
171+
# Linters
172+
- python: 3.6
173+
env:
174+
TEST_VECTOR_HANDLERS=1
175+
TOXENV=bandit
176+
- python: 3.6
177+
env:
178+
TEST_VECTOR_HANDLERS=1
179+
TOXENV=readme
180+
# Pending buildout of docs
181+
#- python: 3.6
182+
# env:
183+
# TEST_VECTOR_HANDLERS=1
184+
# TOXENV=docs
185+
#- python: 3.6
186+
# env:
187+
# TEST_VECTOR_HANDLERS=1
188+
# TOXENV=doc8
189+
# Pending linting cleanup
190+
#- python: 3.6
191+
# env:
192+
# TEST_VECTOR_HANDLERS=1
193+
# TOXENV=flake8
194+
#- python: 3.6
195+
# env:
196+
# TEST_VECTOR_HANDLERS=1
197+
# TOXENV=pylint
198+
#- python: 3.6
199+
# env:
200+
# TEST_VECTOR_HANDLERS=1
201+
# TOXENV=flake8-tests
202+
#- python: 3.6
203+
# env:
204+
# TEST_VECTOR_HANDLERS=1
205+
# TOXENV=pylint-tests
97206
install: pip install tox
98-
script: tox
207+
script:
208+
- if [[ -n $TEST_VECTOR_HANDLERS ]]; then cd test_vector_handlers; fi
209+
- tox

test_vector_generator/README.rst

Whitespace-only changes.
File renamed without changes.

test_vector_handlers/README.rst

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#######################################
2+
aws-encryption-sdk test vector handlers
3+
#######################################
4+
5+
There modules provide handlers to be used to process existing, or generate new,
6+
test vectors based on test vector manifests.
7+
8+
***************
9+
Getting Started
10+
***************
11+
12+
Required Prerequisites
13+
======================
14+
15+
* Python 2.7 or 3.4+
16+
* aws-encryption-sdk
17+
18+
Use
19+
===
20+
21+
In addition to direct use of the library, some CLI tools are provided to simplify
22+
processing of common test manifest types.
23+
24+
Full Message Encrypt
25+
--------------------
26+
27+
Used to process an AWS Encryption SDK Full Message Encrypt manifest and produce
28+
a Full Message Decrypt manifest along with all corresponding plaintexts and ciphertexts.
29+
30+
.. code::
31+
32+
usage: awses-full-message-encrypt [-h] --output OUTPUT --input INPUT [--human]
33+
34+
Build ciphertexts and decrypt manifest from keys and encrypt manifests
35+
36+
optional arguments:
37+
-h, --help show this help message and exit
38+
--output OUTPUT Directory in which to store results
39+
--input INPUT Existing full message encrypt manifest
40+
--human Output human-readable JSON
41+
42+
43+
Full Message Decrypt
44+
--------------------
45+
46+
Used to process an AWS Encryption SDK Full Message Decrypt manifest to
47+
decrypt and verify all referenced ciphertexts.
48+
49+
.. code::
50+
51+
usage: awses-full-message-decrypt [-h] --input INPUT
52+
53+
Decrypt ciphertexts generated by awses-full-message-encrypt
54+
55+
optional arguments:
56+
-h, --help show this help message and exit
57+
--input INPUT Existing full message decrypt manifest
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
attrs >= 17.4.0
2+
aws-encryption-sdk
23
six
File renamed without changes.
File renamed without changes.

test_vector_generator/src/awses_test_vectors/__init__.py renamed to test_vector_handlers/src/awses_test_vectors/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
13-
__version__ = "0.0.0"
13+
__version__ = "1.0.0"

test_vector_generator/src/awses_test_vectors/commands/full_message_decrypt.py renamed to test_vector_handlers/src/awses_test_vectors/commands/full_message_decrypt.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def cli(args=None):
2828
# type: (Optional[Iterable[str]]) -> None
2929
"""CLI entry point for processing AWS Encryption SDK Decrypt Message manifests."""
3030
parser = argparse.ArgumentParser(description="Decrypt ciphertexts generated by awses-full-message-encrypt")
31-
parser.add_argument("--input", type=argparse.FileType("r"), help="Existing full message decrypt manifest")
31+
parser.add_argument(
32+
"--input", required=True, type=argparse.FileType("r"), help="Existing full message decrypt manifest"
33+
)
3234

3335
parsed = parser.parse_args(args)
3436

test_vector_generator/src/awses_test_vectors/commands/full_message_encrypt.py renamed to test_vector_handlers/src/awses_test_vectors/commands/full_message_encrypt.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ def cli(args=None):
3030
parser = argparse.ArgumentParser(
3131
description="Build ciphertexts and decrypt manifest from keys and encrypt manifests"
3232
)
33-
parser.add_argument("--output", help="Directory in which to store results")
34-
parser.add_argument("--input", type=argparse.FileType("r"), help="Existing full message encrypt manifest")
33+
parser.add_argument("--output", required=True, help="Directory in which to store results")
34+
parser.add_argument(
35+
"--input", required=True, type=argparse.FileType("r"), help="Existing full message encrypt manifest"
36+
)
3537
parser.add_argument(
3638
"--human",
3739
required=False,

test_vector_generator/src/awses_test_vectors/internal/aws_kms.py renamed to test_vector_handlers/src/awses_test_vectors/internal/aws_kms.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"""
1414
Helper utilities for interacting with AWS KMS.
1515
"""
16-
from aws_encryption_sdk.identifiers import AlgorithmSuite
16+
try:
17+
from aws_encryption_sdk.identifiers import AlgorithmSuite
18+
except ImportError:
19+
from aws_encryption_sdk.identifiers import Algorithm as AlgorithmSuite
1720
from aws_encryption_sdk.key_providers.kms import KMSMasterKeyProvider
1821

1922
from awses_test_vectors.internal.defaults import ENCODING

test_vector_generator/src/awses_test_vectors/internal/util.py renamed to test_vector_handlers/src/awses_test_vectors/internal/util.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919

2020
import six
2121
from attr import Attribute # noqa pylint: disable=unused-import
22-
from aws_encryption_sdk.identifiers import AlgorithmSuite
22+
23+
try:
24+
from aws_encryption_sdk.identifiers import AlgorithmSuite
25+
except ImportError:
26+
from aws_encryption_sdk.identifiers import Algorithm as AlgorithmSuite
2327

2428
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
2529
from typing import Any, Callable, Dict, Iterable, Type # noqa pylint: disable=unused-import

test_vector_generator/src/awses_test_vectors/manifests/full_message/encrypt.py renamed to test_vector_handlers/src/awses_test_vectors/manifests/full_message/encrypt.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import attr
2424
import aws_encryption_sdk
2525
import six
26-
from aws_encryption_sdk.identifiers import AlgorithmSuite
2726
from aws_encryption_sdk.key_providers.base import MasterKeyProvider
2827

2928
from awses_test_vectors.internal.defaults import ENCODING
@@ -40,6 +39,12 @@
4039
from awses_test_vectors.manifests.keys import KeysManifest
4140
from awses_test_vectors.manifests.master_key import MasterKeySpec, master_key_provider_from_master_key_specs
4241

42+
try:
43+
from aws_encryption_sdk.identifiers import AlgorithmSuite
44+
except ImportError:
45+
from aws_encryption_sdk.identifiers import Algorithm as AlgorithmSuite
46+
47+
4348
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
4449
from typing import Callable, Dict, IO, Iterable, Optional # noqa pylint: disable=unused-import
4550
from awses_test_vectors.internal.mypy_types import ( # noqa pylint: disable=unused-import

test_vector_generator/src/awses_test_vectors/manifests/master_key.py renamed to test_vector_handlers/src/awses_test_vectors/manifests/master_key.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import attr
1919
import six
2020
from aws_encryption_sdk.identifiers import EncryptionKeyType, WrappingAlgorithm
21-
from aws_encryption_sdk.internal.crypto.wrapping_keys import WrappingKey
2221
from aws_encryption_sdk.key_providers.base import MasterKeyProvider # noqa pylint: disable=unused-import
2322
from aws_encryption_sdk.key_providers.kms import KMSMasterKey # noqa pylint: disable=unused-import
2423
from aws_encryption_sdk.key_providers.raw import RawMasterKey
@@ -27,6 +26,12 @@
2726
from awses_test_vectors.internal.util import membership_validator
2827
from awses_test_vectors.manifests.keys import KeysManifest, KeySpec # noqa pylint: disable=unused-import
2928

29+
try:
30+
from aws_encryption_sdk.internal.crypto.wrapping_keys import WrappingKey
31+
except ImportError:
32+
from aws_encryption_sdk.internal.crypto import WrappingKey
33+
34+
3035
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
3136
from typing import Iterable # noqa pylint: disable=unused-import
3237
from awses_test_vectors.internal.mypy_types import MASTER_KEY_SPEC # noqa pylint: disable=unused-import

test_vector_generator/tox.ini renamed to test_vector_handlers/tox.ini

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tox]
22
envlist =
3-
py{27,34,35,36,37},
3+
py{27,34,35,36,37}-awses_{1.3.0,1.3.max,latest},
4+
# 1.2.0 and 1.2.max are being difficult because of attrs
45
bandit, doc8, readme, docs,
56
{flake8,pylint}{,-tests},
67
# prone to false positives
@@ -44,8 +45,10 @@ passenv =
4445
AWS_PROFILE
4546
sitepackages = False
4647
deps =
47-
aws-encryption-sdk
4848
-rtest/requirements.txt
49+
awses_1.3.0: aws-encryption-sdk==1.3.0
50+
awses_1.3.max: aws-encryption-sdk >= 1.3.0, < 1.4.0
51+
awses_latest: aws-encryption-sdk
4952
commands = {[testenv:base-command]commands}
5053

5154
[testenv:full-encrypt]
@@ -126,7 +129,7 @@ commands =
126129
[testenv:pylint]
127130
basepython = python3
128131
deps =
129-
{[testenv]deps}
132+
-rtest/requirements.txt
130133
pyflakes
131134
pylint
132135
commands =
@@ -219,7 +222,7 @@ commands = python setup.py check -r -s
219222
basepython = python3
220223
deps =
221224
# Pull bandit from github because they haven't published 1.4.1 to pypi yet
222-
git+git://github.com/openstack/bandit.git@master
225+
git+git://github.com/PyCQA/bandit.git@master
223226
commands = bandit -r src/awses_test_vectors/
224227

225228
# Prone to false positives: only run independently

0 commit comments

Comments
 (0)