How to use the iotedgedev.connectionstring.IoTHubConnectionString function in iotedgedev

To help you get started, we’ve selected a few iotedgedev examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / iotedgedev / tests / test_connectionstring.py View on Github external
def test_valid_iothub_connectionstring():
    connectionstring = IoTHubConnectionString(valid_iothub_connectionstring)
    assert connectionstring.iothub_host.name == "ChaoyiTestIoT.azure-devices.net"
    assert connectionstring.iothub_host.hub_name == "ChaoyiTestIoT"
    assert connectionstring.shared_access_key_name == "iothubowner"
    assert connectionstring.shared_access_key == "moregibberish"
    assert connectionstring.iothub_host.name_hash == "6b8fcfea09003d5f104771e83bd9ff54c592ec2277ec1815df91dd64d1633778"
github Azure / iotedgedev / tests / test_connectionstring.py View on Github external
def test_invalid_iothub_connectionstring():
    with pytest.raises(KeyError):
        IoTHubConnectionString(invalid_iothub_connectionstring)
github Azure / iotedgedev / tests / test_connectionstring.py View on Github external
def test_empty_iothub_connectionstring():
    connectionstring = IoTHubConnectionString(emptystring)
    assert not connectionstring.data
github Azure / iotedgedev / tests / test_iotedgedev.py View on Github external
def test_valid_env_iothub_connectionstring():
    """Test for loading data of env file"""

    env_iothub_connectionstring = os.getenv("IOTHUB_CONNECTION_STRING")
    connectionstring = IoTHubConnectionString(env_iothub_connectionstring)

    assert connectionstring.iothub_host.name
    assert connectionstring.iothub_host.hub_name
    assert connectionstring.shared_access_key
    assert connectionstring.shared_access_key_name
github Azure / iotedgedev / iotedgedev / iotedgedev.py View on Github external
def check(self):
        if not self.checked:
            self.load_dotenv()

            try:
                try:
                    self.IOTHUB_CONNECTION_STRING = self.get_envvar(
                        "IOTHUB_CONNECTION_STRING")
                    self.IOTHUB_CONNECTION_INFO = IoTHubConnectionString(
                        self.IOTHUB_CONNECTION_STRING)
                except:
                    self.output.error("ERROR: Unable to parse IOTHUB_CONNECTION_STRING Environment Variable. Please ensure that you have the right connection string set.")
                    sys.exit(-1)

                try:
                    self.DEVICE_CONNECTION_STRING = self.get_envvar(
                        "DEVICE_CONNECTION_STRING")
                    self.DEVICE_CONNECTION_INFO = DeviceConnectionString(
                        self.DEVICE_CONNECTION_STRING)
                except:
                    self.output.error("ERROR: Unable to parse DEVICE_CONNECTION_STRING Environment Variable. Please ensure that you have the right connection string set.")
                    sys.exit(-1)

                
                self.RUNTIME_HOST_NAME = self.get_envvar("RUNTIME_HOST_NAME")
github Azure / iotedgedev / iotedgedev / envvars.py View on Github external
def load(self, force=False):
        if not self.loaded or force:
            if self.verbose:
                self.output.header("ENVIRONMENT VARIABLES")

            self.load_dotenv()

            try:
                try:
                    self.IOTHUB_CONNECTION_STRING = self.get_envvar("IOTHUB_CONNECTION_STRING")
                    self.IOTHUB_CONNECTION_INFO = None
                    if self.IOTHUB_CONNECTION_STRING:
                        self.IOTHUB_CONNECTION_INFO = IoTHubConnectionString(self.IOTHUB_CONNECTION_STRING)

                except Exception as ex:
                    raise ValueError("Unable to parse IOTHUB_CONNECTION_STRING Environment Variable. Please ensure that you have the right connection string set. {0}".format(str(ex)))

                try:
                    self.DEVICE_CONNECTION_STRING = self.get_envvar("DEVICE_CONNECTION_STRING")
                    self.DEVICE_CONNECTION_INFO = None
                    if self.DEVICE_CONNECTION_STRING:
                        self.DEVICE_CONNECTION_INFO = DeviceConnectionString(self.DEVICE_CONNECTION_STRING)

                except Exception as ex:
                    raise ValueError("Unable to parse DEVICE_CONNECTION_STRING Environment Variable. Please ensure that you have the right connection string set. {0}".format(str(ex)))

                self.get_registries()

                self.BYPASS_MODULES = self.get_envvar("BYPASS_MODULES", default="")