本文整理汇总了Python中functionaltests.api.v2.clients.zone_client.ZoneClient.as_user方法的典型用法代码示例。如果您正苦于以下问题:Python ZoneClient.as_user方法的具体用法?Python ZoneClient.as_user怎么用?Python ZoneClient.as_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类functionaltests.api.v2.clients.zone_client.ZoneClient
的用法示例。
在下文中一共展示了ZoneClient.as_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_import_domain
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_import_domain(self):
user = 'default'
resp, zone = ZoneClient.as_user(user).post_zone(
datagen.random_zone_data())
ZoneClient.as_user(user).wait_for_zone(zone.id)
export_client = ZoneExportClient.as_user(user)
resp, model = export_client.post_zone_export(zone.id)
export_id = model.id
self.assertEqual(resp.status, 202)
self.assertEqual(model.status, 'PENDING')
export_client.wait_for_zone_export(export_id)
resp, model = export_client.get_zone_export(export_id)
self.assertEqual(resp.status, 200)
self.assertEqual(model.status, 'COMPLETE')
resp, body = export_client.get_exported_zone(export_id)
self.assertEqual(resp.status, 200)
export_client.delete_zone_export(export_id)
self.assertRaises(NotFound,
lambda: export_client.get_zone_export(model.id))
示例2: setUp
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def setUp(self):
super(RecordsetTest, self).setUp()
self.increase_quotas(user='default')
resp, self.zone = ZoneClient.as_user('default').post_zone(
datagen.random_zone_data())
ZoneClient.as_user('default').wait_for_zone(self.zone.id)
self.client = RecordsetClient.as_user('default', with_token=False)
示例3: setUp
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def setUp(self):
super(TransferZoneOwnerShipTest, self).setUp()
self.increase_quotas(user='default')
self.increase_quotas(user='alt')
resp, self.zone = ZoneClient.as_user('default').post_zone(
datagen.random_zone_data())
ZoneClient.as_user('default').wait_for_zone(self.zone.id)
示例4: test_do_zone_transfer_scoped
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_do_zone_transfer_scoped(self):
target_project_id = TransferRequestClient.as_user('alt').tenant_id
post_model = datagen.random_transfer_request_data(
target_project_id=target_project_id)
fixture = self.useFixture(TransferRequestFixture(
zone=self.zone,
post_model=post_model,
user='default',
target_user='alt',
))
transfer_request = fixture.transfer_request
resp, retrived_transfer_request = TransferRequestClient.\
as_user('alt').get_transfer_request(transfer_request.id)
self.assertEqual(200, resp.status)
resp, transfer_accept = TransferAcceptClient.as_user('alt')\
.post_transfer_accept(
datagen.random_transfer_accept_data(
key=transfer_request.key,
zone_transfer_request_id=transfer_request.id
))
self.assertEqual(201, resp.status)
client = ZoneClient.as_user('default')
self._assert_exception(
exceptions.NotFound, 'domain_not_found', 404,
client.get_zone, self.zone.id)
resp, zone = ZoneClient.as_user('alt').get_zone(self.zone.id)
self.assertEqual(200, resp.status)
示例5: test_do_zone_transfer_scoped
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_do_zone_transfer_scoped(self):
target_project_id = TransferRequestClient.as_user('alt').tenant_id
resp, transfer_request = TransferRequestClient.as_user('default')\
.post_transfer_request(self.zone.id,
datagen.random_transfer_request_data(
target_project_id=target_project_id))
self.assertEqual(resp.status, 201)
resp, retrived_transfer_request = TransferRequestClient.\
as_user('alt').get_transfer_request(transfer_request.id)
self.assertEqual(resp.status, 200)
resp, transfer_accept = TransferAcceptClient.as_user('alt')\
.post_transfer_accept(
datagen.random_transfer_accept_data(
key=transfer_request.key,
zone_transfer_request_id=transfer_request.id
))
self.assertEqual(resp.status, 201)
client = ZoneClient.as_user('default')
self._assert_exception(
exceptions.NotFound, 'domain_not_found', 404,
client.get_zone, self.zone.id)
resp, zone = ZoneClient.as_user('alt').get_zone(self.zone.id)
self.assertEqual(resp.status, 200)
示例6: setUp
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def setUp(self):
super(ZoneTest, self).setUp()
self.increase_quotas(user='default')
self.authed_client = ZoneClient.as_user('default')
self.client = ZoneClient.as_user('default', with_token=False)
self.fixture = self.useFixture(ZoneFixture(user='default'))
self.zone = None
示例7: test_no_create_subdomain_by_alt_user
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_no_create_subdomain_by_alt_user(self):
zone = self.useFixture(ZoneFixture(user='default')).post_model
subzone = datagen.random_zone_data(name='sub.' + zone.name)
subsubzone = datagen.random_zone_data(name='sub.sub.' + zone.name)
self.assertRaises(Forbidden,
lambda: ZoneClient.as_user('alt').post_zone(subzone))
self.assertRaises(Forbidden,
lambda: ZoneClient.as_user('alt').post_zone(subsubzone))
示例8: _create_transfer_request
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def _create_transfer_request(self):
client = TransferRequestClient.as_user(self.user)
self.post_resp, self.transfer_request = client \
.post_transfer_request(self.zone.id, self.post_model)
assert self.post_resp.status == 201
self.addCleanup(self.cleanup_transfer_request, client,
self.transfer_request.id)
self.addCleanup(ZoneFixture.cleanup_zone,
ZoneClient.as_user(self.user), self.zone.id)
self.addCleanup(ZoneFixture.cleanup_zone,
ZoneClient.as_user(self.target_user), self.zone.id)
示例9: test_no_create_recordset_via_alt_domain
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_no_create_recordset_via_alt_domain(self):
resp, zone = ZoneClient.as_user("default").post_zone(datagen.random_zone_data())
resp, alt_zone = ZoneClient.as_user("alt").post_zone(datagen.random_zone_data())
# alt attempts to create record with name A12345.{zone}
recordset = datagen.random_a_recordset(zone_name=zone.name)
self.assertRaises(
RestClientException, lambda: RecordsetClient.as_user("alt").post_recordset(zone.id, recordset)
)
self.assertRaises(
RestClientException, lambda: RecordsetClient.as_user("alt").post_recordset(alt_zone.id, recordset)
)
示例10: test_update_zone
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_update_zone(self):
old_model = self.fixture.created_zone
patch_model = datagen.random_zone_data()
del patch_model.name # don't try to override the zone name
resp, new_model = ZoneClient.as_user("default").patch_zone(old_model.id, patch_model)
self.assertEqual(resp.status, 202)
ZoneClient.as_user("default").wait_for_zone(new_model.id)
resp, model = ZoneClient.as_user("default").get_zone(new_model.id)
self.assertEqual(resp.status, 200)
self.assertEqual(new_model.id, old_model.id)
self.assertEqual(new_model.name, old_model.name)
self.assertEqual(new_model.ttl, patch_model.ttl)
self.assertEqual(new_model.email, patch_model.email)
示例11: setUp
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def setUp(self):
super(RecordsetFuzzTest, self).setUp()
# self.increase_quotas(user='admin')
resp, self.zone = ZoneClient.as_user('default').post_zone(
datagen.random_zone_data())
# ZoneClient.as_user('default').wait_for_zone(self.zone.id)
self.client = RecordsetClient.as_user('default')
示例12: test_no_create_super_recordsets
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_no_create_super_recordsets(self):
# default creates zone a.b.c.example.com.
# alt fails to create record with name b.c.example.com
zone_data = datagen.random_zone_data()
recordset = datagen.random_a_recordset(zone_name=zone_data.name)
recordset.name = 'b.c.' + zone_data.name
zone_data.name = 'a.b.c.' + zone_data.name
resp, zone = ZoneClient.as_user('default').post_zone(zone_data)
self.assertRaises(exceptions.RestClientException,
lambda: RecordsetClient.as_user('alt')
.post_recordset(zone.id, recordset))
示例13: test_no_create_recordset_by_alt_tenant
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_no_create_recordset_by_alt_tenant(self):
resp, zone = ZoneClient.as_user("default").post_zone(datagen.random_zone_data())
# try with name=A123456.zone.com.
recordset = datagen.random_a_recordset(zone_name=zone.name)
self.assertRaises(
RestClientException, lambda: RecordsetClient.as_user("alt").post_recordset(zone.id, recordset)
)
# try with name=zone.com.
recordset.name = zone.name
self.assertRaises(
RestClientException, lambda: RecordsetClient.as_user("alt").post_recordset(zone.id, recordset)
)
示例14: test_import_domain
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_import_domain(self):
user = "default"
import_client = ZoneImportClient.as_user(user)
zone_client = ZoneClient.as_user(user)
fixture = self.useFixture(ZoneImportFixture(user=user))
import_id = fixture.zone_import.id
resp, model = import_client.get_zone_import(import_id)
self.assertEqual(resp.status, 200)
self.assertEqual(model.status, "COMPLETE")
self.addCleanup(ZoneFixture.cleanup_zone, zone_client, model.zone_id)
# Wait for the zone to become 'ACTIVE'
zone_client.wait_for_zone(model.zone_id)
resp, zone_model = zone_client.get_zone(model.zone_id)
# Now make sure we can delete the zone_import
import_client.delete_zone_import(import_id)
self.assertRaises(NotFound, lambda: import_client.get_zone_import(model.id))
示例15: test_list_zones
# 需要导入模块: from functionaltests.api.v2.clients.zone_client import ZoneClient [as 别名]
# 或者: from functionaltests.api.v2.clients.zone_client.ZoneClient import as_user [as 别名]
def test_list_zones(self):
resp, model = ZoneClient.as_user('default').list_zones()
self.assertEqual(200, resp.status)
self.assertGreater(len(model.zones), 0)