BIND 10 trac931_2, updated. e9975a7383a299789fd18b184880a00dfb0e15ed [trac931] added a test case with the default keyring config. also added a note in updateKeyring() about why we need to catch the case of list==NULL explicitly.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 25 21:33:12 UTC 2011


The branch, trac931_2 has been updated
       via  e9975a7383a299789fd18b184880a00dfb0e15ed (commit)
       via  c8cf64492fbb3329d10b15ff660c9f262e46ae1f (commit)
       via  1ccec996459f9cea1bc32b6d736692fd087aae0e (commit)
       via  4f06531cf0b40476bbfd7d6a4312bacb1d958ffe (commit)
      from  e3a81c18ff3f55727c1308bb894a8eb03e8f48b1 (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 e9975a7383a299789fd18b184880a00dfb0e15ed
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed May 25 14:32:16 2011 -0700

    [trac931] added a test case with the default keyring config.
    also added a note in updateKeyring() about why we need to catch the case
    of list==NULL explicitly.

commit c8cf64492fbb3329d10b15ff660c9f262e46ae1f
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed May 25 13:58:32 2011 -0700

    [trac931] corrected a (non related) typo I happened to notice.

commit 1ccec996459f9cea1bc32b6d736692fd087aae0e
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed May 25 13:52:42 2011 -0700

    [trac931] corrected the document added in the previous commit a bit.

commit 4f06531cf0b40476bbfd7d6a4312bacb1d958ffe
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed May 25 13:43:01 2011 -0700

    [trac931] added a test to reproduce the problem we had with addRemoteConfig.
    Also added a note to the addRemoteConfig() document that when it's called
    for a module the module cc session must not have been "started".

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

Summary of changes:
 src/lib/config/ccsession.h                  |    6 +++++-
 src/lib/config/tests/ccsession_unittests.cc |   10 ++++++++++
 src/lib/server_common/keyring.cc            |    5 +++++
 src/lib/server_common/tests/keyring_test.cc |   23 ++++++++++++++++++++---
 4 files changed, 40 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h
index 99e1b51..e677146 100644
--- a/src/lib/config/ccsession.h
+++ b/src/lib/config/ccsession.h
@@ -256,12 +256,16 @@ public:
      * for those changes. This function will subscribe to the relevant module
      * channel.
      *
+     * This method must be called before calling the \c start() method on the
+     * ModuleCCSession (it also implies the ModuleCCSession must have been
+     * constructed with start_immediately being false).
+     *
      * \param spec_name This specifies the module to add. It is either a
      *                  filename of the spec file to use or a name of module
      *                  (in case it's a module name, the spec data is
      *                  downloaded from the configuration manager, therefore
      *                  the configuration manager must know it). If
-     *                  spec_is_filenabe is true (the default), then a
+     *                  spec_is_filename is true (the default), then a
      *                  filename is assumed, otherwise a module name.
      * \param handler The handler function called whenever there's a change.
      *                Called once initally from this function. May be NULL
diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc
index 104fa10..46132b3 100644
--- a/src/lib/config/tests/ccsession_unittests.cc
+++ b/src/lib/config/tests/ccsession_unittests.cc
@@ -595,4 +595,14 @@ TEST_F(CCSessionTest, delayedStart) {
                  FakeSession::DoubleRead);
 }
 
+// Similar to the above, but more implicitly by calling addRemoteConfig().
+// We should construct ModuleCCSession with start_immediately being false
+// if we need to call addRemoteConfig().
+// The correct cases are covered in remoteConfig test.
+TEST_F(CCSessionTest, doubleStartWithAddRemoteConfig) {
+    ModuleCCSession mccs(ccspecfile("spec29.spec"), session, NULL, NULL);
+    session.getMessages()->add(createAnswer(0, el("{}")));
+    EXPECT_THROW(mccs.addRemoteConfig(ccspecfile("spec2.spec")),
+                 FakeSession::DoubleRead);
+}
 }
diff --git a/src/lib/server_common/keyring.cc b/src/lib/server_common/keyring.cc
index b1de7aa..4bc9296 100644
--- a/src/lib/server_common/keyring.cc
+++ b/src/lib/server_common/keyring.cc
@@ -30,6 +30,11 @@ void
 updateKeyring(const std::string&, ConstElementPtr data) {
     ConstElementPtr list(data->get("keys"));
     KeyringPtr load(new TSIGKeyRing);
+
+    // Note that 'data' only contains explicitly configured config parameters.
+    // So if we use the default list is NULL, rather than an empty list, and
+    // we must explicitly expect that case (and handle it just like an empty
+    // list).
     for (size_t i(0); list && i < list->size(); ++ i) {
         load->add(TSIGKey(list->get(i)->stringValue()));
     }
diff --git a/src/lib/server_common/tests/keyring_test.cc b/src/lib/server_common/tests/keyring_test.cc
index 4d61950..d79b541 100644
--- a/src/lib/server_common/tests/keyring_test.cc
+++ b/src/lib/server_common/tests/keyring_test.cc
@@ -43,15 +43,24 @@ public:
     isc::cc::FakeSession session;
     std::auto_ptr<ModuleCCSession> mccs;
     std::string specfile;
-    void doInit() {
+    void doInit(bool with_key = true) {
         // Prepare the module specification for it and the config
         session.getMessages()->
             add(createAnswer(0,
                              moduleSpecFromFile(std::string(PLUGIN_DATA_PATH) +
                                                 "/tsig_keys.spec").
                              getFullSpec()));
-        session.getMessages()->add(createAnswer(0, Element::fromJSON(
-            "{\"keys\": [\"key:MTIzNAo=:hmac-sha1\"]}")));
+        if (with_key) {
+            session.getMessages()->add(
+                createAnswer(0, Element::fromJSON(
+                                 "{\"keys\": [\"key:MTIzNAo=:hmac-sha1\"]}")));
+        } else {
+            // This emulates the case of using the spec default.  Note that
+            // the default value won't be passed to the config handler, so
+            // we'll pass an empty object, instead of {"keys": []}.
+            session.getMessages()->add(createAnswer(0,
+                                                    Element::fromJSON("{}")));
+        }
         // Now load it
         EXPECT_NO_THROW(initKeyring(*mccs));
         EXPECT_NE(keyring, boost::shared_ptr<TSIGKeyRing>()) <<
@@ -97,6 +106,14 @@ TEST_F(KeyringTest, keyring) {
     }
 }
 
+TEST_F(KeyringTest, keyringWithDefault) {
+    // If we don't explicitly specify a keyring, the default (no key) will
+    // be used.
+    doInit(false);
+    EXPECT_EQ(0, keyring->size());
+    deinitKeyring(*mccs);
+}
+
 // Init twice
 TEST_F(KeyringTest, initTwice) {
     // It is NULL before




More information about the bind10-changes mailing list