-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathtest_meta.py
69 lines (51 loc) · 2.41 KB
/
test_meta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Functional tests for ``dynamodb_encryption_sdk.material_providers.store.meta``."""
import base64
import os
import boto3
import pytest
from moto import mock_dynamodb2
from dynamodb_encryption_sdk.exceptions import NoKnownVersionError
from dynamodb_encryption_sdk.material_providers.store.meta import MetaStore, MetaStoreAttributeNames
from dynamodb_encryption_sdk.material_providers.wrapped import WrappedCryptographicMaterialsProvider
from ...functional_test_utils import build_static_jce_cmp, mock_metastore
pytestmark = [pytest.mark.functional, pytest.mark.local]
def test_create_table(mock_metastore):
# type: (MetaStore) -> None
assert mock_metastore._table.key_schema == [
{"AttributeName": MetaStoreAttributeNames.PARTITION.value, "KeyType": "HASH"},
{"AttributeName": MetaStoreAttributeNames.SORT.value, "KeyType": "RANGE"},
]
assert mock_metastore._table.attribute_definitions == [
{"AttributeName": MetaStoreAttributeNames.PARTITION.value, "AttributeType": "S"},
{"AttributeName": MetaStoreAttributeNames.SORT.value, "AttributeType": "N"},
]
def test_max_version_empty(mock_metastore):
# type: (MetaStore) -> None
with pytest.raises(NoKnownVersionError) as excinfo:
mock_metastore.max_version("example_name")
excinfo.match(r"No known version for name: ")
def test_max_version_exists(mock_metastore):
# type: (MetaStore) -> None
mock_metastore.get_or_create_provider("example_name", 2)
mock_metastore.get_or_create_provider("example_name", 5)
test = mock_metastore.max_version("example_name")
assert test == 5
@pytest.mark.xfail(strict=True)
def test_version_from_material_description():
assert False
def test_provider(mock_metastore):
# type: (MetaStore) -> None
test = mock_metastore.provider("example_name")
assert isinstance(test, WrappedCryptographicMaterialsProvider)