def post_data(self): return { 'server': 'g' + random_label(), 'comment': random_label(), 'ttl': random_byte(), 'domain': self.domain.name, }
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': 'p' + random_label(), 'iname': 'mgmt4', 'dhcp_enabled': True, 'dns_enabled': True, 'mac': '11:22:33:44:55:00', 'system': '/tasty/systems/system/{0}/'.format(self.s.pk), 'domain': self.domain.name, 'ip_str': "2000:a{0}:a{1}:a{2}::".format(random_byte(), random_byte(), random_byte()), 'ip_type': '6' }
def post_data(self): return { 'description': random_label(), 'ttl': random_byte(), 'fqdn': 'f' + random_label() + "." + self.domain.name, 'txt_data': random_label() }
def post_data(self): return { # We are f*****g this up on purpose. 'fuckinup': random_label(), 'fqdn': "c{0}.{1}.{2)}".format(random_label(), random_label(), self.domain.name), }
def test_SRV(self): data = {'rtype': 'SRV'} data.update({'target': random_label()}) data.update(self.craft_label_domain()) data['label'] = "_" + random_label() data.update(self.craft_ttl_and_description()) data.update(self.craft_number_dict('priority')) data.update(self.craft_number_dict('weight')) data.update(self.craft_number_dict('port')) data.update(self.craft_name_dict('target')) request = FakeRequest(json.dumps(data)) response = commit_record(request) self.assertFalse('errors' in response.content) self.assertTrue(response.status_code, 200) content = json.loads(response.content) self.validate_return_object(content['obj_class'], content['obj_pk'], data) # Now do an update orig_obj_pk = content['obj_pk'] data['pk'] = orig_obj_pk data.update(self.craft_label_domain()) data['label'] = "_" + random_label() request = FakeRequest(json.dumps(data)) response = commit_record(request) self.validate_return_object(content['obj_class'], content['obj_pk'], data) self.assertEqual(orig_obj_pk, content['obj_pk'])
def test_SRV(self): data = {'rtype': 'SRV'} data.update({'target': random_label()}) data.update(self.craft_label_domain()) data['label'] = "_" + random_label() data.update(self.craft_ttl_and_comment()) data.update(self.craft_number_dict('priority')) data.update(self.craft_number_dict('weight')) data.update(self.craft_number_dict('port')) data.update(self.craft_name_dict('target')) request = FakeRequest(json.dumps(data)) response = commit_record(request) self.assertFalse('errors' in response.content) self.assertTrue(response.status_code, 200) content = json.loads(response.content) self.validate_return_object(content['obj_class'], content['obj_pk'], data) # Now do an update orig_obj_pk = content['obj_pk'] data['pk'] = orig_obj_pk data.update(self.craft_label_domain()) data['label'] = "_" + random_label() request = FakeRequest(json.dumps(data)) response = commit_record(request) self.validate_return_object(content['obj_class'], content['obj_pk'], data) self.assertEqual(orig_obj_pk, content['obj_pk'])
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'ip_str': "11.{0}.{1}.{2}".format(random_byte(), random_byte(), random_byte()), 'ip_type': '4', 'name': random_label() }
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': 'f' + random_label(), 'domain': self.domain.name, 'txt_data': random_label() }
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': 'i' + random_label(), 'domain': self.domain.name, 'ip_str': "11.{0}.{1}.{2}".format(random_byte(), random_byte(), random_byte()), 'ip_type': '4' }
def post_data(self): return { # We are f*****g this up on purpose. 'fuckinup': random_label(), 'fqdn': 'c' + random_label() + '.' + random_label() + '.' + self.domain.name, }
def post_data(self): return { 'description': random_label(), 'ttl': random_byte(), 'ip_str': "11.{0}.{1}.{2}".format( random_byte(), random_byte(), random_byte()), 'ip_type': '4', 'name': random_label() }
def post_data(self): return { 'description': random_label(), 'ttl': random_byte(), 'fqdn': 'j' + random_label() + "." + self.domain.name, 'ip_str': "1000:{0}:{1}:{2}::".format(random_byte(), random_byte(), random_byte()), 'ip_type': '6' }
def post_data(self): return { 'description': random_label(), 'ttl': random_byte(), 'fqdn': 'i' + random_label() + "." + self.domain.name, 'ip_str': "11.{0}.{1}.{2}".format( random_byte(), random_byte(), random_byte()), 'ip_type': '4' }
def post_data(self): return { 'description': random_label(), 'ttl': random_byte(), 'fqdn': 'h' + random_label() + "." + self.domain.name, 'algorithm_number': 1, 'fingerprint_type': 1, 'key': random_label() }
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': random_label(), 'domain': self.domain.name, 'ip_str': "11.{0}.{1}.{2}".format(random_byte(), random_byte(), random_byte()), 'ip_type': '4' }
def post_data(self): return { 'description': random_label(), 'ttl': random_byte(), 'fqdn': 'e' + random_label() + "." + self.domain.name, 'server': random_label(), 'priority': 123, 'ttl': 213 }
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': random_label(), 'domain': self.domain.name, 'ip_str': "1000:{0}:{1}:{2}::".format(random_byte(), random_byte(), random_byte()), 'ip_type': '6' }
def post_data(self): return { 'description': 'k' + random_label(), 'ttl': random_byte(), 'ip_str': "1000:{0}:{1}:{2}:{3}:{4}::".format( random_byte(), random_byte(), random_byte(), random_byte(), random_byte()), 'ip_type': '6', 'name': random_label() }
def post_data(self): return { 'description': random_label(), 'ttl': random_byte(), 'fqdn': "_" + random_label() + "." + self.domain.name, 'target': random_label(), 'priority': 2, 'weight': 2222, 'port': 222 }
def build_sample_domain(): domain_name = '' for i in range(2): domain_name = random_label() domain = Domain(name=domain_name) soa = SOA(primary=random_label(), contact="asf", comment=random_label()) soa.save() domain.soa = soa domain.save() return domain
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': 'j' + random_label(), 'domain': self.domain.name, 'ip_str': "1000:{0}:{1}:{2}::".format(random_byte(), random_byte(), random_byte()), 'ip_type': '6' }
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': 'h' + random_label(), 'domain': self.domain.name, 'algorithm_number': 1, 'fingerprint_type': 1, 'key': random_label() }
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': 'e' + random_label(), 'domain': self.domain.name, 'server': random_label(), 'priority': 123, 'ttl': 213 }
def post_data(self): return { 'comment': random_label(), 'ttl': random_byte(), 'label': "_" + random_label(), 'domain': self.domain.name, 'target': random_label(), 'priority': 2, 'weight': 2222, 'port': 222 }
def test_fqdn_create(self): obj_data = self.post_data() label = obj_data.pop('label') domain = random_label() + '.' + str(self.test_type.__name__) + '.' + random_label() + '.' + random_label() + '.' + obj_data.pop('domain') obj_data['fqdn'] = label + '.' + domain resp, post_data = self.generic_create(obj_data) _, (_, new_object_url) = resp.items() new_resp = self.api_client.get(new_object_url, format='json') self.assertValidJSONResponse(new_resp) new_obj_data = json.loads(new_resp.content) self.assertEqual(label, new_obj_data['label']) self.assertEqual(domain, new_obj_data['domain'])
def post_data(self): return { 'comment': 'm' + random_label(), 'ttl': random_byte(), 'mac': '11:22:33:44:55:00', 'system': '/tasty/systems/system/{0}/'.format(self.s.pk), 'label': 'a' + random_label(), 'iname': 'eth2.4', 'dhcp_enabled': False, 'dns_enabled': True, 'domain': self.domain.name, 'ip_str': "11.255.{0}.{1}".format(random_byte(), random_byte()), 'ip_type': '4' }
def test_fqdn_create(self): obj_data = self.post_data() label = obj_data.pop('label') domain = random_label() + '.' + str( self.test_type.__name__) + '.' + random_label( ) + '.' + random_label() + '.' + obj_data.pop('domain') obj_data['fqdn'] = label + '.' + domain resp, post_data = self.generic_create(obj_data) _, (_, new_object_url) = resp.items() new_resp = self.api_client.get(new_object_url, format='json') self.assertValidJSONResponse(new_resp) new_obj_data = json.loads(new_resp.content) self.assertEqual(label, new_obj_data['label']) self.assertEqual(domain, new_obj_data['domain'])
def test_PTR(self): data = {'rtype': 'PTR'} data.update({'name': random_label()}) data.update(self.craft_ip_str()) data.update(self.craft_ttl_and_comment()) request = FakeRequest(json.dumps(data)) response = commit_record(request) self.assertFalse('errors' in response.content) self.assertTrue(response.status_code, 200) content = json.loads(response.content) self.validate_return_object(content['obj_class'], content['obj_pk'], data) # Now do an update orig_obj_pk = content['obj_pk'] data['pk'] = orig_obj_pk data.update(self.craft_ip_str()) request = FakeRequest(json.dumps(data)) response = commit_record(request) self.validate_return_object(content['obj_class'], content['obj_pk'], data) self.assertEqual(orig_obj_pk, content['obj_pk'])
def test_PTR(self): data = {'rtype': 'PTR'} data.update({'name': random_label()}) data.update(self.craft_ip_str()) data.update(self.craft_ttl_and_description()) request = FakeRequest(json.dumps(data)) response = commit_record(request) self.assertFalse('errors' in response.content) self.assertTrue(response.status_code, 200) content = json.loads(response.content) self.validate_return_object(content['obj_class'], content['obj_pk'], data) # Now do an update orig_obj_pk = content['obj_pk'] data['pk'] = orig_obj_pk data.update(self.craft_ip_str()) request = FakeRequest(json.dumps(data)) response = commit_record(request) self.validate_return_object(content['obj_class'], content['obj_pk'], data) self.assertEqual(orig_obj_pk, content['obj_pk'])
def craft_ttl_and_description(self): data = { 'ttl': random_byte(), 'description': random_label() } return data
def craft_name_dict(self, field): data = {field: random_label() + "." + random_label()} return data
def craft_label_domain(self): data = { 'label': random_label(), 'domain': self.d.name } return data
def craft_label_domain(self): data = {'label': random_label(), 'domain': self.d.name} return data
def craft_ttl_and_comment(self): data = { 'ttl': random_byte(), 'comment': random_label() } return data
def craft_ttl_and_description(self): data = {'ttl': random_byte(), 'description': random_label()} return data
def post_data(self): return { 'key': random_label(), 'value': random_label(), }