Exemple #1
0
def test_raises_when_auth_provider_created_from_numeric_connection_string():
    with pytest.raises(
            ValueError,
            match=
            "Connection string is required and should not be empty or blank and must be supplied as a string",
    ):
        SymmetricKeyAuthenticationProvider.parse(654354)
Exemple #2
0
def test_raises_when_auth_provider_created_from_connection_string_with_duplicatekeys(
):
    with pytest.raises(ValueError,
                       match="Invalid Connection String - Unable to parse"):
        connection_string = (
            "HostName=beauxbatons.academy-net;HostName=TheDeluminator;HostName=Zm9vYmFy"
        )
        SymmetricKeyAuthenticationProvider.parse(connection_string)
Exemple #3
0
def test_raises_when_auth_provider_created_from_connection_string_without_proper_delimeter(
):
    with pytest.raises(
            ValueError,
            match=
            "Connection string is required and should not be empty or blank and must be supplied as a string",
    ):
        connection_string = "HostName+beauxbatons.academy-net!DeviceId+TheDeluminator!"
        SymmetricKeyAuthenticationProvider.parse(connection_string)
Exemple #4
0
def test_raises_when_auth_provider_created_connection_string_with_numeric_argument(
):
    with pytest.raises(
            ValueError,
            match=
            "Connection string is required and should not be empty or blank and must be supplied as a string",
    ):
        connection_string = "HostName^43443434"
        SymmetricKeyAuthenticationProvider.parse(connection_string)
Exemple #5
0
def test_all_attributes_for_device():
    connection_string = connection_string_device_sk_format.format(
        hostname, device_id, shared_access_key)
    sym_key_auth_provider = SymmetricKeyAuthenticationProvider.parse(
        connection_string)
    assert sym_key_auth_provider.hostname == hostname
    assert sym_key_auth_provider.device_id == device_id
    assert hostname in sym_key_auth_provider.sas_token_str
    assert device_id in sym_key_auth_provider.sas_token_str
Exemple #6
0
def test_sastoken_keyname_device():
    connection_string = connection_string_device_skn_format.format(
        hostname, device_id, shared_access_key_name, shared_access_key)

    sym_key_auth_provider = SymmetricKeyAuthenticationProvider.parse(
        connection_string)

    assert hostname in sym_key_auth_provider.sas_token_str
    assert device_id in sym_key_auth_provider.sas_token_str
    assert shared_access_key_name in sym_key_auth_provider.sas_token_str
Exemple #7
0
def test_all_attributes_for_module():
    connection_string = connection_string_module_sk_format.format(
        hostname, device_id, module_id, shared_access_key)
    sym_key_auth_provider = SymmetricKeyAuthenticationProvider.parse(
        connection_string)
    try:
        assert sym_key_auth_provider.hostname == hostname
        assert sym_key_auth_provider.device_id == device_id
        assert sym_key_auth_provider.module_id == module_id
        assert hostname in sym_key_auth_provider.get_current_sas_token()
        assert device_id in sym_key_auth_provider.get_current_sas_token()
        assert module_id in sym_key_auth_provider.get_current_sas_token()
    finally:
        sym_key_auth_provider.disconnect()
Exemple #8
0
def test_raises_when_auth_provider_created_from_connection_string_with_bad_keys(
):
    with pytest.raises(ValueError,
                       match="Invalid Connection String - Invalid Key"):
        connection_string = "BadHostName=beauxbatons.academy-net;BadDeviceId=TheDeluminator;SharedAccessKey=Zm9vYmFy"
        SymmetricKeyAuthenticationProvider.parse(connection_string)
Exemple #9
0
def test_raises_when_auth_provider_created_from_incomplete_connection_string():
    with pytest.raises(ValueError,
                       match="Invalid Connection String - Incomplete"):
        connection_string = "HostName=beauxbatons.academy-net;SharedAccessKey=Zm9vYmFy"
        SymmetricKeyAuthenticationProvider.parse(connection_string)
Exemple #10
0
def test_raises_when_auth_provider_created_from_connection_string_without_proper_delimeter(
):
    with pytest.raises(ValueError):
        connection_string = "HostName+beauxbatons.academy-net!DeviceId+TheDeluminator!"
        SymmetricKeyAuthenticationProvider.parse(connection_string)