class PowerDNSTestCase(LibcloudTestCase): def setUp(self): PowerDNSDriver.connectionCls.conn_class = PowerDNSMockHttp PowerDNSMockHttp.type = None self.driver = PowerDNSDriver('testsecret') self.test_zone = Zone(id='example.com.', domain='example.com', driver=self.driver, type='master', ttl=None, extra={}) self.test_record = Record(id=None, name='', data='192.0.2.1', type=RecordType.A, zone=self.test_zone, driver=self.driver, extra={}) def test_create_record(self): record = self.test_zone.create_record(name='newrecord.example.com', type=RecordType.A, data='192.0.5.4', extra={'ttl': 86400}) self.assertEqual(record.id, None) self.assertEqual(record.name, 'newrecord.example.com') self.assertEqual(record.data, '192.0.5.4') self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 86400) def test_create_zone(self): extra = {'nameservers': ['ns1.example.org', 'ns2.example.org']} zone = self.driver.create_zone('example.org', extra=extra) self.assertEqual(zone.id, 'example.org.') self.assertEqual(zone.domain, 'example.org') self.assertEqual(zone.type, None) self.assertEqual(zone.ttl, None) def test_delete_record(self): self.assertTrue(self.test_record.delete()) def test_delete_zone(self): self.assertTrue(self.test_zone.delete()) def test_get_record(self): with self.assertRaises(NotImplementedError): self.driver.get_record('example.com.', '12345') def test_get_zone(self): zone = self.driver.get_zone('example.com.') self.assertEqual(zone.id, 'example.com.') self.assertEqual(zone.domain, 'example.com') self.assertEqual(zone.type, None) self.assertEqual(zone.ttl, None) def test_list_record_types(self): result = self.driver.list_record_types() self.assertEqual(len(result), 23) def test_list_records(self): records = self.driver.list_records(self.test_zone) self.assertEqual(len(records), 4) def test_list_zones(self): zones = self.driver.list_zones() self.assertEqual(zones[0].id, 'example.com.') self.assertEqual(zones[0].domain, 'example.com') self.assertEqual(zones[0].type, None) self.assertEqual(zones[0].ttl, None) self.assertEqual(zones[1].id, 'example.net.') self.assertEqual(zones[1].domain, 'example.net') self.assertEqual(zones[1].type, None) self.assertEqual(zones[1].ttl, None) def test_update_record(self): record = self.driver.update_record(self.test_record, name='newrecord.example.com', type=RecordType.A, data='127.0.0.1', extra={'ttl': 300}) self.assertEqual(record.id, None) self.assertEqual(record.name, 'newrecord.example.com') self.assertEqual(record.data, '127.0.0.1') self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 300) def test_update_zone(self): with self.assertRaises(NotImplementedError): self.driver.update_zone(self.test_zone, 'example.net') # Test some error conditions def test_create_existing_zone(self): PowerDNSMockHttp.type = 'EXISTS' extra = {'nameservers': ['ns1.example.com', 'ns2.example.com']} with self.assertRaises(ZoneAlreadyExistsError): self.driver.create_zone('example.com', extra=extra) def test_get_missing_zone(self): PowerDNSMockHttp.type = 'MISSING' with self.assertRaises(ZoneDoesNotExistError): self.driver.get_zone('example.com.') def test_delete_missing_record(self): PowerDNSMockHttp.type = 'MISSING' self.assertFalse(self.test_record.delete()) def test_delete_missing_zone(self): PowerDNSMockHttp.type = 'MISSING' self.assertFalse(self.test_zone.delete())
class RcodeZeroDNSTestCase(LibcloudTestCase): def setUp(self): RcodeZeroDNSDriver.connectionCls.conn_class = RcodeZeroDNSMockHttp RcodeZeroDNSMockHttp.type = None self.driver = RcodeZeroDNSDriver('mysecret') self.test_zone = Zone(id='example.at', domain='example.at', driver=self.driver, type='master', ttl=None, extra={}) self.test_record = Record(id=None, name='', data='192.0.2.1', type=RecordType.A, zone=self.test_zone, driver=self.driver, extra={}) def test_create_record(self): record = self.test_zone.create_record(name='newrecord', type=RecordType.A, data='192.0.5.4', extra={'ttl': 86400}) self.assertEqual(record.id, None) self.assertEqual(record.name, 'newrecord') self.assertEqual(record.data, '192.0.5.4') self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 86400) def test_create_zone(self): extra = {"masters": ["193.0.2.2"]} zone = self.driver.create_zone("example.at", type='slave', extra=extra) self.assertEqual(zone.id, 'example.at.') self.assertEqual(zone.domain, 'example.at') self.assertEqual(zone.type, 'slave') self.assertEqual(zone.ttl, None) def test_delete_record(self): self.assertTrue(self.test_record.delete()) def test_delete_zone(self): self.assertTrue(self.test_zone.delete()) def test_get_record(self): record = self.driver.get_record('example.at.', '12345') self.assertEqual(record, None) def test_get_zone(self): zone = self.driver.get_zone('example.at') self.assertEqual(zone.id, 'example.at') self.assertEqual(zone.domain, 'example.at') self.assertEqual(zone.type, 'master') self.assertEqual(zone.ttl, None) def test_list_record_types(self): result = self.driver.list_record_types() self.assertEqual(len(result), 25) def test_list_records(self): records = self.driver.list_records(self.test_zone) self.assertEqual(len(records), 3) def test_list_zones(self): zones = self.driver.list_zones() self.assertEqual(zones[0].id, 'example1.at') self.assertEqual(zones[0].domain, 'example1.at') self.assertEqual(zones[0].type, 'slave') self.assertEqual(zones[0].ttl, None) self.assertEqual(zones[0].extra['masters'][0], '193.0.2.2') self.assertEqual(zones[0].extra['serial'], 20180411) self.assertEqual(zones[1].id, 'example2.at') self.assertEqual(zones[1].domain, 'example2.at') self.assertEqual(zones[1].type, 'master') self.assertEqual(zones[1].ttl, None) def test_update_record(self): record = self.driver.update_record(self.test_record, name='newrecord', type=RecordType.A, data='127.0.0.1', extra={'ttl': 300}) self.assertEqual(record.id, '430059068a39501b8df5a577b1e46ad7') self.assertEqual(record.name, 'newrecord') self.assertEqual(record.data, '127.0.0.1') self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 300) def test_update_zone(self): with self.assertRaises(NotImplementedError): self.driver.update_zone(self.test_zone, 'example.at') # # Test some error conditions def test_create_existing_zone(self): RcodeZeroDNSMockHttp.type = 'EXISTS' extra = {'masters': ['193.0.2.2']} with self.assertRaises(ZoneAlreadyExistsError): self.driver.create_zone("example1.at", type='slave', extra=extra) def test_get_missing_zone(self): RcodeZeroDNSMockHttp.type = 'MISSING' with self.assertRaises(ZoneDoesNotExistError): self.driver.get_zone('example.com') def test_delete_missing_zone(self): RcodeZeroDNSMockHttp.type = 'MISSING' self.assertFalse(self.test_zone.delete())
class NFSNTestCase(LibcloudTestCase): def setUp(self): NFSNDNSDriver.connectionCls.conn_classes = (None, NFSNMockHttp) NFSNMockHttp.type = None self.driver = NFSNDNSDriver('testid', 'testsecret') self.test_zone = Zone(id='example.com', domain='example.com', driver=self.driver, type='master', ttl=None, extra={}) self.test_record = Record(id=None, name='', data='192.0.2.1', type=RecordType.A, zone=self.test_zone, driver=self.driver, extra={}) def test_list_zones(self): with self.assertRaises(NotImplementedError): self.driver.list_zones() def test_create_zone(self): with self.assertRaises(NotImplementedError): self.driver.create_zone('example.com') def test_get_zone(self): zone = self.driver.get_zone('example.com') self.assertEquals(zone.id, None) self.assertEquals(zone.domain, 'example.com') def test_delete_zone(self): with self.assertRaises(NotImplementedError): self.driver.delete_zone(self.test_zone) def test_create_record(self): NFSNMockHttp.type = 'CREATED' record = self.test_zone.create_record(name='newrecord', type=RecordType.A, data='127.0.0.1', extra={'ttl': 900}) self.assertEquals(record.id, None) self.assertEquals(record.name, 'newrecord') self.assertEquals(record.data, '127.0.0.1') self.assertEquals(record.type, RecordType.A) self.assertEquals(record.ttl, 900) def test_get_record(self): with self.assertRaises(NotImplementedError): self.driver.get_record('example.com', '12345') def test_delete_record(self): self.assertTrue(self.test_record.delete()) def test_list_records(self): records = self.driver.list_records(self.test_zone) self.assertEqual(len(records), 2) def test_ex_get_records_by(self): NFSNMockHttp.type = 'ONE_RECORD' records = self.driver.ex_get_records_by(self.test_zone, type=RecordType.A) self.assertEqual(len(records), 1) record = records[0] self.assertEquals(record.name, '') self.assertEquals(record.data, '192.0.2.1') self.assertEquals(record.type, RecordType.A) self.assertEquals(record.ttl, 3600) def test_get_zone_not_found(self): NFSNMockHttp.type = 'NOT_FOUND' with self.assertRaises(ZoneDoesNotExistError): self.driver.get_zone('example.com') def test_delete_record_not_found(self): NFSNMockHttp.type = 'NOT_FOUND' with self.assertRaises(RecordDoesNotExistError): self.assertTrue(self.test_record.delete())
class RcodeZeroDNSTestCase(LibcloudTestCase): def setUp(self): RcodeZeroDNSDriver.connectionCls.conn_class = RcodeZeroDNSMockHttp RcodeZeroDNSMockHttp.type = None self.driver = RcodeZeroDNSDriver("mysecret") self.test_zone = Zone( id="example.at", domain="example.at", driver=self.driver, type="master", ttl=None, extra={}, ) self.test_record = Record( id=None, name="", data="192.0.2.1", type=RecordType.A, zone=self.test_zone, driver=self.driver, extra={}, ) def test_create_record(self): record = self.test_zone.create_record( name="newrecord", type=RecordType.A, data="192.0.5.4", extra={"ttl": 86400} ) self.assertEqual(record.id, None) self.assertEqual(record.name, "newrecord") self.assertEqual(record.data, "192.0.5.4") self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 86400) def test_create_zone(self): extra = {"masters": ["193.0.2.2"]} zone = self.driver.create_zone("example.at", type="slave", extra=extra) self.assertEqual(zone.id, "example.at.") self.assertEqual(zone.domain, "example.at") self.assertEqual(zone.type, "slave") self.assertEqual(zone.ttl, None) def test_delete_record(self): self.assertTrue(self.test_record.delete()) def test_delete_zone(self): self.assertTrue(self.test_zone.delete()) def test_get_record(self): record = self.driver.get_record("example.at.", "12345") self.assertEqual(record, None) def test_get_zone(self): zone = self.driver.get_zone("example.at") self.assertEqual(zone.id, "example.at") self.assertEqual(zone.domain, "example.at") self.assertEqual(zone.type, "master") self.assertEqual(zone.ttl, None) def test_list_record_types(self): result = self.driver.list_record_types() self.assertEqual(len(result), 25) def test_list_records(self): records = self.driver.list_records(self.test_zone) self.assertEqual(len(records), 3) def test_list_zones(self): zones = self.driver.list_zones() self.assertEqual(zones[0].id, "example1.at") self.assertEqual(zones[0].domain, "example1.at") self.assertEqual(zones[0].type, "slave") self.assertEqual(zones[0].ttl, None) self.assertEqual(zones[0].extra["masters"][0], "193.0.2.2") self.assertEqual(zones[0].extra["serial"], 20180411) self.assertEqual(zones[1].id, "example2.at") self.assertEqual(zones[1].domain, "example2.at") self.assertEqual(zones[1].type, "master") self.assertEqual(zones[1].ttl, None) def test_update_record(self): record = self.driver.update_record( self.test_record, name="newrecord", type=RecordType.A, data="127.0.0.1", extra={"ttl": 300}, ) self.assertEqual(record.id, "430059068a39501b8df5a577b1e46ad7") self.assertEqual(record.name, "newrecord") self.assertEqual(record.data, "127.0.0.1") self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 300) def test_update_zone(self): with self.assertRaises(NotImplementedError): self.driver.update_zone(self.test_zone, "example.at") # # Test some error conditions def test_create_existing_zone(self): RcodeZeroDNSMockHttp.type = "EXISTS" extra = {"masters": ["193.0.2.2"]} with self.assertRaises(ZoneAlreadyExistsError): self.driver.create_zone("example1.at", type="slave", extra=extra) def test_get_missing_zone(self): RcodeZeroDNSMockHttp.type = "MISSING" with self.assertRaises(ZoneDoesNotExistError): self.driver.get_zone("example.com") def test_delete_missing_zone(self): RcodeZeroDNSMockHttp.type = "MISSING" self.assertFalse(self.test_zone.delete())
class NFSNTestCase(LibcloudTestCase): def setUp(self): NFSNDNSDriver.connectionCls.conn_class = NFSNMockHttp NFSNMockHttp.type = None self.driver = NFSNDNSDriver('testid', 'testsecret') self.test_zone = Zone(id='example.com', domain='example.com', driver=self.driver, type='master', ttl=None, extra={}) self.test_record = Record(id=None, name='', data='192.0.2.1', type=RecordType.A, zone=self.test_zone, driver=self.driver, extra={}) def test_list_zones(self): with self.assertRaises(NotImplementedError): self.driver.list_zones() def test_create_zone(self): with self.assertRaises(NotImplementedError): self.driver.create_zone('example.com') def test_get_zone(self): zone = self.driver.get_zone('example.com') self.assertEquals(zone.id, None) self.assertEquals(zone.domain, 'example.com') def test_delete_zone(self): with self.assertRaises(NotImplementedError): self.driver.delete_zone(self.test_zone) def test_create_record(self): NFSNMockHttp.type = 'CREATED' record = self.test_zone.create_record(name='newrecord', type=RecordType.A, data='127.0.0.1', extra={'ttl': 900}) self.assertEquals(record.id, None) self.assertEquals(record.name, 'newrecord') self.assertEquals(record.data, '127.0.0.1') self.assertEquals(record.type, RecordType.A) self.assertEquals(record.ttl, 900) def test_get_record(self): with self.assertRaises(NotImplementedError): self.driver.get_record('example.com', '12345') def test_delete_record(self): self.assertTrue(self.test_record.delete()) def test_list_records(self): records = self.driver.list_records(self.test_zone) self.assertEqual(len(records), 2) def test_ex_get_records_by(self): NFSNMockHttp.type = 'ONE_RECORD' records = self.driver.ex_get_records_by(self.test_zone, type=RecordType.A) self.assertEqual(len(records), 1) record = records[0] self.assertEquals(record.name, '') self.assertEquals(record.data, '192.0.2.1') self.assertEquals(record.type, RecordType.A) self.assertEquals(record.ttl, 3600) def test_get_zone_not_found(self): NFSNMockHttp.type = 'NOT_FOUND' with self.assertRaises(ZoneDoesNotExistError): self.driver.get_zone('example.com') def test_delete_record_not_found(self): NFSNMockHttp.type = 'NOT_FOUND' with self.assertRaises(RecordDoesNotExistError): self.assertTrue(self.test_record.delete())
class NFSNTestCase(LibcloudTestCase): def setUp(self): NFSNDNSDriver.connectionCls.conn_class = NFSNMockHttp NFSNMockHttp.type = None self.driver = NFSNDNSDriver("testid", "testsecret") self.test_zone = Zone( id="example.com", domain="example.com", driver=self.driver, type="master", ttl=None, extra={}, ) self.test_record = Record( id=None, name="", data="192.0.2.1", type=RecordType.A, zone=self.test_zone, driver=self.driver, extra={}, ) def test_list_zones(self): with self.assertRaises(NotImplementedError): self.driver.list_zones() def test_create_zone(self): with self.assertRaises(NotImplementedError): self.driver.create_zone("example.com") def test_get_zone(self): zone = self.driver.get_zone("example.com") self.assertEqual(zone.id, None) self.assertEqual(zone.domain, "example.com") def test_delete_zone(self): with self.assertRaises(NotImplementedError): self.driver.delete_zone(self.test_zone) def test_create_record(self): NFSNMockHttp.type = "CREATED" record = self.test_zone.create_record( name="newrecord", type=RecordType.A, data="127.0.0.1", extra={"ttl": 900} ) self.assertEqual(record.id, None) self.assertEqual(record.name, "newrecord") self.assertEqual(record.data, "127.0.0.1") self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 900) def test_get_record(self): with self.assertRaises(NotImplementedError): self.driver.get_record("example.com", "12345") def test_delete_record(self): self.assertTrue(self.test_record.delete()) def test_list_records(self): records = self.driver.list_records(self.test_zone) self.assertEqual(len(records), 2) def test_ex_get_records_by(self): NFSNMockHttp.type = "ONE_RECORD" records = self.driver.ex_get_records_by(self.test_zone, type=RecordType.A) self.assertEqual(len(records), 1) record = records[0] self.assertEqual(record.name, "") self.assertEqual(record.data, "192.0.2.1") self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 3600) def test_get_zone_not_found(self): NFSNMockHttp.type = "NOT_FOUND" with self.assertRaises(ZoneDoesNotExistError): self.driver.get_zone("example.com") def test_delete_record_not_found(self): NFSNMockHttp.type = "NOT_FOUND" with self.assertRaises(RecordDoesNotExistError): self.assertTrue(self.test_record.delete())
class PowerDNSTestCase(LibcloudTestCase): def setUp(self): PowerDNSDriver.connectionCls.conn_class = PowerDNSMockHttp PowerDNSMockHttp.type = None self.driver = PowerDNSDriver("testsecret") self.test_zone = Zone( id="example.com.", domain="example.com", driver=self.driver, type="master", ttl=None, extra={}, ) self.test_record = Record( id=None, name="", data="192.0.2.1", type=RecordType.A, zone=self.test_zone, driver=self.driver, extra={}, ) def test_create_record(self): record = self.test_zone.create_record( name="newrecord.example.com", type=RecordType.A, data="192.0.5.4", extra={"ttl": 86400}, ) self.assertIsNone(record.id) self.assertEqual(record.name, "newrecord.example.com") self.assertEqual(record.data, "192.0.5.4") self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 86400) def test_create_zone(self): extra = {"nameservers": ["ns1.example.org", "ns2.example.org"]} zone = self.driver.create_zone("example.org", extra=extra) self.assertEqual(zone.id, "example.org.") self.assertEqual(zone.domain, "example.org") self.assertIsNone(zone.type) self.assertIsNone(zone.ttl) def test_delete_record(self): self.assertTrue(self.test_record.delete()) def test_delete_zone(self): self.assertTrue(self.test_zone.delete()) def test_get_record(self): with self.assertRaises(NotImplementedError): self.driver.get_record("example.com.", "12345") def test_get_zone(self): zone = self.driver.get_zone("example.com.") self.assertEqual(zone.id, "example.com.") self.assertEqual(zone.domain, "example.com") self.assertIsNone(zone.type) self.assertIsNone(zone.ttl) def test_list_record_types(self): result = self.driver.list_record_types() self.assertEqual(len(result), 23) def test_list_records(self): records = self.driver.list_records(self.test_zone) self.assertEqual(len(records), 4) def test_list_zones(self): zones = self.driver.list_zones() self.assertEqual(zones[0].id, "example.com.") self.assertEqual(zones[0].domain, "example.com") self.assertIsNone(zones[0].type) self.assertIsNone(zones[0].ttl) self.assertEqual(zones[1].id, "example.net.") self.assertEqual(zones[1].domain, "example.net") self.assertIsNone(zones[1].type) self.assertIsNone(zones[1].ttl) def test_update_record(self): record = self.driver.update_record( self.test_record, name="newrecord.example.com", type=RecordType.A, data="127.0.0.1", extra={"ttl": 300}, ) self.assertIsNone(record.id) self.assertEqual(record.name, "newrecord.example.com") self.assertEqual(record.data, "127.0.0.1") self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 300) def test_update_zone(self): with self.assertRaises(NotImplementedError): self.driver.update_zone(self.test_zone, "example.net") # Test some error conditions def test_create_existing_zone(self): PowerDNSMockHttp.type = "EXISTS" extra = {"nameservers": ["ns1.example.com", "ns2.example.com"]} with self.assertRaises(ZoneAlreadyExistsError): self.driver.create_zone("example.com", extra=extra) def test_get_missing_zone(self): PowerDNSMockHttp.type = "MISSING" with self.assertRaises(ZoneDoesNotExistError): self.driver.get_zone("example.com.") def test_delete_missing_record(self): PowerDNSMockHttp.type = "MISSING" self.assertFalse(self.test_record.delete()) def test_delete_missing_zone(self): PowerDNSMockHttp.type = "MISSING" self.assertFalse(self.test_zone.delete())