Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 2ff132d

Browse files
committed
test invalid dns records
1 parent 26a90c3 commit 2ff132d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CloudFlare/tests/test_dns_records.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ def test_dns_records_create_values():
5555
dns_content3 = 'temp pytest element 3'
5656
print('dns_record: %s' % (dns_name), file=sys.stderr)
5757

58+
def test_dns_records_port_invalid():
59+
# create an invalid DNS record - i.e. txt value for A record IP address
60+
dns_record = {'name':dns_name, 'type':'A', 'content':'NOT-A-VALID-IP-ADDRESS'}
61+
try:
62+
dns_result = cf.zones.dns_records.post(zone_id, data=dns_record)
63+
assert False
64+
except CloudFlare.exceptions.CloudFlareAPIError as e:
65+
# more than one error returned by the API - a specific error and a generic error
66+
assert len(e) > 0
67+
for x in e:
68+
print('Error expected: %d %s' % (int(x), str(x)))
69+
print('Error expected: %d %s' % (int(e), str(e)))
70+
assert True
71+
5872
def test_dns_records_get1():
5973
# GET
6074
params = {'name':dns_name + '.' + zone_name, 'match':'all', 'type':dns_type}
@@ -133,6 +147,7 @@ def test_dns_records_get5():
133147
else:
134148
test_find_zone()
135149
test_dns_records_create_values()
150+
test_dns_records_port_invalid()
136151
test_dns_records_get1()
137152
test_dns_records_post()
138153
test_dns_records_get2()

0 commit comments

Comments
 (0)