Parcourir la source

[trac811_new] added some trivial editorial changes. also added a test
case with an invalid tsigkey string.

JINMEI Tatuya il y a 14 ans
Parent
commit
7a1c4cc8e1
2 fichiers modifiés avec 20 ajouts et 6 suppressions
  1. 17 3
      src/bin/xfrin/tests/xfrin_test.py
  2. 3 3
      src/bin/xfrin/xfrin.py.in

+ 17 - 3
src/bin/xfrin/tests/xfrin_test.py

@@ -90,8 +90,8 @@ class MockXfrin(Xfrin):
         if MockXfrin.check_command_hook:
             MockXfrin.check_command_hook()
 
-    def xfrin_start(self, zone_name, rrclass, db_file, master_addrinfo, tsig_key_str,
-                    check_soa = True):
+    def xfrin_start(self, zone_name, rrclass, db_file, master_addrinfo,
+                    tsig_key_str, check_soa=True):
         # store some of the arguments for verification, then call this
         # method in the superclass
         self.xfrin_started_zone_name = zone_name
@@ -101,7 +101,7 @@ class MockXfrin(Xfrin):
         self.xfrin_started_tsig_key_str = tsig_key_str
         return Xfrin.xfrin_start(self, zone_name, rrclass, db_file,
                                  master_addrinfo, tsig_key_str,
-                                 check_soa = True)
+                                 check_soa=True)
 
 class MockXfrinConnection(XfrinConnection):
     def __init__(self, sock_map, zone_name, rrclass, db_file, shutdown_event,
@@ -560,6 +560,7 @@ class TestXfrin(unittest.TestCase):
 
     def test_command_handler_retransfer_short_command1(self):
         # try it when only specifying the zone name (of unknown zone)
+        # this should fail because master address is not specified.
         short_args = {}
         short_args['zone_name'] = TEST_ZONE_NAME_STR
         self.assertEqual(self.xfr.command_handler("retransfer",
@@ -567,6 +568,7 @@ class TestXfrin(unittest.TestCase):
 
     def test_command_handler_retransfer_short_command2(self):
         # try it when only specifying the zone name (of unknown zone)
+        # this should fail because master address is not specified.
         short_args = {}
         short_args['zone_name'] = TEST_ZONE_NAME_STR
         self.assertEqual(self.xfr.command_handler("retransfer",
@@ -779,6 +781,18 @@ class TestXfrin(unittest.TestCase):
         # since this has failed, we should still have the previous config
         self._check_zones_config(zones2)
 
+        zones = { 'zones': [
+                  { 'name': 'test.example',
+                    'master_addr': '192.0.2.7',
+                    'master_port': 53,
+                    # using a bad TSIG key spec
+                    'tsig_key': "bad..example.com:SFuWd/q99SzF8Yzd1QbB9g=="
+                  }
+                ]}
+        self.assertEqual(self.xfr.config_handler(zones)['result'][0], 1)
+        # since this has failed, we should still have the previous config
+        self._check_zones_config(zones2)
+
         # let's also add a zone that is correct too, and make sure
         # that the new config is not partially taken
         zones = { 'zones': [

+ 3 - 3
src/bin/xfrin/xfrin.py.in

@@ -77,8 +77,8 @@ class XfrinConfigException(Exception):
     pass
 
 def _check_zone_name(zone_name_str):
-    """Checks if the given zone name is a valid domain name, and returns it as a Name object.
-       Raises an XfrinException if it is not."""
+    """Checks if the given zone name is a valid domain name, and returns
+    it as a Name object. Raises an XfrinException if it is not."""
     try:
         return Name(zone_name_str)
     except (EmptyLabel, TooLongLabel, BadLabelType, BadEscape,
@@ -406,7 +406,7 @@ class XfrinRecorder:
         return ret
 
 class ZoneInfo:
-    def __init__(self, config_data, module_cc = None):
+    def __init__(self, config_data, module_cc=None):
         """Creates a zone_info with the config data element as
            specified by the 'zones' list in xfrin.spec. Module_cc is
            needed to get the defaults from the specification"""