Permalink
Browse files

qtype is now case insensitive

Plus update JSON API tests to test for this (from @zeha).
  • Loading branch information...
1 parent 13af5d8 commit 4d9c289dbf9ec60610102a6f1b82fc837887701b @mind04 mind04 committed with mind04 Jan 25, 2015
Showing with 12 additions and 8 deletions.
  1. +6 −5 pdns/qtype.cc
  2. +6 −3 regression-tests.api/test_Zones.py
View
@@ -79,19 +79,20 @@ QType &QType::operator=(uint16_t n)
int QType::chartocode(const char *p)
{
- static QType qt;
+ string P = toUpper(p);
vector<namenum>::iterator pos;
+
for(pos=names.begin(); pos < names.end(); ++pos)
- if(pos->first == p)
+ if(pos->first == P)
return pos->second;
-
+
if(*p=='#') {
return atoi(p+1);
}
- if(boost::starts_with(p, "TYPE"))
+ if(boost::starts_with(P, "TYPE"))
return atoi(p+4);
-
+
return 0;
}
@@ -95,13 +95,14 @@ def test_create_zone_with_comments(self):
comments = [
{
'name': name,
- 'type': 'SOA',
+ 'type': 'soa', # test uppercasing of type, too.
'account': 'test1',
'content': 'blah blah',
'modified_at': 11112,
}
]
payload, data = self.create_zone(name=name, comments=comments)
+ comments[0]['type'] = comments[0]['type'].upper()
# check our comment has appeared
self.assertEquals(data['comments'], comments)
@@ -110,13 +111,14 @@ def test_create_zone_with_custom_soa(self):
records = [
{
"name": name,
- "type": "SOA",
+ 'type': 'soa', # test uppercasing of type, too.
"ttl": 3600,
"content": "ns1.example.net testmaster@example.net 10 10800 3600 604800 3600",
"disabled": False
}
]
payload, data = self.create_zone(name=name, records=records)
+ records[0]['type'] = records[0]['type'].upper()
self.assertEquals([r for r in data['records'] if r['type'] == records[0]['type']], records)
def test_create_zone_trailing_dot(self):
@@ -449,7 +451,7 @@ def test_zone_rr_update(self):
rrset = {
'changetype': 'replace',
'name': name,
- 'type': 'NS',
+ 'type': 'ns',
'records': [
{
"name": name,
@@ -475,6 +477,7 @@ def test_zone_rr_update(self):
self.assert_success_json(r)
# verify that (only) the new record is there
r = self.session.get(self.url("/servers/localhost/zones/" + name))
+ rrset['type'] = rrset['type'].upper()
data = r.json()['records']
recs = [rec for rec in data if rec['type'] == rrset['type'] and rec['name'] == rrset['name']]
self.assertEquals(recs, rrset['records'])

0 comments on commit 4d9c289

Please sign in to comment.