def test_loaded_key_infos():
    cmp = _kms_cmp(material_description={})

    assert cmp._content_key_info == KeyInfo.from_description(
        _DEFAULT_CONTENT_ENCRYPTION_ALGORITHM)
    assert cmp._signing_key_info == KeyInfo.from_description(
        _DEFAULT_SIGNING_ALGORITHM)
    assert cmp._regional_clients == {}
def test_key_info_from_material_description(
    material_description, description_key, default_algorithm, default_key_length, expected_kwargs
):
    expected_keyinfo = KeyInfo(**expected_kwargs)
    actual_keyinfo = KeyInfo.from_material_description(
        material_description, description_key, default_algorithm, default_key_length
    )

    assert actual_keyinfo == expected_keyinfo
def test_derive_encryption_key(default_kms_cmp, description, method_name,
                               key_name):
    key_info = KeyInfo.from_description(description)

    test = getattr(default_kms_cmp, method_name)(
        initial_material=_DERIVED_KEYS["initial_material"], key_info=key_info)

    assert test.key == _DERIVED_KEYS[key_name]
def test_key_info_from_description_fails():
    with pytest.raises(ValueError):
        KeyInfo.from_description(description="AES")
def test_key_info_attrs_fail(invalid_kwargs):
    with pytest.raises(TypeError):
        kwargs = _VALID_KEY_INFO_KWARGS.copy()
        kwargs.update(invalid_kwargs)
        KeyInfo(**kwargs)