]> granicus.if.org Git - pdns/commitdiff
qtype is now case insensitive
authorKees Monshouwer <mind04@monshouwer.org>
Sun, 25 Jan 2015 21:48:07 +0000 (22:48 +0100)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Mon, 26 Jan 2015 20:45:55 +0000 (21:45 +0100)
Plus update JSON API tests to test for this (from @zeha).

pdns/qtype.cc
regression-tests.api/test_Zones.py

index 3e23f12b12135beba06ee0508cf39b3dbedb77b2..ed7bf4fd06af19710762590ee25f8236364d48b8 100644 (file)
@@ -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;
 }
 
index b627d15fdcc0c6e43976ba8cafbad13f709c2d52..3e208729727310e4e2000d831a2bedd04773667f 100644 (file)
@@ -95,13 +95,14 @@ class AuthZones(ApiTestCase):
         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 @@ class AuthZones(ApiTestCase):
         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 @@ fred   IN  A      192.168.0.4
         rrset = {
             'changetype': 'replace',
             'name': name,
-            'type': 'NS',
+            'type': 'ns',
             'records': [
                 {
                     "name": name,
@@ -475,6 +477,7 @@ fred   IN  A      192.168.0.4
         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'])