本文整理汇总了Python中azure.servicemanagement.ServiceManagementService.list_management_certificates方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceManagementService.list_management_certificates方法的具体用法?Python ServiceManagementService.list_management_certificates怎么用?Python ServiceManagementService.list_management_certificates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.servicemanagement.ServiceManagementService
的用法示例。
在下文中一共展示了ServiceManagementService.list_management_certificates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ManagementCertificateManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import list_management_certificates [as 别名]
class ManagementCertificateManagementServiceTest(AzureTestCase):
def setUp(self):
proxy_host = credentials.getProxyHost()
proxy_port = credentials.getProxyPort()
self.sms = ServiceManagementService(credentials.getSubscriptionId(), credentials.getManagementCertFile())
if proxy_host:
self.sms.set_proxy(proxy_host, proxy_port)
self.management_certificate_name = getUniqueNameBasedOnCurrentTime('utmgmtcert')
def tearDown(self):
try:
self.sms.delete_management_certificate(self.management_certificate_name)
except: pass
#--Helpers-----------------------------------------------------------------
def _create_management_certificate(self, thumbprint):
result = self.sms.add_management_certificate(MANAGEMENT_CERT_PUBLICKEY, thumbprint, MANAGEMENT_CERT_DATA)
self.assertIsNone(result)
def _management_certificate_exists(self, thumbprint):
try:
props = self.sms.get_management_certificate(thumbprint)
return props is not None
except:
return False
#--Test cases for management certificates ----------------------------
def test_list_management_certificates(self):
# Arrange
self._create_management_certificate(self.management_certificate_name)
# Act
result = self.sms.list_management_certificates()
# Assert
self.assertIsNotNone(result)
self.assertTrue(len(result) > 0)
cert = None
for temp in result:
if temp.subscription_certificate_thumbprint == self.management_certificate_name:
cert = temp
break
self.assertIsNotNone(cert)
self.assertIsNotNone(cert.created)
self.assertEqual(cert.subscription_certificate_public_key, MANAGEMENT_CERT_PUBLICKEY)
self.assertEqual(cert.subscription_certificate_data, MANAGEMENT_CERT_DATA)
self.assertEqual(cert.subscription_certificate_thumbprint, self.management_certificate_name)
def test_get_management_certificate(self):
# Arrange
self._create_management_certificate(self.management_certificate_name)
# Act
result = self.sms.get_management_certificate(self.management_certificate_name)
# Assert
self.assertIsNotNone(result)
self.assertIsNotNone(result.created)
self.assertEqual(result.subscription_certificate_public_key, MANAGEMENT_CERT_PUBLICKEY)
self.assertEqual(result.subscription_certificate_data, MANAGEMENT_CERT_DATA)
self.assertEqual(result.subscription_certificate_thumbprint, self.management_certificate_name)
def test_add_management_certificate(self):
# Arrange
public_key = MANAGEMENT_CERT_PUBLICKEY
data = MANAGEMENT_CERT_DATA
# Act
result = self.sms.add_management_certificate(public_key, self.management_certificate_name, data)
# Assert
self.assertIsNone(result)
self.assertTrue(self._management_certificate_exists(self.management_certificate_name))
def test_delete_management_certificate(self):
# Arrange
self._create_management_certificate(self.management_certificate_name)
# Act
result = self.sms.delete_management_certificate(self.management_certificate_name)
# Assert
self.assertIsNone(result)
self.assertFalse(self._management_certificate_exists(self.management_certificate_name))
开发者ID:Bunkerbewohner,项目名称:azure-sdk-for-python,代码行数:91,代码来源:test_managementcertificatemanagementservice.py
示例2: ManagementCertificateManagementServiceTest
# 需要导入模块: from azure.servicemanagement import ServiceManagementService [as 别名]
# 或者: from azure.servicemanagement.ServiceManagementService import list_management_certificates [as 别名]
class ManagementCertificateManagementServiceTest(AzureTestCase):
def setUp(self):
self.sms = ServiceManagementService(credentials.getSubscriptionId(),
credentials.getManagementCertFile())
self.sms.set_proxy(credentials.getProxyHost(),
credentials.getProxyPort(),
credentials.getProxyUser(),
credentials.getProxyPassword())
self.certificate_thumbprints = []
def tearDown(self):
for thumbprint in self.certificate_thumbprints:
try:
self.sms.delete_management_certificate(thumbprint)
except: pass
#--Helpers-----------------------------------------------------------------
def _create_management_certificate(self, cert):
self.certificate_thumbprints.append(cert.thumbprint)
result = self.sms.add_management_certificate(cert.public_key,
cert.thumbprint,
cert.data)
self.assertIsNone(result)
def _management_certificate_exists(self, thumbprint):
try:
props = self.sms.get_management_certificate(thumbprint)
return props is not None
except:
return False
#--Test cases for management certificates ----------------------------
def test_list_management_certificates(self):
# Arrange
local_cert = _local_certificate()
self._create_management_certificate(local_cert)
# Act
result = self.sms.list_management_certificates()
# Assert
self.assertIsNotNone(result)
self.assertTrue(len(result) > 0)
cert = None
for temp in result:
if temp.subscription_certificate_thumbprint == local_cert.thumbprint:
cert = temp
break
self.assertIsNotNone(cert)
self.assertIsNotNone(cert.created)
self.assertEqual(cert.subscription_certificate_public_key, local_cert.public_key)
self.assertEqual(cert.subscription_certificate_data, local_cert.data)
self.assertEqual(cert.subscription_certificate_thumbprint, local_cert.thumbprint)
def test_get_management_certificate(self):
# Arrange
local_cert = _local_certificate()
self._create_management_certificate(local_cert)
# Act
result = self.sms.get_management_certificate(local_cert.thumbprint)
# Assert
self.assertIsNotNone(result)
self.assertIsNotNone(result.created)
self.assertEqual(result.subscription_certificate_public_key, local_cert.public_key)
self.assertEqual(result.subscription_certificate_data, local_cert.data)
self.assertEqual(result.subscription_certificate_thumbprint, local_cert.thumbprint)
def test_add_management_certificate(self):
# Arrange
local_cert = _local_certificate()
# Act
self.certificate_thumbprints.append(local_cert.thumbprint)
result = self.sms.add_management_certificate(local_cert.public_key,
local_cert.thumbprint,
local_cert.data)
# Assert
self.assertIsNone(result)
self.assertTrue(self._management_certificate_exists(local_cert.thumbprint))
def test_delete_management_certificate(self):
# Arrange
local_cert = _local_certificate()
self._create_management_certificate(local_cert)
# Act
result = self.sms.delete_management_certificate(local_cert.thumbprint)
# Assert
self.assertIsNone(result)
self.assertFalse(self._management_certificate_exists(local_cert.thumbprint))