Commit e9975a73 authored by JINMEI Tatuya's avatar JINMEI Tatuya

[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.
parent c8cf6449
......@@ -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) {
......@@ -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
moduleSpecFromFile(std::string(PLUGIN_DATA_PATH) +
session.getMessages()->add(createAnswer(0, Element::fromJSON(
"{\"keys\": [\"key:MTIzNAo=:hmac-sha1\"]}")));
if (with_key) {
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": []}.
// Now load it
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.
EXPECT_EQ(0, keyring->size());
// Init twice
TEST_F(KeyringTest, initTwice) {
// It is NULL before
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment