diff options
author | dekehn <dekehn@gmail.com> | 2022-05-02 23:03:49 +0000 |
---|---|---|
committer | Don Kehn <dekehn@gmail.com> | 2022-05-31 23:03:47 +0000 |
commit | 264ac571d5ccb484e8071d2bec575992296dfb2a (patch) | |
tree | c72f199aef63143dd6717b3c2631630d82a454e5 | |
parent | c78db47c746cab2fc505bd60f11f05a08eb94120 (diff) | |
download | designate-264ac571d5ccb484e8071d2bec575992296dfb2a.tar.gz |
Minimum TTL value allowed is zero
According to ITEF https://tools.ietf.org/html/rfc2181#section-8
the definition of the ttl value is unsigned integer and can have a
minimum value of 0. This patch changes the minimum value of 1 to allow
for 0. Unit test have also been modified accordingly.
Closes-Bug: #1926429
Change-Id: I7876b4c1e2c800b654ca750211ee2e58f3ea4309
(cherry picked from commit 6ac659d241c65c245d8a090768ac7559c32a13f1)
4 files changed, 15 insertions, 7 deletions
diff --git a/designate/objects/zone.py b/designate/objects/zone.py index 3b9e54dc..45fa2a11 100644 --- a/designate/objects/zone.py +++ b/designate/objects/zone.py @@ -31,7 +31,7 @@ class Zone(base.DesignateObject, base.DictObjectMixin, 'tenant_id': fields.StringFields(nullable=True, read_only=False), 'name': fields.DomainField(maxLength=255), 'email': fields.EmailField(maxLength=255, nullable=True), - 'ttl': fields.IntegerFields(nullable=True, minimum=1, + 'ttl': fields.IntegerFields(nullable=True, minimum=0, maximum=2147483647), 'refresh': fields.IntegerFields(nullable=True, minimum=0, maximum=2147483647, read_only=False), diff --git a/designate/tests/test_api/test_v2/test_zones.py b/designate/tests/test_api/test_v2/test_zones.py index e9d1c386..e3c4f881 100644 --- a/designate/tests/test_api/test_v2/test_zones.py +++ b/designate/tests/test_api/test_v2/test_zones.py @@ -139,8 +139,8 @@ class ApiV2ZonesTest(ApiV2TestCase): fixture = self.get_zone_fixture(fixture=0) fixture['ttl'] = 0 body = fixture - self._assert_exception('invalid_object', 400, self.client.post_json, - '/zones', body) + response = self.client.post_json('/zones', body) + self.assertEqual(202, response.status_int) def test_create_zone_ttl_is_greater_than_max(self): fixture = self.get_zone_fixture(fixture=0) diff --git a/designate/tests/test_central/test_service.py b/designate/tests/test_central/test_service.py index 2c6f8cf5..37e2a8d0 100644 --- a/designate/tests/test_central/test_service.py +++ b/designate/tests/test_central/test_service.py @@ -715,18 +715,18 @@ class CentralServiceTest(CentralTestCase): self.policy({'use_low_ttl': '!'}) self.config(min_ttl=100, group='service:central') - context = self.get_context() + context = self.get_context(project_id=1) values = self.get_zone_fixture(fixture=1) - values['ttl'] = 0 + values['ttl'] = 5 - with testtools.ExpectedException(ValueError): + with testtools.ExpectedException(exceptions.InvalidTTL): self.central_service.create_zone( context, objects.Zone.from_dict(values)) def test_create_zone_below_zero_ttl(self): self.policy({'use_low_ttl': '!'}) - self.config(min_ttl=1, + self.config(min_ttl=0, group='service:central') context = self.get_context() diff --git a/releasenotes/notes/bug-1926429-allow-ttl-min-of-zero-688f7c2cf095d89d.yaml b/releasenotes/notes/bug-1926429-allow-ttl-min-of-zero-688f7c2cf095d89d.yaml new file mode 100644 index 00000000..fc157bde --- /dev/null +++ b/releasenotes/notes/bug-1926429-allow-ttl-min-of-zero-688f7c2cf095d89d.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Allows for a minimum TTL value of zero to be used instead of 1. As stated + in RFC https://datatracker.ietf.org/doc/html/rfc2181#section-8. + + .. _bug 1926429: https://bugs.launchpad.net/designate/+bug/1926429 + |