BIND 10 trac875, updated. f8c763ef2c9eb8343ead481093e2d0024e3f1cd2 [trac875] Tests for the checking function

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 11 14:26:58 UTC 2011


The branch, trac875 has been updated
       via  f8c763ef2c9eb8343ead481093e2d0024e3f1cd2 (commit)
      from  f80cdaf115a8ad80184240b283b243ac07bb9739 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f8c763ef2c9eb8343ead481093e2d0024e3f1cd2
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed May 11 16:26:41 2011 +0200

    [trac875] Tests for the checking function

-----------------------------------------------------------------------

Summary of changes:
 src/bin/cfgmgr/plugins/tests/tsig_keys_test.py |   48 ++++++++++++++++++++++++
 src/bin/cfgmgr/plugins/tsig_keys.py            |    2 +-
 2 files changed, 49 insertions(+), 1 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py b/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
index ee38ee6..e6436a9 100644
--- a/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
+++ b/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
@@ -51,5 +51,53 @@ class TSigKeysTest(unittest.TestCase):
         # There's some nonempty configuration
         self.assertNotEqual({}, spec.get_config_spec())
 
+    def test_missing_keys(self):
+        """
+        Test that missing keys doesn't kill us. There are just no keys there.
+        """
+        self.assertEqual(None, tsig_keys.check({}))
+
+    def test_data_empty(self):
+        """Check we accept valid config with empty set of tsig keys."""
+        self.assertEqual(None, tsig_keys.check({'keys': []}))
+
+    def test_keys_valid(self):
+        """
+        Check we accept some valid keys (we don't check all the algorithms,
+        that's the job of isc.dns.TSIGKey).
+        """
+        self.assertEqual(None, tsig_keys.check({'keys':
+            ['testkey:QklORCAxMCBpcyBjb29sCg==',
+             'test.key:QklORCAxMCBpcyBjb29sCg==:hmac-sha1']}))
+
+    def test_keys_same_name(self):
+        """
+        Test we reject when we have multiple keys with the same name.
+        """
+        self.assertEqual("Multiple TSIG keys with name 'test.key'",
+                         tsig_keys.check({'keys':
+                                         ['test.key:QklORCAxMCBpcyBjb29sCg==',
+                                          'test.key:b3RoZXIK']}))
+
+    def test_invalid_key(self):
+        """
+        Test we reject invalid key.
+        """
+        self.assertEqual("TSIG: Invalid TSIG key string: invalid.key",
+                         tsig_keys.check({'keys': ['invalid.key']}))
+        self.assertEqual(
+            "TSIG: attempt to decode a value not in base64 char set",
+            tsig_keys.check({'keys': ['invalid.key:123']}))
+
+    def test_bad_format(self):
+        """
+        Test we fail on bad format. We don't really care much how here, though,
+        as this should not get in trough config manager anyway.
+        """
+        self.assertNotEqual(None, tsig_keys.check({'bad_name': {}}))
+        self.assertNotEqual(None, tsig_keys.check({'keys': 'not_list'}))
+        self.assertNotEqual(None, tsig_keys.check({'keys': 42}))
+        self.assertNotEqual(None, tsig_keys.check({'keys': {}}))
+
 if __name__ == '__main__':
         unittest.main()
diff --git a/src/bin/cfgmgr/plugins/tsig_keys.py b/src/bin/cfgmgr/plugins/tsig_keys.py
index f3ba881..39058b4 100644
--- a/src/bin/cfgmgr/plugins/tsig_keys.py
+++ b/src/bin/cfgmgr/plugins/tsig_keys.py
@@ -18,7 +18,7 @@ from isc.util.file import path_search
 from bind10_config import PLUGIN_PATHS
 spec = module_spec_from_file(path_search('tsig_keys.spec', PLUGIN_PATHS))
 
-def check():
+def check(config):
     pass
 
 def load():




More information about the bind10-changes mailing list