Convert fixtures/exceptions to Pytest
This commit is contained in:
parent
6d364dc7aa
commit
cb6731f340
16 changed files with 119 additions and 170 deletions
|
|
@ -2,7 +2,6 @@ from __future__ import unicode_literals
|
|||
|
||||
import sure # noqa
|
||||
import pytest
|
||||
from parameterized import parameterized
|
||||
|
||||
from moto.kms.exceptions import (
|
||||
AccessDeniedException,
|
||||
|
|
@ -22,7 +21,7 @@ from moto.kms.utils import (
|
|||
Ciphertext,
|
||||
)
|
||||
|
||||
ENCRYPTION_CONTEXT_VECTORS = (
|
||||
ENCRYPTION_CONTEXT_VECTORS = [
|
||||
(
|
||||
{"this": "is", "an": "encryption", "context": "example"},
|
||||
b"an" b"encryption" b"context" b"example" b"this" b"is",
|
||||
|
|
@ -31,8 +30,8 @@ ENCRYPTION_CONTEXT_VECTORS = (
|
|||
{"a_this": "one", "b_is": "actually", "c_in": "order"},
|
||||
b"a_this" b"one" b"b_is" b"actually" b"c_in" b"order",
|
||||
),
|
||||
)
|
||||
CIPHERTEXT_BLOB_VECTORS = (
|
||||
]
|
||||
CIPHERTEXT_BLOB_VECTORS = [
|
||||
(
|
||||
Ciphertext(
|
||||
key_id="d25652e4-d2d2-49f7-929a-671ccda580c6",
|
||||
|
|
@ -57,7 +56,7 @@ CIPHERTEXT_BLOB_VECTORS = (
|
|||
b"1234567890123456"
|
||||
b"some ciphertext that is much longer now",
|
||||
),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def test_generate_data_key():
|
||||
|
|
@ -74,32 +73,32 @@ def test_generate_master_key():
|
|||
len(test).should.equal(MASTER_KEY_LEN)
|
||||
|
||||
|
||||
@parameterized(ENCRYPTION_CONTEXT_VECTORS)
|
||||
@pytest.mark.parametrize("raw,serialized", ENCRYPTION_CONTEXT_VECTORS)
|
||||
def test_serialize_encryption_context(raw, serialized):
|
||||
test = _serialize_encryption_context(raw)
|
||||
test.should.equal(serialized)
|
||||
|
||||
|
||||
@parameterized(CIPHERTEXT_BLOB_VECTORS)
|
||||
@pytest.mark.parametrize("raw,_serialized", CIPHERTEXT_BLOB_VECTORS)
|
||||
def test_cycle_ciphertext_blob(raw, _serialized):
|
||||
test_serialized = _serialize_ciphertext_blob(raw)
|
||||
test_deserialized = _deserialize_ciphertext_blob(test_serialized)
|
||||
test_deserialized.should.equal(raw)
|
||||
|
||||
|
||||
@parameterized(CIPHERTEXT_BLOB_VECTORS)
|
||||
@pytest.mark.parametrize("raw,serialized", CIPHERTEXT_BLOB_VECTORS)
|
||||
def test_serialize_ciphertext_blob(raw, serialized):
|
||||
test = _serialize_ciphertext_blob(raw)
|
||||
test.should.equal(serialized)
|
||||
|
||||
|
||||
@parameterized(CIPHERTEXT_BLOB_VECTORS)
|
||||
@pytest.mark.parametrize("raw,serialized", CIPHERTEXT_BLOB_VECTORS)
|
||||
def test_deserialize_ciphertext_blob(raw, serialized):
|
||||
test = _deserialize_ciphertext_blob(serialized)
|
||||
test.should.equal(raw)
|
||||
|
||||
|
||||
@parameterized(((ec[0],) for ec in ENCRYPTION_CONTEXT_VECTORS))
|
||||
@pytest.mark.parametrize("encryption_context", [ec[0] for ec in ENCRYPTION_CONTEXT_VECTORS])
|
||||
def test_encrypt_decrypt_cycle(encryption_context):
|
||||
plaintext = b"some secret plaintext"
|
||||
master_key = Key("nop", "nop", "nop", "nop", "nop")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue