From: Christian Hofstaedtler Date: Mon, 3 Oct 2016 14:12:48 +0000 (+0200) Subject: API: url in zone info should be absolute X-Git-Tag: auth-4.0.5~1^2~31^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9df0238e1b567cdd7c48185b00160fb952c3e9f4;p=thirdparty%2Fpdns.git API: url in zone info should be absolute Fixes #4524. (cherry picked from commit 16e25450a17bee09f83a6cf7817ebd95e3504c6a) --- diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index ac6ed58d7b..1fc3165fcc 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -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) }, diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index 396d26b83b..95e71c4151 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -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'])