Browse Source

use a string instead of an object for the RRclass parameter for xfrin/notify.
add validation of the given string.
adjust/add tests for this change.


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac221b@2477 e5f2f494-b856-4b98-b285-d166d9295462

JINMEI Tatuya 15 years ago
parent
commit
f55a7b7475
2 changed files with 10 additions and 1 deletions
  1. 5 1
      src/bin/xfrin/tests/xfrin_test.py
  2. 5 0
      src/bin/xfrin/xfrin.py.in

+ 5 - 1
src/bin/xfrin/tests/xfrin_test.py

@@ -430,9 +430,13 @@ class TestXfrin(unittest.TestCase):
         self.assertEqual(master_addrinfo[4][0], TEST_MASTER_IPV6_ADDRESS)
 
     def test_parse_cmd_params_chclass(self):
-        self.args['rrclass'] = RRClass.CH()
+        self.args['rrclass'] = 'CH'
         self.assertEqual(self._do_parse()[1], RRClass.CH())
 
+    def test_parse_cmd_params_bogusclass(self):
+        self.args['rrclass'] = 'XXX'
+        self.assertRaises(XfrinException, self._do_parse)
+
     def test_parse_cmd_params_nozone(self):
         # zone name is mandatory.
         del self.args['zone_name']

+ 5 - 0
src/bin/xfrin/xfrin.py.in

@@ -440,6 +440,11 @@ a separate method for the convenience of unit tests.
             # the class is passed in the command arg (where we specify
             # the default)
             rrclass = RRClass.IN()
+        else:
+            try:
+                rrclass = RRClass(rrclass)
+            except InvalidRRClass as e:
+                raise XfrinException('invalid RRClass: ' + rrclass)
 
         master = args.get('master')
         if not master: