From c7b3a526bec537805a25e67f9904def02473822d Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Tue, 24 Jan 2017 11:13:19 +0100 Subject: [PATCH] Backport #4781: API: correctly take TTL from first record even if we are at the last comment Cherry picked from master 50d739d0ae978b8b0b737b079992744ff8aa126d --- pdns/ws-auth.cc | 2 +- regression-tests.api/test_Zones.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index a8201d31d4..9562490410 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -384,7 +384,7 @@ static void fillZone(const DNSName& zonename, HttpResponse* resp) { auto cit = comments.begin(); while (rit != records.end() || cit != comments.end()) { - if (cit == comments.end() || (rit != records.end() && (cit->qname.toString() < rit->qname.toString() || cit->qtype < rit->qtype))) { + if (cit == comments.end() || (rit != records.end() && (cit->qname.toString() <= rit->qname.toString() || cit->qtype < rit->qtype || cit->qtype == rit->qtype))) { current_qname = rit->qname; current_qtype = rit->qtype; ttl = rit->ttl; diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index 958e192e3c..396d26b83b 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -886,6 +886,8 @@ fred IN A 192.168.0.4 self.assertNotEquals(serverset['comments'], []) # verify that modified_at has been set by pdns self.assertNotEquals([c for c in serverset['comments']][0]['modified_at'], 0) + # verify that TTL is correct (regression test) + self.assertEquals(serverset['ttl'], 3600) def test_zone_comment_delete(self): # Test: Delete ONLY comments. -- 2.47.2