/
opt
/
imh-python
/
lib
/
python3.9
/
site-packages
/
libcloud
/
test
/
dns
/
/opt/imh-python/lib/python3.9/site-packages/libcloud/test/dns
mkdir
upload
Name
Size
Mode
Actions
fixtures/
-
0755
rm
__pycache__/
-
0755
rm
test_auroradns.py
12849
0644
edit
dl
rm
test_base.py
4989
0644
edit
dl
rm
test_buddyns.py
6294
0644
edit
dl
rm
test_cloudflare.py
15093
0644
edit
dl
rm
test_digitalocean.py
7115
0644
edit
dl
rm
test_dnsimple.py
11814
0644
edit
dl
rm
test_dnspod.py
10804
0644
edit
dl
rm
test_durabledns.py
27827
0644
edit
dl
rm
test_gandi.py
12019
0644
edit
dl
rm
test_gandi_live.py
17155
0644
edit
dl
rm
test_godaddy.py
7260
0644
edit
dl
rm
test_google.py
7732
0644
edit
dl
rm
test_hostvirtual.py
10728
0644
edit
dl
rm
test_linode.py
13995
0644
edit
dl
rm
test_liquidweb.py
14079
0644
edit
dl
rm
test_luadns.py
12153
0644
edit
dl
rm
test_nfsn.py
6018
0644
edit
dl
rm
test_nsone.py
10309
0644
edit
dl
rm
test_onapp.py
9538
0644
edit
dl
rm
test_pointdns.py
33526
0644
edit
dl
rm
test_powerdns.py
7764
0644
edit
dl
rm
test_rackspace.py
25793
0644
edit
dl
rm
test_rcodezero.py
8565
0644
edit
dl
rm
test_route53.py
14213
0644
edit
dl
rm
test_softlayer.py
9817
0644
edit
dl
rm
test_vultr.py
12848
0644
edit
dl
rm
test_worldwidedns.py
20383
0644
edit
dl
rm
test_zerigo.py
14587
0644
edit
dl
rm
test_zonomi.py
16113
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
Edit:
/opt/imh-python/lib/python3.9/site-packages/libcloud/test/dns/test_google.py
(7732B)
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and import sys import unittest from libcloud.utils.py3 import httplib from libcloud.dns.types import ZoneDoesNotExistError from libcloud.dns.types import RecordDoesNotExistError from libcloud.dns.drivers.google import GoogleDNSDriver from libcloud.common.google import GoogleBaseAuthConnection from libcloud.test.common.test_google import GoogleAuthMockHttp, GoogleTestCase from libcloud.test import MockHttp from libcloud.test.file_fixtures import DNSFileFixtures from libcloud.test.secrets import DNS_PARAMS_GOOGLE, DNS_KEYWORD_PARAMS_GOOGLE class GoogleTests(GoogleTestCase): def setUp(self): GoogleDNSMockHttp.test = self GoogleDNSDriver.connectionCls.conn_class = GoogleDNSMockHttp GoogleBaseAuthConnection.conn_class = GoogleAuthMockHttp GoogleDNSMockHttp.type = None kwargs = DNS_KEYWORD_PARAMS_GOOGLE.copy() kwargs['auth_type'] = 'IA' self.driver = GoogleDNSDriver(*DNS_PARAMS_GOOGLE, **kwargs) def test_default_scopes(self): self.assertIsNone(self.driver.scopes) def test_list_zones(self): zones = self.driver.list_zones() self.assertEqual(len(zones), 2) def test_list_records(self): zone = self.driver.list_zones()[0] records = self.driver.list_records(zone=zone) self.assertEqual(len(records), 3) def test_get_zone(self): zone = self.driver.get_zone('example-com') self.assertEqual(zone.id, 'example-com') self.assertEqual(zone.domain, 'example.com.') def test_get_zone_does_not_exist(self): GoogleDNSMockHttp.type = 'ZONE_DOES_NOT_EXIST' try: self.driver.get_zone('example-com') except ZoneDoesNotExistError as e: self.assertEqual(e.zone_id, 'example-com') else: self.fail('Exception not thrown') def test_get_record(self): GoogleDNSMockHttp.type = 'FILTER_ZONES' zone = self.driver.list_zones()[0] record = self.driver.get_record(zone.id, "A:foo.example.com.") self.assertEqual(record.id, 'A:foo.example.com.') self.assertEqual(record.name, 'foo.example.com.') self.assertEqual(record.type, 'A') self.assertEqual(record.zone.id, 'example-com') def test_get_record_zone_does_not_exist(self): GoogleDNSMockHttp.type = 'ZONE_DOES_NOT_EXIST' try: self.driver.get_record('example-com', 'a:a') except ZoneDoesNotExistError as e: self.assertEqual(e.zone_id, 'example-com') else: self.fail('Exception not thrown') def test_get_record_record_does_not_exist(self): GoogleDNSMockHttp.type = 'RECORD_DOES_NOT_EXIST' try: self.driver.get_record('example-com', "A:foo") except RecordDoesNotExistError as e: self.assertEqual(e.record_id, 'A:foo') else: self.fail('Exception not thrown') def test_create_zone(self): extra = {'description': 'new domain for example.org'} zone = self.driver.create_zone('example.org.', extra) self.assertEqual(zone.domain, 'example.org.') self.assertEqual(zone.extra['description'], extra['description']) self.assertEqual(len(zone.extra['nameServers']), 4) def test_delete_zone(self): zone = self.driver.get_zone('example-com') res = self.driver.delete_zone(zone) self.assertTrue(res) def test_ex_bulk_record_changes(self): zone = self.driver.get_zone('example-com') records = self.driver.ex_bulk_record_changes(zone, {}) self.assertEqual(records['additions'][0].name, 'foo.example.com.') self.assertEqual(records['additions'][0].type, 'A') self.assertEqual(records['deletions'][0].name, 'bar.example.com.') self.assertEqual(records['deletions'][0].type, 'A') class GoogleDNSMockHttp(MockHttp): fixtures = DNSFileFixtures('google') def _dns_v1_projects_project_name_managedZones( self, method, url, body, headers): if method == 'POST': body = self.fixtures.load('zone_create.json') else: body = self.fixtures.load('zone_list.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _dns_v1_projects_project_name_managedZones_FILTER_ZONES( self, method, url, body, headers): body = self.fixtures.load('zone_list.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _dns_v1_projects_project_name_managedZones_example_com_rrsets_FILTER_ZONES( self, method, url, body, headers): body = self.fixtures.load('record.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _dns_v1_projects_project_name_managedZones_example_com_rrsets( self, method, url, body, headers): body = self.fixtures.load('records_list.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _dns_v1_projects_project_name_managedZones_example_com( self, method, url, body, headers): if method == 'GET': body = self.fixtures.load('managed_zones_1.json') elif method == 'DELETE': body = None return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _dns_v1_projects_project_name_managedZones_example_com_changes( self, method, url, body, headers): body = self.fixtures.load('record_changes.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _dns_v1_projects_project_name_managedZones_example_com_ZONE_DOES_NOT_EXIST( self, method, url, body, headers): body = self.fixtures.load('get_zone_does_not_exists.json') return (httplib.NOT_FOUND, body, {}, httplib.responses[httplib.NOT_FOUND]) def _dns_v1_projects_project_name_managedZones_example_com_RECORD_DOES_NOT_EXIST( self, method, url, body, headers): body = self.fixtures.load('managed_zones_1.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _dns_v1_projects_project_name_managedZones_example_com_rrsets_RECORD_DOES_NOT_EXIST( self, method, url, body, headers): body = self.fixtures.load('no_record.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _dns_v1_projects_project_name_managedZones_example_com_rrsets_ZONE_DOES_NOT_EXIST( self, method, url, body, headers): body = self.fixtures.load('get_zone_does_not_exists.json') return (httplib.NOT_FOUND, body, {}, httplib.responses[httplib.NOT_FOUND]) def _dns_v1_projects_project_name_managedZones_example_com_FILTER_ZONES( self, method, url, body, headers): body = self.fixtures.load('zone.json') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) if __name__ == '__main__': sys.exit(unittest.main())
Save
cmd:
run