def test_load_master_key_provider_unknown_name(monkeypatch): master_key_parsing._entry_points() monkeypatch.setattr(master_key_parsing, "_ENTRY_POINTS", defaultdict(dict)) with pytest.raises(BadUserArgumentError) as excinfo: master_key_parsing._load_master_key_provider("unknown_name") excinfo.match(r'Requested master key provider not found: "unknown_name"')
def test_load_master_key_provider_known_name_unknown_name(monkeypatch): monkeypatch.setitem( master_key_parsing._ENTRY_POINTS, "aws-kms", {"my-fake-package": FakeEntryPoint(name="aws-kms", module_name="my-fake-package")}, ) with pytest.raises(BadUserArgumentError) as excinfo: master_key_parsing._load_master_key_provider("aws-encryption-sdk-cli::aws-kms") excinfo.match( r'Requested master key provider not found: "aws-encryption-sdk-cli::aws-kms". Packages discovered for *' )
def test_load_master_key_provider_known_name_only_multiple_entry_points(monkeypatch): monkeypatch.setitem( master_key_parsing._ENTRY_POINTS, "aws-kms", { "aws-encryption-sdk-cli": FakeEntryPoint( name="aws-kms", dist=MagicMock(project_name="aws-encryption-sdk-cli") ), "my-fake-package": FakeEntryPoint(name="aws-kms", module_name="my-fake-package"), }, ) with pytest.raises(BadUserArgumentError) as excinfo: master_key_parsing._load_master_key_provider("aws-kms") excinfo.match(r"Multiple entry points discovered and no package specified. *")
def test_load_master_key_provider_known_package_and_name(): assert (master_key_parsing._load_master_key_provider( "aws-encryption-sdk-cli::aws-kms") is aws_kms_master_key_provider)
def test_load_master_key_provider_known_name_only_single_entry_point(): assert master_key_parsing._load_master_key_provider( "aws-kms") is aws_kms_master_key_provider