Fix for ttl values
Fixing ttl values validation at api level when used during domain and record creation or updation Also contains api test cases for zero ttl values. Partial-Bug: #1220354 Change-Id: I4461ab92d5ff85eec700aca84304b7368847a98f
This commit is contained in:
parent
233726639a
commit
1993c74386
@ -59,7 +59,7 @@ class Domain(base.DictObjectMixin, base.SoftDeleteObjectMixin,
|
||||
'ttl': {
|
||||
'schema': {
|
||||
'type': ['integer', 'null'],
|
||||
'minimum': 0,
|
||||
'minimum': 1,
|
||||
'maximum': 2147483647
|
||||
},
|
||||
},
|
||||
|
@ -112,7 +112,7 @@ class RecordSet(base.DictObjectMixin, base.PersistentObjectMixin,
|
||||
'schema': {
|
||||
'type': ['integer', 'null'],
|
||||
'description': 'Default time to live',
|
||||
'minimum': 0,
|
||||
'minimum': 1,
|
||||
'maximum': 2147483647
|
||||
},
|
||||
},
|
||||
|
@ -32,7 +32,7 @@
|
||||
"ttl": {
|
||||
"type": "integer",
|
||||
"description": "Time to live",
|
||||
"minimum": 0,
|
||||
"minimum": 1,
|
||||
"maximum": 2147483647
|
||||
},
|
||||
"serial": {
|
||||
|
@ -48,7 +48,7 @@
|
||||
"ttl": {
|
||||
"type": ["integer", "null"],
|
||||
"description": "Time to live",
|
||||
"minimum": 0,
|
||||
"minimum": 1,
|
||||
"maximum": 2147483647
|
||||
},
|
||||
"description": {
|
||||
|
@ -87,6 +87,12 @@ class ApiV1DomainsTest(ApiV1Test):
|
||||
fixture['ttl'] = -1
|
||||
self.post('domains', data=fixture, status_code=400)
|
||||
|
||||
def test_create_domain_zero_ttl(self):
|
||||
# Create a domain
|
||||
fixture = self.get_domain_fixture(0)
|
||||
fixture['ttl'] = 0
|
||||
self.post('domains', data=fixture, status_code=400)
|
||||
|
||||
def test_create_domain_invalid_ttl(self):
|
||||
# Create a domain
|
||||
fixture = self.get_domain_fixture(0)
|
||||
@ -278,6 +284,14 @@ class ApiV1DomainsTest(ApiV1Test):
|
||||
|
||||
self.put('domains/%s' % domain['id'], data=data, status_code=400)
|
||||
|
||||
def test_update_domain_zero_ttl(self):
|
||||
# Create a domain
|
||||
domain = self.create_domain()
|
||||
|
||||
data = {'ttl': 0}
|
||||
|
||||
self.put('domains/%s' % domain['id'], data=data, status_code=400)
|
||||
|
||||
@patch.object(central_service.Service, 'update_domain',
|
||||
side_effect=messaging.MessagingTimeout())
|
||||
def test_update_domain_timeout(self, _):
|
||||
|
@ -210,6 +210,20 @@ class ApiV1RecordsTest(ApiV1Test):
|
||||
self.post('domains/%s/records' % self.domain['id'], data=fixture,
|
||||
status_code=400)
|
||||
|
||||
def test_create_record_zero_ttl(self):
|
||||
fixture = self.get_record_fixture(self.recordset['type'])
|
||||
fixture.update({
|
||||
'name': self.recordset['name'],
|
||||
'type': self.recordset['type'],
|
||||
})
|
||||
|
||||
# Set the TTL to a value zero
|
||||
fixture['ttl'] = 0
|
||||
|
||||
# Create a record, Ensuring it Fails with a 400
|
||||
self.post('domains/%s/records' % self.domain['id'], data=fixture,
|
||||
status_code=400)
|
||||
|
||||
def test_create_record_invalid_ttl(self):
|
||||
fixture = self.get_record_fixture(self.recordset['type'])
|
||||
fixture.update({
|
||||
@ -466,6 +480,15 @@ class ApiV1RecordsTest(ApiV1Test):
|
||||
self.put('domains/%s/records/%s' % (self.domain['id'], record['id']),
|
||||
data=data, status_code=400)
|
||||
|
||||
def test_update_record_zero_ttl(self):
|
||||
# Create a record
|
||||
record = self.create_record(self.domain, self.recordset)
|
||||
|
||||
data = {'ttl': 0}
|
||||
|
||||
self.put('domains/%s/records/%s' % (self.domain['id'], record['id']),
|
||||
data=data, status_code=400)
|
||||
|
||||
def test_update_record_invalid_ttl(self):
|
||||
# Create a record
|
||||
record = self.create_record(self.domain, self.recordset)
|
||||
|
Loading…
Reference in New Issue
Block a user