Skip to content

Commit

Permalink
qtype is now case insensitive
Browse files Browse the repository at this point in the history
Plus update JSON API tests to test for this (from @zeha).
  • Loading branch information
mind04 authored and zeha committed Jan 26, 2015
1 parent 94b7c11 commit 8ce0dc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 6 additions & 5 deletions pdns/qtype.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 6 additions & 3 deletions regression-tests.api/test_Zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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):
Expand Down Expand Up @@ -449,7 +451,7 @@ def test_zone_rr_update(self):
rrset = {
'changetype': 'replace',
'name': name,
'type': 'NS',
'type': 'ns',
'records': [
{
"name": name,
Expand All @@ -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'])
Expand Down

0 comments on commit 8ce0dc7

Please sign in to comment.