コード例 #1
0
ファイル: client_ut.py プロジェクト: dqj/azure-iot-sdk-python
    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")
コード例 #2
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")
コード例 #3
0
    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")
コード例 #4
0
    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)
コード例 #5
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)
コード例 #6
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)
コード例 #7
0
 def setUpClass(cls):
     cs = "HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     cls.psc = ProvisioningServiceClient.create_from_connection_string(cs)
コード例 #8
0
 def test_fail_invalid_cs(self):
     cs = "not_a_connection_string"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
コード例 #9
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)
コード例 #10
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)
コード例 #11
0
ファイル: client_ut.py プロジェクト: dqj/azure-iot-sdk-python
 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)
コード例 #12
0
ファイル: client_ut.py プロジェクト: dqj/azure-iot-sdk-python
 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)
コード例 #13
0
ファイル: client_ut.py プロジェクト: dqj/azure-iot-sdk-python
 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)
コード例 #14
0
ファイル: client_ut.py プロジェクト: dqj/azure-iot-sdk-python
 def setUpClass(cls):
     cs = "HostName=test-uri.azure-devices-provisioning.net;SharedAccessKeyName=provisioningserviceowner;SharedAccessKey=dGVzdGluZyBhIHNhc3Rva2Vu"
     cls.psc = ProvisioningServiceClient.create_from_connection_string(cs)
コード例 #15
0
ファイル: client_ut.py プロジェクト: dqj/azure-iot-sdk-python
 def test_fail_invalid_cs(self):
     cs = "not_a_connection_string"
     with self.assertRaises(ValueError):
         psc = ProvisioningServiceClient.create_from_connection_string(cs)
コード例 #16
0
ファイル: client_ut.py プロジェクト: dqj/azure-iot-sdk-python
 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)