]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
API: url in zone info should be absolute 4526/head
authorChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Mon, 3 Oct 2016 14:12:48 +0000 (16:12 +0200)
committerChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Mon, 3 Oct 2016 14:12:54 +0000 (16:12 +0200)
Fixes #4524.

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

index 2960be0563dddb4c9f72aaa3ea10e5c6ec3a9919..db875b101030dfd043ef5a4d78718f3a5df1865f 100644 (file)
@@ -308,7 +308,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 45efc0464a3747bfec559a157175818b34bd7e3c..03f7bbc726be4042f8b278f2d3d3e45143ed922b 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_zone_metadata(self):
         payload_metadata = {"type": "Metadata", "kind": "AXFR-SOURCE", "metadata": ["127.0.0.2"]}
         r = self.session.post(self.url("/api/v1/servers/localhost/zones/example.com/metadata"),