Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_sha256_hash():
assert Utility.get_sha256_hash("foo") == "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"
def __init__(self, hostname):
self.name = hostname
if self.name and "." in self.name:
self.hub_name = self.name.split('.')[0]
# get connection string hostname hash to count distint IoT Hub number
self.name_hash = Utility.get_sha256_hash(self.name)
# get hostname suffix (e.g., azure-devices.net) to distinguish national clouds
self.name_suffix = self.name[self.name.index(".")+1:]
else:
self.hub_name = ""
self.name_hash = ""
self.name_suffix = ""
def _wrapped_func(*args, **kwargs):
val = func(*args, **kwargs)
if not val:
raise ValueError('Return value is None')
elif not isinstance(val, six.string_types):
raise ValueError('Return value is not string')
from .utility import Utility
return Utility.get_sha256_hash(val)