Ejemplo n.º 1
0
    def test_reordered_cs_args(self):
        cs = "SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu;HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner"
        psc = ProvisioningServiceClient.create_from_connection_string(cs)

        self.assertEqual(psc.host_name, "test-uri.azure-devices-provisioning.net")
        self.assertEqual(psc.shared_access_key_name, "provisioningserviceowner")
        self.assertEqual(psc.shared_access_key, "dGVzdGluZyBhIHNhc3Rva2Vu")
    def test_reordered_cs_args(self):
        cs = "SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu;HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner"
        psc = ProvisioningServiceClient.create_from_connection_string(cs)

        self.assertEqual(psc.host_name,
                         "test-uri.azure-devices-provisioning.net")
        self.assertEqual(psc.shared_access_key_name,
                         "provisioningserviceowner")
        self.assertEqual(psc.shared_access_key, "dGVzdGluZyBhIHNhc3Rva2Vu")
    def test_create_w_params(self):
        psc = ProvisioningServiceClient("test-uri.azure-devices-provisioning.net", \
            "provisioningserviceowner", "dGVzdGluZyBhIHNhc3Rva2Vu")

        self.assertEqual(psc.host_name,
                         "test-uri.azure-devices-provisioning.net")
        self.assertEqual(psc.shared_access_key_name,
                         "provisioningserviceowner")
        self.assertEqual(psc.shared_access_key, "dGVzdGluZyBhIHNhc3Rva2Vu")
    def test_basic_cs(self):
        cs = "HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
        psc = ProvisioningServiceClient.create_from_connection_string(cs)

        self.assertEqual(psc.host_name,
                         "test-uri.azure-devices-provisioning.net")
        self.assertEqual(psc.shared_access_key_name,
                         "provisioningserviceowner")
        self.assertEqual(psc.shared_access_key, "dGVzdGluZyBhIHNhc3Rva2Vu")
        self.assertIsInstance(psc._runtime_client,
                              GeneratedProvisioningServiceClient)
 def test_fail_missing_cs_args(self):
     #HostName is missing
     cs = "SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
 def test_fail_too_many_cs_args(self):
     #ExtraVal additional cs val
     cs = "ExtraVal=testingValue;HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
 def setUpClass(cls):
     cs = "HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     cls.psc = ProvisioningServiceClient.create_from_connection_string(cs)
 def test_fail_invalid_cs(self):
     cs = "not_a_connection_string"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
 def test_fail_duplicate_cs_args(self):
     #SharedAccessKeyName defined twice
     cs = "SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu;SharedAccessKeyName=duplicatevalue"
     with self.assertRaises(UnboundLocalError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
 def test_fail_replaced_cs_args(self):
     #ExtraVal replaces HostName in cs
     cs = "ExtraVal=testingValue;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
Ejemplo n.º 11
0
 def test_fail_replaced_cs_args(self):
     #ExtraVal replaces HostName in cs
     cs = "ExtraVal=testingValue;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
Ejemplo n.º 12
0
 def test_fail_missing_cs_args(self):
     #HostName is missing
     cs = "SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
Ejemplo n.º 13
0
 def test_fail_too_many_cs_args(self):
     #ExtraVal additional cs val
     cs = "ExtraVal=testingValue;HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
Ejemplo n.º 14
0
 def setUpClass(cls):
     cs = "HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     cls.psc = ProvisioningServiceClient.create_from_connection_string(cs)
Ejemplo n.º 15
0
 def test_fail_invalid_cs(self):
     cs = "not_a_connection_string"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
Ejemplo n.º 16
0
 def test_fail_duplicate_cs_args(self):
     #SharedAccessKeyName defined twice
     cs = "SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu;SharedAccessKeyName=duplicatevalue"
     with self.assertRaises(UnboundLocalError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)