def test_sk_auth_provider_created_correctly_from_device_connection_string():
    connection_string = connection_string_device_sk_format.format(
        hostname, device_id, shared_access_key)
    auth_provider = from_connection_string(connection_string)
    assert isinstance(auth_provider, SymmetricKeyAuthenticationProvider)
    assert auth_provider.device_id == device_id
    assert auth_provider.hostname == hostname
def module_transport():
    connection_string_mod = connection_string_format_mod.format(
        fake_hostname, fake_device_id, fake_module_id, fake_shared_access_key)
    authentication_provider = from_connection_string(connection_string_mod)

    with patch(
            "azure.iot.device.iothub.transport.mqtt.mqtt_transport.pipeline_stages_mqtt.MQTTProvider"
    ):
        transport = MQTTTransport(authentication_provider)
    transport.on_transport_connected = MagicMock()
    transport.on_transport_disconnected = MagicMock()
    yield transport
    transport.disconnect()
def auth_provider(request):
    from azure.iot.device.iothub.auth.authentication_provider_factory import (
        from_connection_string,
        from_shared_access_signature,
    )

    auth_type = request.param
    if auth_type == "SymmetricKey":
        return from_connection_string(
            connection_string_format.format(hostname, device_id, shared_access_key)
        )
    elif auth_type == "SharedAccessSignature":
        uri = hostname + "/devices/" + device_id
        return from_shared_access_signature(sastoken_format.format(uri, signature, expiry))
def authentication_provider():
    connection_string = connection_string_format.format(
        fake_hostname, fake_device_id, fake_shared_access_key)
    auth_provider = from_connection_string(connection_string)
    return auth_provider