diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bind_file.py | 52 | ||||
| -rw-r--r-- | tests/client.py | 16 | ||||
| -rw-r--r-- | tests/data/test.bind | 12 | ||||
| -rw-r--r-- | tests/data/test_no_ttl.bind | 12 |
4 files changed, 66 insertions, 26 deletions
diff --git a/tests/bind_file.py b/tests/bind_file.py index 4d1114f..7062146 100644 --- a/tests/bind_file.py +++ b/tests/bind_file.py @@ -15,7 +15,7 @@ class TestBindFileParsing(unittest.TestCase): self.assertEqual("test.com.", bind_file.origin) self.assertEqual(1234, bind_file.ttl) - self.assertEqual(5, len(bind_file.records)) + self.assertEqual(7, len(bind_file.records)) self.assertEqual( BindRecord( "test.com.", 600, RecordClass.IN, DNSRecordType.A, "1.2.3.4" @@ -24,12 +24,23 @@ class TestBindFileParsing(unittest.TestCase): ) self.assertEqual( BindRecord( - "sub.test.com.", 600, RecordClass.IN, DNSRecordType.A, "4.3.2.1" + "test.com.", + 600, + RecordClass.IN, + DNSRecordType.A, + "1.2.3.5", + comment="This is a comment", ), bind_file.records[1], ) self.assertEqual( BindRecord( + "sub.test.com.", 600, RecordClass.IN, DNSRecordType.A, "4.3.2.1" + ), + bind_file.records[2], + ) + self.assertEqual( + BindRecord( "test.com.", 600, RecordClass.IN, @@ -37,13 +48,13 @@ class TestBindFileParsing(unittest.TestCase): "2001:db8::1", comment="This is a comment", ), - bind_file.records[2], + bind_file.records[3], ) self.assertEqual( BindRecord( "test.com.", 1234, RecordClass.IN, DNSRecordType.TXT, "pkb-client" ), - bind_file.records[3], + bind_file.records[4], ) self.assertEqual( BindRecord( @@ -54,7 +65,7 @@ class TestBindFileParsing(unittest.TestCase): "mail.test.com.", prio=10, ), - bind_file.records[4], + bind_file.records[5], ) with self.subTest("Without default TTL"): @@ -63,7 +74,7 @@ class TestBindFileParsing(unittest.TestCase): self.assertEqual("test.com.", bind_file.origin) self.assertEqual(None, bind_file.ttl) - self.assertEqual(5, len(bind_file.records)) + self.assertEqual(7, len(bind_file.records)) self.assertEqual( BindRecord( "test.com.", 600, RecordClass.IN, DNSRecordType.A, "1.2.3.4" @@ -72,12 +83,23 @@ class TestBindFileParsing(unittest.TestCase): ) self.assertEqual( BindRecord( - "sub.test.com.", 600, RecordClass.IN, DNSRecordType.A, "4.3.2.1" + "test.com.", + 600, + RecordClass.IN, + DNSRecordType.A, + "1.2.3.5", + comment="This is a comment", ), bind_file.records[1], ) self.assertEqual( BindRecord( + "sub.test.com.", 600, RecordClass.IN, DNSRecordType.A, "4.3.2.1" + ), + bind_file.records[2], + ) + self.assertEqual( + BindRecord( "test.com.", 700, RecordClass.IN, @@ -85,13 +107,13 @@ class TestBindFileParsing(unittest.TestCase): "2001:db8::1", comment="This is a comment", ), - bind_file.records[2], + bind_file.records[3], ) self.assertEqual( BindRecord( "test.com.", 700, RecordClass.IN, DNSRecordType.TXT, "pkb-client" ), - bind_file.records[3], + bind_file.records[4], ) self.assertEqual( BindRecord( @@ -102,7 +124,7 @@ class TestBindFileParsing(unittest.TestCase): "mail.test.com.", prio=10, ), - bind_file.records[4], + bind_file.records[5], ) def test_writing_bind_file(self): @@ -131,11 +153,11 @@ class TestBindFileParsing(unittest.TestCase): file_content = ( "$ORIGIN test.com.\n" "$TTL 1234\n" - "test.com. 600 IN A 1.2.3.4\n" - "sub.test.com. 700 IN A 4.3.2.1\n" - "test.com. 600 IN AAAA 2001:db8::1\n" - "test.com. 600 IN TXT pkb-client\n" - "test.com. 600 IN MX 10 mail.test.com.\n" + 'test.com. 600 IN A "1.2.3.4"\n' + 'sub.test.com. 700 IN A "4.3.2.1"\n' + 'test.com. 600 IN AAAA "2001:db8::1"\n' + 'test.com. 600 IN TXT "pkb-client"\n' + 'test.com. 600 IN MX 10 "mail.test.com."\n' ) with tempfile.NamedTemporaryFile() as f: diff --git a/tests/client.py b/tests/client.py index 3b3a813..719ab84 100644 --- a/tests/client.py +++ b/tests/client.py @@ -1005,6 +1005,19 @@ class TestClientAuth(unittest.TestCase): ) ], ) + responses.post( + url=urljoin(API_ENDPOINT, "domain/updateNs/example.com"), + json={"status": "SUCCESS"}, + match=[ + matchers.json_params_matcher( + { + "apikey": "key", + "secretapikey": "secret", + "ns": ["ns1.example.com"], + } + ) + ], + ) with tempfile.TemporaryDirectory() as temp_dir: filename = Path(temp_dir, "records.bind") @@ -1015,7 +1028,8 @@ class TestClientAuth(unittest.TestCase): "$TTL 1234\n" "@ IN SOA dns.example.com. dns2.example.com. (100 300 100 6000 600)\n" "example.com. IN 600 A 127.0.0.3\n" - "sub.example.com. 600 IN A 127.0.0.4" + "sub.example.com. 600 IN A 127.0.0.4\n" + "example.com IN 86400 NS ns1.example.com." ) ) diff --git a/tests/data/test.bind b/tests/data/test.bind index b99dcf4..4f04129 100644 --- a/tests/data/test.bind +++ b/tests/data/test.bind @@ -2,9 +2,11 @@ $ORIGIN test.com. $TTL 1234 @ IN SOA dns.example.com. dns2.example.com. (100 300 100 6000 600) test.com. IN 600 A 1.2.3.4 -test.com. HS 600 A 1.2.3.4 -sub.test.com. 600 IN A 4.3.2.1 -@ IN 600 AAAA 2001:db8::1 ; This is a comment +test.com. IN 600 A 1.2.3.5 ; This is a comment +test.com. HS 600 A "1.2.3.4" +sub.test.com. 600 IN A "4.3.2.1" +@ IN 600 AAAA "2001:db8::1" ; This is a comment -test.com. IN TXT pkb-client -test.com. 600 IN MX 10 mail.test.com. +test.com. IN TXT "pkb-client" +test.com. 600 IN MX 10 "mail.test.com." +test.com. 600 IN TXT "test;test2" ; This is a comment diff --git a/tests/data/test_no_ttl.bind b/tests/data/test_no_ttl.bind index 7dac0ff..52e9b0f 100644 --- a/tests/data/test_no_ttl.bind +++ b/tests/data/test_no_ttl.bind @@ -1,9 +1,11 @@ $ORIGIN test.com. @ IN SOA dns.example.com. dns2.example.com. (100 300 100 6000 600) test.com. IN 600 A 1.2.3.4 -test.com. HS 600 A 1.2.3.4 -sub.test.com. 600 IN A 4.3.2.1 -@ IN 700 AAAA 2001:db8::1 ; This is a comment +test.com. IN 600 A 1.2.3.5 ; This is a comment +test.com. HS 600 A "1.2.3.4" +sub.test.com. 600 IN A "4.3.2.1" +@ IN 700 AAAA "2001:db8::1" ; This is a comment -test.com. IN TXT pkb-client -test.com. 600 IN MX 10 mail.test.com. +test.com. IN TXT "pkb-client" +test.com. 600 IN MX 10 "mail.test.com." +test.com. 600 IN TXT "test;test2" ; This is a comment |
