]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
API: url in zone info should be absolute
authorChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Mon, 3 Oct 2016 14:12:48 +0000 (16:12 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Tue, 7 Nov 2017 20:24:53 +0000 (21:24 +0100)
Fixes #4524.

(cherry picked from commit 16e25450a17bee09f83a6cf7817ebd95e3504c6a)

pdns/ws-auth.cc
regression-tests.api/test_Zones.py

index ac6ed58d7b8416472efd693f7bfc66d901605f61..1fc3165fccc8d90c1aed2e69442bd8a313637aa0 100644 (file)
@@ -311,7 +311,7 @@ static Json::object getZoneInfo(const DomainInfo& di) {
   return Json::object {
     // id is the canonical lookup key, which doesn't actually match the name (in some cases)
     { "id", zoneId },
-    { "url", "api/v1/servers/localhost/zones/" + zoneId },
+    { "url", "/api/v1/servers/localhost/zones/" + zoneId },
     { "name", di.zone.toString() },
     { "kind", di.getKindString() },
     { "dnssec", dk.isSecuredZone(di.zone) },
index 396d26b83b9d83a7becf31c11694182be1ea80b3..95e71c4151e0507d4d5a95eac5dbec1fc9f62c20 100644 (file)
@@ -286,6 +286,13 @@ class AuthZones(ApiTestCase, AuthZonesHelperMixin):
             headers={'content-type': 'application/json'})
         self.assertEquals(r.status_code, 422)
 
+    def test_zone_absolute_url(self):
+        name, payload, data = self.create_zone()
+        r = self.session.get(self.url("/api/v1/servers/localhost/zones"))
+        rdata = r.json()
+        print(rdata[0])
+        self.assertTrue(rdata[0]['url'].startswith('/api/v'))
+
     def test_create_slave_zone(self):
         # Test that nameservers can be absent for slave zones.
         name, payload, data = self.create_zone(kind='Slave', nameservers=None, masters=['127.0.0.2'])