From 8ffb7a9bab0d6adc4879f9cb1ce73ded65fa92be Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Sat, 7 Feb 2015 15:01:26 +0100 Subject: [PATCH 1/2] API: read and expose domain account field --- docs/markdown/httpapi/api_spec.md | 4 ++++ modules/gmysqlbackend/gmysqlbackend.cc | 4 ++-- modules/gpgsqlbackend/gpgsqlbackend.cc | 4 ++-- modules/gsqlite3backend/gsqlite3backend.cc | 4 ++-- pdns/backends/gsql/gsqlbackend.cc | 10 ++++++---- pdns/dnsbackend.hh | 1 + pdns/ws-auth.cc | 1 + regression-tests.api/test_Zones.py | 2 +- 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/docs/markdown/httpapi/api_spec.md b/docs/markdown/httpapi/api_spec.md index be462982b84c..c33bcb82e5f1 100644 --- a/docs/markdown/httpapi/api_spec.md +++ b/docs/markdown/httpapi/api_spec.md @@ -297,6 +297,7 @@ zone_collection "presigned": , "soa_edit": "", "soa_edit_api": "", + "account": "", "nameservers": ["", ...], "servers": ["", ...], "recursion_desired": , @@ -338,6 +339,9 @@ zone_collection the SOA-EDIT-API rules. (Which are the same as the SOA-EDIT rules.) **Note**: Authoritative only. +* `account` MAY be set. It's value is defined by local policy. + **Note**: Authoritative only. + * `notified_serial`, `serial` MUST NOT be sent in client bodies. **Note**: Authoritative only. diff --git a/modules/gmysqlbackend/gmysqlbackend.cc b/modules/gmysqlbackend/gmysqlbackend.cc index 316e06035386..6320c31705ed 100644 --- a/modules/gmysqlbackend/gmysqlbackend.cc +++ b/modules/gmysqlbackend/gmysqlbackend.cc @@ -66,7 +66,7 @@ class gMySQLFactory : public BackendFactory declare(suffix,"master-zone-query","Data", "select master from domains where name=? and type='SLAVE'"); - declare(suffix,"info-zone-query","","select id,name,master,last_check,notified_serial,type from domains where name=?"); + declare(suffix,"info-zone-query","","select id,name,master,last_check,notified_serial,type,account from domains where name=?"); declare(suffix,"info-all-slaves-query","","select id,name,master,last_check,type from domains where type='SLAVE'"); declare(suffix,"supermaster-query","", "select account from supermasters where ip=? and nameserver=?"); @@ -117,7 +117,7 @@ class gMySQLFactory : public BackendFactory declare(suffix,"delete-tsig-key-query","", "delete from tsigkeys where name=?"); declare(suffix,"get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys"); - declare(suffix, "get-all-domains-query", "Retrieve all domains", "select domains.id, domains.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from domains LEFT JOIN records ON records.domain_id=domains.id AND records.type='SOA' AND records.name=domains.name WHERE records.disabled=0 OR ?"); + declare(suffix, "get-all-domains-query", "Retrieve all domains", "select domains.id, domains.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check, domains.account from domains LEFT JOIN records ON records.domain_id=domains.id AND records.type='SOA' AND records.name=domains.name WHERE records.disabled=0 OR ?"); declare(suffix, "list-comments-query", "", "SELECT domain_id,name,type,modified_at,account,comment FROM comments WHERE domain_id=?"); declare(suffix, "insert-comment-query", "", "INSERT INTO comments (domain_id, name, type, modified_at, account, comment) VALUES (?, ?, ?, ?, ?, ?)"); diff --git a/modules/gpgsqlbackend/gpgsqlbackend.cc b/modules/gpgsqlbackend/gpgsqlbackend.cc index cf3d8c8c4a6b..25d65e8d30f8 100644 --- a/modules/gpgsqlbackend/gpgsqlbackend.cc +++ b/modules/gpgsqlbackend/gpgsqlbackend.cc @@ -60,7 +60,7 @@ class gPgSQLFactory : public BackendFactory declare(suffix,"master-zone-query","Data", "select master from domains where name=$1 and type='SLAVE'"); - declare(suffix,"info-zone-query","","select id,name,master,last_check,notified_serial,type from domains where name=$1"); + declare(suffix,"info-zone-query","","select id,name,master,last_check,notified_serial,type,account from domains where name=$1"); declare(suffix,"info-all-slaves-query","","select id,name,master,last_check,type from domains where type='SLAVE'"); declare(suffix,"supermaster-query","", "select account from supermasters where ip=$1 and nameserver=$2"); @@ -111,7 +111,7 @@ class gPgSQLFactory : public BackendFactory declare(suffix,"delete-tsig-key-query","", "delete from tsigkeys where name=$1"); declare(suffix,"get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys"); - declare(suffix, "get-all-domains-query", "Retrieve all domains", "select domains.id, domains.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from domains LEFT JOIN records ON records.domain_id=domains.id AND records.type='SOA' AND records.name=domains.name WHERE records.disabled=false OR $1"); + declare(suffix, "get-all-domains-query", "Retrieve all domains", "select domains.id, domains.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check, domains.account from domains LEFT JOIN records ON records.domain_id=domains.id AND records.type='SOA' AND records.name=domains.name WHERE records.disabled=false OR $1"); declare(suffix, "list-comments-query", "", "SELECT domain_id,name,type,modified_at,account,comment FROM comments WHERE domain_id=$1"); declare(suffix, "insert-comment-query", "", "INSERT INTO comments (domain_id, name, type, modified_at, account, comment) VALUES ($1, $2, $3, $4, $5, $6)"); diff --git a/modules/gsqlite3backend/gsqlite3backend.cc b/modules/gsqlite3backend/gsqlite3backend.cc index 33aab48314ea..a8bbf231c948 100644 --- a/modules/gsqlite3backend/gsqlite3backend.cc +++ b/modules/gsqlite3backend/gsqlite3backend.cc @@ -77,7 +77,7 @@ class gSQLite3Factory : public BackendFactory declare(suffix, "master-zone-query", "Data", "select master from domains where name=:domain and type='SLAVE'"); - declare(suffix, "info-zone-query", "","select id,name,master,last_check,notified_serial,type from domains where name=:domain"); + declare(suffix, "info-zone-query", "","select id,name,master,last_check,notified_serial,type,account from domains where name=:domain"); declare(suffix, "info-all-slaves-query", "","select id,name,master,last_check,type from domains where type='SLAVE'"); declare(suffix, "supermaster-query", "", "select account from supermasters where ip=:ip and nameserver=:nameserver"); @@ -128,7 +128,7 @@ class gSQLite3Factory : public BackendFactory declare(suffix, "delete-tsig-key-query","", "delete from tsigkeys where name=:key_name"); declare(suffix, "get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys"); - declare(suffix, "get-all-domains-query", "Retrieve all domains", "select domains.id, domains.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check from domains LEFT JOIN records ON records.domain_id=domains.id AND records.type='SOA' AND records.name=domains.name WHERE records.disabled=0 OR :include_disabled"); + declare(suffix, "get-all-domains-query", "Retrieve all domains", "select domains.id, domains.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check, domains.account from domains LEFT JOIN records ON records.domain_id=domains.id AND records.type='SOA' AND records.name=domains.name WHERE records.disabled=0 OR :include_disabled"); declare(suffix, "list-comments-query", "", "SELECT domain_id,name,type,modified_at,account,comment FROM comments WHERE domain_id=:domain_id"); declare(suffix, "insert-comment-query", "", "INSERT INTO comments (domain_id, name, type, modified_at, account, comment) VALUES (:domain_id, :qname, :qtype, :modified_at, :account, :content)"); diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 5c79f4b0e781..c45aa2ac4bdc 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -273,7 +273,7 @@ bool GSQLBackend::setKind(const string &domain, const DomainInfo::DomainKind kin bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di) { /* fill DomainInfo from database info: - id,name,master IP(s),last_check,notified_serial,type */ + id,name,master IP(s),last_check,notified_serial,type,account */ try { d_InfoOfDomainsZoneQuery_stmt-> bind("domain", toLower(domain))-> @@ -295,6 +295,7 @@ bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di) di.last_check=atol(d_result[0][3].c_str()); di.notified_serial = atol(d_result[0][4].c_str()); string type=d_result[0][5]; + di.account=d_result[0][6]; di.backend=this; di.serial = 0; @@ -1153,15 +1154,16 @@ void GSQLBackend::getAllDomains(vector *domains, bool include_disabl if (!row[4].empty()) { stringtok(di.masters, row[4], " ,\t"); } - di.last_check=atol(row[6].c_str()); - + SOAData sd; fillSOAData(row[2], sd); di.serial = sd.serial; if (!row[5].empty()) { di.notified_serial = atol(row[5].c_str()); } - + di.last_check = atol(row[6].c_str()); + di.account = row[7]; + if (pdns_iequals(row[3], "MASTER")) di.kind = DomainInfo::Master; else if (pdns_iequals(row[3], "SLAVE")) diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index 794e38ac241e..c07a27b05f0a 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -51,6 +51,7 @@ struct DomainInfo uint32_t notified_serial; uint32_t serial; time_t last_check; + string account; enum DomainKind { Master, Slave, Native } kind; DNSBackend *backend; diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index baa35d020ca5..828542201d76 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -307,6 +307,7 @@ static void fillZone(const string& zonename, HttpResponse* resp) { doc.AddMember("type", "Zone", doc.GetAllocator()); doc.AddMember("kind", di.getKindString(), doc.GetAllocator()); doc.AddMember("dnssec", dk.isSecuredZone(di.zone), doc.GetAllocator()); + doc.AddMember("account", di.account.c_str(), doc.GetAllocator()); string soa_edit_api; di.backend->getDomainMetadataOne(zonename, "SOA-EDIT-API", soa_edit_api); doc.AddMember("soa_edit_api", soa_edit_api.c_str(), doc.GetAllocator()); diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index 3e2087297273..3daf9ddb3141 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -49,7 +49,7 @@ def create_zone(self, name=None, **kwargs): def test_create_zone(self): payload, data = self.create_zone(serial=22) - for k in ('id', 'url', 'name', 'masters', 'kind', 'last_check', 'notified_serial', 'serial', 'soa_edit_api', 'soa_edit'): + for k in ('id', 'url', 'name', 'masters', 'kind', 'last_check', 'notified_serial', 'serial', 'soa_edit_api', 'soa_edit', 'account'): self.assertIn(k, data) if k in payload: self.assertEquals(data[k], payload[k]) From 79532aa7e793c5219adb2880576a1d27c2d802f2 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Sat, 7 Feb 2015 15:20:42 +0100 Subject: [PATCH 2/2] API: allow writing to domains.account field --- modules/gmysqlbackend/gmysqlbackend.cc | 3 ++- modules/gpgsqlbackend/gpgsqlbackend.cc | 3 ++- modules/gsqlite3backend/gsqlite3backend.cc | 3 ++- pdns/backends/gsql/gsqlbackend.cc | 17 +++++++++++++++++ pdns/backends/gsql/gsqlbackend.hh | 7 ++++++- pdns/dnsbackend.hh | 6 ++++++ pdns/ws-auth.cc | 3 +++ regression-tests.api/test_Zones.py | 9 +++++++++ 8 files changed, 47 insertions(+), 4 deletions(-) diff --git a/modules/gmysqlbackend/gmysqlbackend.cc b/modules/gmysqlbackend/gmysqlbackend.cc index 6320c31705ed..793ade9afae7 100644 --- a/modules/gmysqlbackend/gmysqlbackend.cc +++ b/modules/gmysqlbackend/gmysqlbackend.cc @@ -72,7 +72,7 @@ class gMySQLFactory : public BackendFactory declare(suffix,"supermaster-query","", "select account from supermasters where ip=? and nameserver=?"); declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=? and account=?"); - declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',?)"); + declare(suffix,"insert-zone-query","", "insert into domains (type,name,account) values('NATIVE',?,?)"); declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',?,?,?)"); declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values (?,?,?,?,?,?,?,?)"); @@ -92,6 +92,7 @@ class gMySQLFactory : public BackendFactory declare(suffix,"update-master-query","", "update domains set master=? where name=?"); declare(suffix,"update-kind-query","", "update domains set type=? where name=?"); + declare(suffix,"update-account-query","", "update domains set account=? where name=?"); declare(suffix,"update-serial-query","", "update domains set notified_serial=? where id=?"); declare(suffix,"update-lastcheck-query","", "update domains set last_check=? where id=?"); declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=?"); diff --git a/modules/gpgsqlbackend/gpgsqlbackend.cc b/modules/gpgsqlbackend/gpgsqlbackend.cc index 25d65e8d30f8..74b6e0518451 100644 --- a/modules/gpgsqlbackend/gpgsqlbackend.cc +++ b/modules/gpgsqlbackend/gpgsqlbackend.cc @@ -66,7 +66,7 @@ class gPgSQLFactory : public BackendFactory declare(suffix,"supermaster-query","", "select account from supermasters where ip=$1 and nameserver=$2"); declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=$1 and account=$2"); - declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',$1)"); + declare(suffix,"insert-zone-query","", "insert into domains (type,name,account) values('NATIVE',$1,$2)"); declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',$1,$2,$3)"); declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values ($1,$2,$3,$4,$5,$6,$7,$8)"); @@ -86,6 +86,7 @@ class gPgSQLFactory : public BackendFactory declare(suffix,"update-master-query","", "update domains set master=$1 where name=$2"); declare(suffix,"update-kind-query","", "update domains set type=$1 where name=$2"); + declare(suffix,"update-account-query","", "update domains set account=$1 where name=$2"); declare(suffix,"update-serial-query","", "update domains set notified_serial=$1 where id=$2"); declare(suffix,"update-lastcheck-query","", "update domains set last_check=$1 where id=$2"); declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=$1"); diff --git a/modules/gsqlite3backend/gsqlite3backend.cc b/modules/gsqlite3backend/gsqlite3backend.cc index a8bbf231c948..3c872620645a 100644 --- a/modules/gsqlite3backend/gsqlite3backend.cc +++ b/modules/gsqlite3backend/gsqlite3backend.cc @@ -83,7 +83,7 @@ class gSQLite3Factory : public BackendFactory declare(suffix, "supermaster-query", "", "select account from supermasters where ip=:ip and nameserver=:nameserver"); declare(suffix, "supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=:nameserver and account=:account"); - declare(suffix, "insert-zone-query", "", "insert into domains (type,name) values('NATIVE',:domain)"); + declare(suffix, "insert-zone-query", "", "insert into domains (type,name,account) values('NATIVE',:domain,:account)"); declare(suffix, "insert-slave-query", "", "insert into domains (type,name,master,account) values('SLAVE',:domain,:masters,:account)"); declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values (:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:auth)"); @@ -103,6 +103,7 @@ class gSQLite3Factory : public BackendFactory declare(suffix, "update-master-query", "", "update domains set master=:master where name=:domain"); declare(suffix, "update-kind-query", "", "update domains set type=:kind where name=:domain"); + declare(suffix, "update-account-query","", "update domains set account=:account where name=:domain"); declare(suffix, "update-serial-query", "", "update domains set notified_serial=:serial where id=:domain_id"); declare(suffix, "update-lastcheck-query", "", "update domains set last_check=:last_check where id=:domain_id"); declare(suffix, "zone-lastchange-query", "", "select max(change_date) from records where domain_id=:domain_id"); diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index c45aa2ac4bdc..42b9c17817aa 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -72,6 +72,7 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix) d_UpdateKindOfZoneQuery=getArg("update-kind-query"); d_UpdateSerialOfZoneQuery=getArg("update-serial-query"); d_UpdateLastCheckofZoneQuery=getArg("update-lastcheck-query"); + d_UpdateAccountOfZoneQuery=getArg("update-account-query"); d_ZoneLastChangeQuery=getArg("zone-lastchange-query"); d_InfoOfAllMasterDomainsQuery=getArg("info-all-master-query"); d_DeleteDomainQuery=getArg("delete-domain-query"); @@ -142,6 +143,7 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix) d_UpdateKindOfZoneQuery_stmt = NULL; d_UpdateSerialOfZoneQuery_stmt = NULL; d_UpdateLastCheckofZoneQuery_stmt = NULL; + d_UpdateAccountOfZoneQuery_stmt = NULL; d_InfoOfAllMasterDomainsQuery_stmt = NULL; d_DeleteDomainQuery_stmt = NULL; d_DeleteZoneQuery_stmt = NULL; @@ -270,6 +272,21 @@ bool GSQLBackend::setKind(const string &domain, const DomainInfo::DomainKind kin return true; } +bool GSQLBackend::setAccount(const string &domain, const string &account) +{ + try { + d_UpdateAccountOfZoneQuery_stmt-> + bind("account", account)-> + bind("domain", toLower(domain))-> + execute()-> + reset(); + } + catch (SSqlException &e) { + throw PDNSException("GSQLBackend unable to set account of domain \""+domain+"\": "+e.txtReason()); + } + return true; +} + bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di) { /* fill DomainInfo from database info: diff --git a/pdns/backends/gsql/gsqlbackend.hh b/pdns/backends/gsql/gsqlbackend.hh index ed091e110a67..b2e8d0fec10e 100644 --- a/pdns/backends/gsql/gsqlbackend.hh +++ b/pdns/backends/gsql/gsqlbackend.hh @@ -39,7 +39,7 @@ public: d_InfoOfAllSlaveDomainsQuery_stmt = d_db->prepare(d_InfoOfAllSlaveDomainsQuery, 0); d_SuperMasterInfoQuery_stmt = d_db->prepare(d_SuperMasterInfoQuery, 2); d_GetSuperMasterIPs_stmt = d_db->prepare(d_GetSuperMasterIPs, 2); - d_InsertZoneQuery_stmt = d_db->prepare(d_InsertZoneQuery, 1); + d_InsertZoneQuery_stmt = d_db->prepare(d_InsertZoneQuery, 2); d_InsertSlaveZoneQuery_stmt = d_db->prepare(d_InsertSlaveZoneQuery, 3); d_InsertRecordQuery_stmt = d_db->prepare(d_InsertRecordQuery, 8); d_InsertEntQuery_stmt = d_db->prepare(d_InsertEntQuery, 3); @@ -47,6 +47,7 @@ public: d_InsertEntOrderQuery_stmt = d_db->prepare(d_InsertEntOrderQuery, 4); d_UpdateMasterOfZoneQuery_stmt = d_db->prepare(d_UpdateMasterOfZoneQuery, 2); d_UpdateKindOfZoneQuery_stmt = d_db->prepare(d_UpdateKindOfZoneQuery, 2); + d_UpdateAccountOfZoneQuery_stmt = d_db->prepare(d_UpdateAccountOfZoneQuery, 2); d_UpdateSerialOfZoneQuery_stmt = d_db->prepare(d_UpdateSerialOfZoneQuery, 2); d_UpdateLastCheckofZoneQuery_stmt = d_db->prepare(d_UpdateLastCheckofZoneQuery, 2); d_InfoOfAllMasterDomainsQuery_stmt = d_db->prepare(d_InfoOfAllMasterDomainsQuery, 0); @@ -115,6 +116,7 @@ public: release(&d_InsertEntOrderQuery_stmt); release(&d_UpdateMasterOfZoneQuery_stmt); release(&d_UpdateKindOfZoneQuery_stmt); + release(&d_UpdateAccountOfZoneQuery_stmt); release(&d_UpdateSerialOfZoneQuery_stmt); release(&d_UpdateLastCheckofZoneQuery_stmt); release(&d_InfoOfAllMasterDomainsQuery_stmt); @@ -180,6 +182,7 @@ public: void setNotified(uint32_t domain_id, uint32_t serial); bool setMaster(const string &domain, const string &ip); bool setKind(const string &domain, const DomainInfo::DomainKind kind); + bool setAccount(const string &domain, const string &account); virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after); bool updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth); @@ -244,6 +247,7 @@ private: string d_InsertEntOrderQuery; string d_UpdateMasterOfZoneQuery; string d_UpdateKindOfZoneQuery; + string d_UpdateAccountOfZoneQuery; string d_UpdateSerialOfZoneQuery; string d_UpdateLastCheckofZoneQuery; string d_InfoOfAllMasterDomainsQuery; @@ -312,6 +316,7 @@ private: SSqlStatement* d_InsertEntOrderQuery_stmt; SSqlStatement* d_UpdateMasterOfZoneQuery_stmt; SSqlStatement* d_UpdateKindOfZoneQuery_stmt; + SSqlStatement* d_UpdateAccountOfZoneQuery_stmt; SSqlStatement* d_UpdateSerialOfZoneQuery_stmt; SSqlStatement* d_UpdateLastCheckofZoneQuery_stmt; SSqlStatement* d_InfoOfAllMasterDomainsQuery_stmt; diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index c07a27b05f0a..b4122b96e4bc 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -337,6 +337,12 @@ public: return false; } + //! Called when the Account of a domain should be changed + virtual bool setAccount(const string &domain, const string &account) + { + return false; + } + //! Can be called to seed the getArg() function with a prefix void setArgPrefix(const string &prefix); diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index 828542201d76..40a118448067 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -470,6 +470,9 @@ static void updateDomainSettingsFromDocument(const DomainInfo& di, const string& if (document["soa_edit"].IsString()) { di.backend->setDomainMetadataOne(zonename, "SOA-EDIT", document["soa_edit"].GetString()); } + if (document["account"].IsString()) { + di.backend->setAccount(zonename, document["account"].GetString()); + } } static void apiZoneCryptokeys(HttpRequest* req, HttpResponse* resp) { diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index 3daf9ddb3141..8223c3e7a07d 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -75,6 +75,15 @@ def test_create_zone_with_soa_edit_api(self): self.assertGreater(soa_serial, payload['serial']) self.assertEquals(soa_serial, data['serial']) + def test_create_zone_with_account(self): + # soa_edit_api wins over serial + payload, data = self.create_zone(account='anaccount', serial=10) + print data + for k in ('account', ): + self.assertIn(k, data) + if k in payload: + self.assertEquals(data[k], payload[k]) + def test_create_zone_with_records(self): name = unique_zone_name() records = [