Add functional tests for wildcard records
Change-Id: I45b65b7f842e2bc5dc3a8bf2129b1b647ffd5cfa
This commit is contained in:
parent
3313171fb2
commit
31d8145762
@ -24,6 +24,50 @@ from functionaltests.api.v2.clients.recordset_client import RecordsetClient
|
||||
from functionaltests.api.v2.clients.zone_client import ZoneClient
|
||||
|
||||
|
||||
RECORDSETS_DATASET = {
|
||||
'A': dict(
|
||||
make_recordset=lambda z: datagen.random_a_recordset(z.name)),
|
||||
'AAAA': dict(
|
||||
make_recordset=lambda z: datagen.random_aaaa_recordset(z.name)),
|
||||
'CNAME': dict(
|
||||
make_recordset=lambda z: datagen.random_cname_recordset(z.name)),
|
||||
'MX': dict(
|
||||
make_recordset=lambda z: datagen.random_mx_recordset(z.name)),
|
||||
'SPF': dict(
|
||||
make_recordset=lambda z: datagen.random_spf_recordset(z.name)),
|
||||
'SRV': dict(
|
||||
make_recordset=lambda z: datagen.random_srv_recordset(z.name)),
|
||||
'SSHFP': dict(
|
||||
make_recordset=lambda z: datagen.random_sshfp_recordset(z.name)),
|
||||
'TXT': dict(
|
||||
make_recordset=lambda z: datagen.random_txt_recordset(z.name)),
|
||||
}
|
||||
|
||||
WILDCARD_RECORDSETS_DATASET = {
|
||||
'wildcard_A': dict(make_recordset=lambda z:
|
||||
datagen.random_a_recordset(zone_name=z.name,
|
||||
name="*.{0}".format(z.name))),
|
||||
'wildcard_AAAA': dict(make_recordset=lambda z:
|
||||
datagen.random_aaaa_recordset(zone_name=z.name,
|
||||
name="*.{0}".format(z.name))),
|
||||
'wildcard_CNAME': dict(make_recordset=lambda z:
|
||||
datagen.random_cname_recordset(zone_name=z.name,
|
||||
name="*.{0}".format(z.name))),
|
||||
'wildcard_MX': dict(make_recordset=lambda z:
|
||||
datagen.random_mx_recordset(zone_name=z.name,
|
||||
name="*.{0}".format(z.name))),
|
||||
'wildcard_SPF': dict(make_recordset=lambda z:
|
||||
datagen.random_spf_recordset(zone_name=z.name,
|
||||
name="*.{0}".format(z.name))),
|
||||
'wildcard_SSHFP': dict(make_recordset=lambda z:
|
||||
datagen.random_sshfp_recordset(zone_name=z.name,
|
||||
name="*.{0}".format(z.name))),
|
||||
'wildcard_TXT': dict(make_recordset=lambda z:
|
||||
datagen.random_txt_recordset(zone_name=z.name,
|
||||
name="*.{0}".format(z.name))),
|
||||
}
|
||||
|
||||
|
||||
@utils.parameterized_class
|
||||
class RecordsetTest(DesignateV2Test):
|
||||
|
||||
@ -62,25 +106,9 @@ class RecordsetTest(DesignateV2Test):
|
||||
|
||||
self.assertEqual(model_data, data)
|
||||
|
||||
@utils.parameterized({
|
||||
'A': dict(
|
||||
make_recordset=lambda z: datagen.random_a_recordset(z.name)),
|
||||
'AAAA': dict(
|
||||
make_recordset=lambda z: datagen.random_aaaa_recordset(z.name)),
|
||||
'CNAME': dict(
|
||||
make_recordset=lambda z: datagen.random_cname_recordset(z.name)),
|
||||
'MX': dict(
|
||||
make_recordset=lambda z: datagen.random_mx_recordset(z.name)),
|
||||
'SPF': dict(
|
||||
make_recordset=lambda z: datagen.random_spf_recordset(z.name)),
|
||||
'SRV': dict(
|
||||
make_recordset=lambda z: datagen.random_srv_recordset(z.name)),
|
||||
'SSHFP': dict(
|
||||
make_recordset=lambda z: datagen.random_sshfp_recordset(z.name)),
|
||||
'TXT': dict(
|
||||
make_recordset=lambda z: datagen.random_txt_recordset(z.name)),
|
||||
|
||||
})
|
||||
@utils.parameterized(
|
||||
dict(RECORDSETS_DATASET.items() + WILDCARD_RECORDSETS_DATASET.items())
|
||||
)
|
||||
def test_crud_recordset(self, make_recordset):
|
||||
post_model = make_recordset(self.zone)
|
||||
|
||||
@ -120,24 +148,7 @@ class RecordsetTest(DesignateV2Test):
|
||||
RecordsetClient.as_user('default').wait_for_404(
|
||||
self.zone.id, recordset_id)
|
||||
|
||||
@utils.parameterized({
|
||||
'A': dict(
|
||||
make_recordset=lambda z: datagen.random_a_recordset(z.name)),
|
||||
'AAAA': dict(
|
||||
make_recordset=lambda z: datagen.random_aaaa_recordset(z.name)),
|
||||
'CNAME': dict(
|
||||
make_recordset=lambda z: datagen.random_cname_recordset(z.name)),
|
||||
'MX': dict(
|
||||
make_recordset=lambda z: datagen.random_mx_recordset(z.name)),
|
||||
'SPF': dict(
|
||||
make_recordset=lambda z: datagen.random_spf_recordset(z.name)),
|
||||
'SRV': dict(
|
||||
make_recordset=lambda z: datagen.random_srv_recordset(z.name)),
|
||||
'SSHFP': dict(
|
||||
make_recordset=lambda z: datagen.random_sshfp_recordset(z.name)),
|
||||
'TXT': dict(
|
||||
make_recordset=lambda z: datagen.random_txt_recordset(z.name)),
|
||||
})
|
||||
@utils.parameterized(RECORDSETS_DATASET)
|
||||
def test_create_invalid(self, make_recordset, data=None):
|
||||
data = data or ["b0rk"]
|
||||
|
||||
@ -150,24 +161,7 @@ class RecordsetTest(DesignateV2Test):
|
||||
exceptions.BadRequest, 'invalid_object', 400,
|
||||
client.post_recordset, self.zone.id, model)
|
||||
|
||||
@utils.parameterized({
|
||||
'A': dict(
|
||||
make_recordset=lambda z: datagen.random_a_recordset(z.name)),
|
||||
'AAAA': dict(
|
||||
make_recordset=lambda z: datagen.random_aaaa_recordset(z.name)),
|
||||
'CNAME': dict(
|
||||
make_recordset=lambda z: datagen.random_cname_recordset(z.name)),
|
||||
'MX': dict(
|
||||
make_recordset=lambda z: datagen.random_mx_recordset(z.name)),
|
||||
'SPF': dict(
|
||||
make_recordset=lambda z: datagen.random_spf_recordset(z.name)),
|
||||
'SRV': dict(
|
||||
make_recordset=lambda z: datagen.random_srv_recordset(z.name)),
|
||||
'SSHFP': dict(
|
||||
make_recordset=lambda z: datagen.random_sshfp_recordset(z.name)),
|
||||
'TXT': dict(
|
||||
make_recordset=lambda z: datagen.random_txt_recordset(z.name)),
|
||||
})
|
||||
@utils.parameterized(RECORDSETS_DATASET)
|
||||
def test_update_invalid(self, make_recordset, data=None):
|
||||
data = data or ["b0rk"]
|
||||
|
||||
|
@ -184,9 +184,9 @@ def random_zonefile_data(name=None, ttl=None):
|
||||
return zone_base.replace('&', name).replace('#', ttl)
|
||||
|
||||
|
||||
def random_spf_recordset(zone_name, data=None):
|
||||
def random_spf_recordset(zone_name, data=None, **kwargs):
|
||||
data = data or "v=spf1 +all"
|
||||
return random_recordset_data('SPF', zone_name, records=[data])
|
||||
return random_recordset_data('SPF', zone_name, records=[data], **kwargs)
|
||||
|
||||
|
||||
def random_srv_recordset(zone_name, data=None):
|
||||
@ -197,16 +197,17 @@ def random_srv_recordset(zone_name, data=None):
|
||||
|
||||
|
||||
def random_sshfp_recordset(zone_name, algorithm_number=None,
|
||||
fingerprint_type=None, fingerprint=None):
|
||||
fingerprint_type=None, fingerprint=None,
|
||||
**kwargs):
|
||||
algorithm_number = algorithm_number or 2
|
||||
fingerprint_type = fingerprint_type or 1
|
||||
fingerprint = fingerprint or \
|
||||
"123456789abcdef67890123456789abcdef67890"
|
||||
|
||||
data = "%s %s %s" % (algorithm_number, fingerprint_type, fingerprint)
|
||||
return random_recordset_data('SSHFP', zone_name, records=[data])
|
||||
return random_recordset_data('SSHFP', zone_name, records=[data], **kwargs)
|
||||
|
||||
|
||||
def random_txt_recordset(zone_name, data=None):
|
||||
def random_txt_recordset(zone_name, data=None, **kwargs):
|
||||
data = data or "v=spf1 +all"
|
||||
return random_recordset_data('TXT', zone_name, records=[data])
|
||||
return random_recordset_data('TXT', zone_name, records=[data], **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user