|
| 1 | +# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You |
| 4 | +# may not use this file except in compliance with the License. A copy of |
| 5 | +# the License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is |
| 10 | +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 11 | +# ANY KIND, either express or implied. See the License for the specific |
| 12 | +# language governing permissions and limitations under the License. |
| 13 | +""" |
| 14 | +Integration tests for `awses_test_vectors.commands` with keyrings. |
| 15 | +""" |
| 16 | +import pytest |
| 17 | + |
| 18 | +from awses_test_vectors.commands import full_message_decrypt, full_message_decrypt_generate, full_message_encrypt |
| 19 | + |
| 20 | +from ....integration.integration_test_utils import ( # noqa pylint: disable=unused-import |
| 21 | + full_message_decrypt_generation_vectors, |
| 22 | + full_message_encrypt_vectors, |
| 23 | +) |
| 24 | + |
| 25 | + |
| 26 | +pytestmark = [pytest.mark.integ] |
| 27 | + |
| 28 | + |
| 29 | +def test_full_message_encrypt_canonical_full(full_message_encrypt_vectors): |
| 30 | + full_message_encrypt.cli(["--input", full_message_encrypt_vectors, "--keyrings"]) |
| 31 | + |
| 32 | + |
| 33 | +def test_full_message_cycle_canonical_full(tmpdir, full_message_decrypt_generation_vectors): |
| 34 | + # Generate vectors using keyring interfaces |
| 35 | + keyring_output_dir = tmpdir.join("output-keyrings") |
| 36 | + full_message_decrypt_generate.cli([ |
| 37 | + "--output", |
| 38 | + str(keyring_output_dir), |
| 39 | + "--input", |
| 40 | + full_message_decrypt_generation_vectors, |
| 41 | + "--keyrings" |
| 42 | + ]) |
| 43 | + |
| 44 | + # Generate vectors using master key interfaces |
| 45 | + master_key_output_dir = tmpdir.join("output-master-key") |
| 46 | + full_message_decrypt_generate.cli([ |
| 47 | + "--output", |
| 48 | + str(master_key_output_dir), |
| 49 | + "--input", |
| 50 | + full_message_decrypt_generation_vectors |
| 51 | + ]) |
| 52 | + |
| 53 | + # Validate that vectors generated using keyring interfaces |
| 54 | + # can be decrypted by BOTH keyring and master key interfaces |
| 55 | + keyring_decrypt_manifest_file = keyring_output_dir.join("manifest.json") |
| 56 | + full_message_decrypt.cli(["--input", str(keyring_decrypt_manifest_file), "--keyrings"]) |
| 57 | + full_message_decrypt.cli(["--input", str(keyring_decrypt_manifest_file)]) |
| 58 | + |
| 59 | + # Validate that vectors generated using master key interfaces |
| 60 | + # can be decrypted by BOTH keyring and master key interfaces |
| 61 | + master_key_decrypt_manifest_file = keyring_output_dir.join("manifest.json") |
| 62 | + |
| 63 | + full_message_decrypt.cli(["--input", str(master_key_decrypt_manifest_file), "--keyrings"]) |
| 64 | + full_message_decrypt.cli(["--input", str(master_key_decrypt_manifest_file)]) |
0 commit comments