def test_exampleNameserver(self): answer = \ """{ "handle" : "XXXX", "name" : "ns1.example.com", "status" : [ "active" ], "ipAddresses" : [ "192.0.2.1", "192.0.2.2" ], "remarks" : [ "she sells seas shells", "down by the seashore" ], "links" : [ { "value" : "http://example.net/nameserver/xxxx", "rel" : "self", "href" : "http://example.net/nameserver/xxxx" } ], "port43" : "whois.example.net", "registrationDate" : "1990-12-31T23:59:60Z", "registrationBy" : "ABC123", "lastChangedDate" : "1990-12-31T23:59:60Z", "lastChangedBy" : "ABC123", "sponsoredBy" : "SponsorXYZ", "resoldBy" : "ResellerPDQ" } """ reslt = objects.nameserver( 'XXXX', 'ns1.example.com', 'active', ['192.0.2.1', '192.0.2.2'], ['she sells seas shells', 'down by the seashore'], {'value': 'http://example.net/nameserver/xxxx', 'rel': 'self', 'href': 'http://example.net/nameserver/xxxx'}, port43='whois.example.net', registrationDate='1990-12-31T23:59:60Z', registrationBy='ABC123', lastChangedDate='1990-12-31T23:59:60Z', lastChangedBy='ABC123', sponsoredBy='SponsorXYZ', resoldBy='ResellerPDQ', ) self.assertJSON(reslt, answer)
def test_rirDomain(self): answer = \ """{ "handle" : "XXXX", "name" : "192.in-addr.arpa", "nameServers" : [ { "name" : "ns1.rir.net" }, { "name" : "ns2.rir.net" } ], "delegationKeys" : [ { "algorithm": 7, "digest" : "E68C017BD813B9AE2F4DD28E61AD014F859ED44C", "digestType" : 1, "keyTag" : 53814 }], "remarks" : [ "she sells seas shells", "down by the seashore" ], "links" : [ { "value": "http://example.net/domain/XXXX", "rel" : "self", "href" : "http://example.net/domain/XXXX" } ], "registrationDate" : "1990-12-31T23:59:60Z", "lastChangedDate" : "1990-12-31T23:59:60Z", "lastChangedBy" : "*****@*****.**", "entities" : [ { "handle" : "XXXX", "entityNames": [ "Joe Bob, Inc.", "Bobby Joe Shopping" ], "roles" : [ "registrant" ], "postalAddress" : ["123 Maple Ave", "Suite 90001", "Vancouver", "BC", "12393" ], "emails" : [ "*****@*****.**", "*****@*****.**" ], "phones" : { "office" : [ "1-958-555-4321", "1-958-555-4322" ], "fax" : [ "1-958-555-4323" ], "mobile" : [ "1-958-555-4324" ] }, "remarks" : [ "she sells seas shells", "down by the seashore" ], "links" : [ { "value": "http://example.net/entity/xxxx", "rel" : "self", "href" : "http://example.net/entity/xxxx" } ], "registrationDate" : "1990-12-31T23:59:60Z", "lastChangedDate" : "1990-12-31T23:59:60Z", "lastChangedBy" : "*****@*****.**" } ] } """ reslt = objects.domain('XXXX', '192.in-addr.arpa', None, None, [objects.nameserver(None, 'ns1.rir.net'), objects.nameserver(None, 'ns2.rir.net')], objects.entity('XXXX', ['Joe Bob, Inc.', 'Bobby Joe Shopping'], None, 'registrant', ['123 Maple Ave', 'Suite 90001', 'Vancouver', 'BC', '12393'], ['*****@*****.**', '*****@*****.**'], {'office': ['1-958-555-4321', '1-958-555-4322'], 'fax': ['1-958-555-4323'], 'mobile': ['1-958-555-4324']}, ['she sells seas shells', 'down by the seashore'], objects.link("http://example.net/entity/xxxx", "self"), registrationDate= "1990-12-31T23:59:60Z", lastChangedDate= "1990-12-31T23:59:60Z", lastChangedBy= "*****@*****.**" ), objects.delegationKey(7, 'E68C017BD813B9AE2F4DD28E61AD014F859ED44C', 1, 53814), ['she sells seas shells', 'down by the seashore'], objects.link('http://example.net/domain/XXXX', 'self'), registrationDate='1990-12-31T23:59:60Z', lastChangedDate='1990-12-31T23:59:60Z', lastChangedBy='*****@*****.**') self.assertJSON(reslt, answer) ## TODO: more tests from RFC when one is published
def test_simpleNameserver(self): self.assertJSON(objects.nameserver(None, 'ns1.example.com', None, ['2001:db8::123', '2001:db8::124']), '{"name": "ns1.example.com", "ipAddresses":[ "2001:db8::123", "2001:db8::124" ]}')
def test_nameonlyNameserver(self): self.assertJSON(objects.nameserver(None, 'ns1.example.com'), '{"name":"ns1.example.com"}')