Merge "Fix for ttl values"

This commit is contained in:
Jenkins 2015-07-09 11:21:37 +00:00 committed by Gerrit Code Review
commit 1d9dbbd273
6 changed files with 42 additions and 5 deletions

View File

@ -59,7 +59,7 @@ class Domain(base.DictObjectMixin, base.SoftDeleteObjectMixin,
'ttl': {
'schema': {
'type': ['integer', 'null'],
'minimum': 0,
'minimum': 1,
'maximum': 2147483647
},
},

View File

@ -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
},
},

View File

@ -32,7 +32,7 @@
"ttl": {
"type": "integer",
"description": "Time to live",
"minimum": 0,
"minimum": 1,
"maximum": 2147483647
},
"serial": {

View File

@ -48,7 +48,7 @@
"ttl": {
"type": ["integer", "null"],
"description": "Time to live",
"minimum": 0,
"minimum": 1,
"maximum": 2147483647
},
"description": {

View File

@ -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, _):

View File

@ -96,7 +96,7 @@ class ApiV1RecordsTest(ApiV1Test):
# Get the record 2 to ensure recordset did not get deleted
rec_2_get_response = self.get('domains/%s/records/%s' %
(self.domain['id'], record_2.json['id']))
(self.domain['id'], record_2.json['id']))
self.assertIn('id', rec_2_get_response.json)
self.assertIn('name', rec_2_get_response.json)
@ -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)