" unexpected constant string, expecting JSON");
}
-/// @brief Tests the enforcement of data validation when parsing TSIGKeyInfos.
-/// It verifies that:
-/// 1. Name cannot be blank.
-/// 2. Algorithm cannot be blank.
-/// 3. Secret cannot be blank.
-TEST_F(TSIGKeyInfoTest, invalidEntry) {
- // Config with a blank name entry.
- std::string config = "{"
- " \"name\": \"\" , "
- " \"algorithm\": \"HMAC-MD5\" , "
- " \"secret\": \"LSWXnfkKZjdPJI5QxlpnfQ==\" "
- "}";
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that build fails on blank name.
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-
- // Config with a blank algorithm entry.
- config = "{"
- " \"name\": \"d2_key_one\" , "
- " \"algorithm\": \"\" , "
- " \"secret\": \"LSWXnfkKZjdPJI5QxlpnfQ==\" "
- "}";
-
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that build fails on blank algorithm.
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-
- // Config with an invalid algorithm entry.
- config = "{"
- " \"name\": \"d2_key_one\" , "
- " \"algorithm\": \"bogus\" , "
- " \"secret\": \"LSWXnfkKZjdPJI5QxlpnfQ==\" "
- "}";
-
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that build fails on blank algorithm.
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-
- // Config with a blank secret entry.
- config = "{"
- " \"name\": \"d2_key_one\" , "
- " \"algorithm\": \"HMAC-MD5\" , "
- " \"secret\": \"\" "
- "}";
-
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that build fails blank secret
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-
- // Config with an invalid secret entry.
- config = "{"
- " \"name\": \"d2_key_one\" , "
- " \"algorithm\": \"HMAC-MD5\" , "
- " \"secret\": \"bogus\" "
- "}";
-
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that build fails an invalid secret
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-}
-
-/// @brief Verifies that TSIGKeyInfo parsing creates a proper TSIGKeyInfo
-/// when given a valid combination of entries.
-TEST_F(TSIGKeyInfoTest, validEntry) {
- // Valid entries for TSIG key, all items are required.
- std::string config = "{"
- " \"name\": \"d2_key_one\" , "
- " \"algorithm\": \"HMAC-MD5\" , "
- " \"digest-bits\": 120 , "
- " \"secret\": \"dGhpcyBrZXkgd2lsbCBtYXRjaA==\" "
- "}";
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that it builds and commits without throwing.
- //ASSERT_NO_THROW(parser_->build(config_set_));
- (parser_->build(config_set_));
- ASSERT_NO_THROW(parser_->commit());
-
- // Verify the correct number of keys are present
- int count = keys_->size();
- EXPECT_EQ(1, count);
-
- // Find the key and retrieve it.
- TSIGKeyInfoMap::iterator gotit = keys_->find("d2_key_one");
- ASSERT_TRUE(gotit != keys_->end());
- TSIGKeyInfoPtr& key = gotit->second;
-
- // Verify the key contents.
- EXPECT_TRUE(checkKey(key, "d2_key_one", "HMAC-MD5",
- "dGhpcyBrZXkgd2lsbCBtYXRjaA==", 120));
-}
-
-/// @brief Verifies that attempting to parse an invalid list of TSIGKeyInfo
-/// entries is detected.
-TEST_F(TSIGKeyInfoTest, invalidTSIGKeyList) {
- // Construct a list of keys with an invalid key entry.
- std::string config = "["
-
- " { \"name\": \"key1\" , "
- " \"algorithm\": \"HMAC-MD5\" ,"
- " \"digest-bits\": 120 , "
- " \"secret\": \"GWG/Xfbju4O2iXGqkSu4PQ==\" "
- " },"
- // this entry has an invalid algorithm
- " { \"name\": \"key2\" , "
- " \"algorithm\": \"\" ,"
- " \"digest-bits\": 120 , "
- " \"secret\": \"GWG/Xfbju4O2iXGqkSu4PQ==\" "
- " },"
- " { \"name\": \"key3\" , "
- " \"algorithm\": \"HMAC-MD5\" ,"
- " \"secret\": \"GWG/Xfbju4O2iXGqkSu4PQ==\" "
- " }"
- " ]";
-
- ASSERT_TRUE(fromJSON(config));
-
- // Create the list parser.
- isc::dhcp::ParserPtr parser;
- ASSERT_NO_THROW(parser.reset(new TSIGKeyInfoListParser("test", keys_)));
-
- // Verify that the list builds without errors.
- EXPECT_THROW(parser->build(config_set_), D2CfgError);
-}
-
-/// @brief Verifies that attempting to parse an invalid list of TSIGKeyInfo
-/// entries is detected.
-TEST_F(TSIGKeyInfoTest, duplicateTSIGKey) {
- // Construct a list of keys with an invalid key entry.
- std::string config = "["
-
- " { \"name\": \"key1\" , "
- " \"algorithm\": \"HMAC-MD5\" ,"
- " \"digest-bits\": 120 , "
- " \"secret\": \"GWG/Xfbju4O2iXGqkSu4PQ==\" "
- " },"
- " { \"name\": \"key2\" , "
- " \"algorithm\": \"HMAC-MD5\" ,"
- " \"digest-bits\": 120 , "
- " \"secret\": \"GWG/Xfbju4O2iXGqkSu4PQ==\" "
- " },"
- " { \"name\": \"key1\" , "
- " \"algorithm\": \"HMAC-MD5\" ,"
- " \"secret\": \"GWG/Xfbju4O2iXGqkSu4PQ==\" "
- " }"
- " ]";
-
- ASSERT_TRUE(fromJSON(config));
-
- // Create the list parser.
- isc::dhcp::ParserPtr parser;
- ASSERT_NO_THROW(parser.reset(new TSIGKeyInfoListParser("test", keys_)));
-
- // Verify that the list builds without errors.
- EXPECT_THROW(parser->build(config_set_), D2CfgError);
-}
-
-/// @brief Verifies a valid list of TSIG Keys parses correctly.
-/// Also verifies that all of the supported algorithm names work.
-TEST_F(TSIGKeyInfoTest, validTSIGKeyList) {
- // Construct a valid list of keys.
- std::string config = "["
-
- " { \"name\": \"key1\" , "
- " \"algorithm\": \"HMAC-MD5\" ,"
- " \"digest-bits\": 80 , "
- " \"secret\": \"dGhpcyBrZXkgd2lsbCBtYXRjaA==\" "
- " },"
- " { \"name\": \"key2\" , "
- " \"algorithm\": \"HMAC-SHA1\" ,"
- " \"digest-bits\": 80 , "
- " \"secret\": \"dGhpcyBrZXkgd2lsbCBtYXRjaA==\" "
- " },"
- " { \"name\": \"key3\" , "
- " \"algorithm\": \"HMAC-SHA256\" ,"
- " \"digest-bits\": 128 , "
- " \"secret\": \"dGhpcyBrZXkgd2lsbCBtYXRjaA==\" "
- " },"
- " { \"name\": \"key4\" , "
- " \"algorithm\": \"HMAC-SHA224\" ,"
- " \"digest-bits\": 112 , "
- " \"secret\": \"dGhpcyBrZXkgd2lsbCBtYXRjaA==\" "
- " },"
- " { \"name\": \"key5\" , "
- " \"algorithm\": \"HMAC-SHA384\" ,"
- " \"digest-bits\": 192 , "
- " \"secret\": \"dGhpcyBrZXkgd2lsbCBtYXRjaA==\" "
- " },"
- " { \"name\": \"key6\" , "
- " \"algorithm\": \"HMAC-SHA512\" ,"
- " \"digest-bits\": 256 , "
- " \"secret\": \"dGhpcyBrZXkgd2lsbCBtYXRjaA==\" "
- " }"
- " ]";
-
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that the list builds and commits without errors.
- // Create the list parser.
- isc::dhcp::ParserPtr parser;
- ASSERT_NO_THROW(parser.reset(new TSIGKeyInfoListParser("test", keys_)));
- ASSERT_NO_THROW(parser->build(config_set_));
- ASSERT_NO_THROW(parser->commit());
-
- std::string ref_secret = "dGhpcyBrZXkgd2lsbCBtYXRjaA==";
- // Verify the correct number of keys are present
- int count = keys_->size();
- ASSERT_EQ(6, count);
-
- // Find the 1st key and retrieve it.
- TSIGKeyInfoMap::iterator gotit = keys_->find("key1");
- ASSERT_TRUE(gotit != keys_->end());
- TSIGKeyInfoPtr& key = gotit->second;
-
- // Verify the key contents.
- EXPECT_TRUE(checkKey(key, "key1", TSIGKeyInfo::HMAC_MD5_STR,
- ref_secret, 80));
-
- // Find the 2nd key and retrieve it.
- gotit = keys_->find("key2");
- ASSERT_TRUE(gotit != keys_->end());
- key = gotit->second;
-
- // Verify the key contents.
- EXPECT_TRUE(checkKey(key, "key2", TSIGKeyInfo::HMAC_SHA1_STR,
- ref_secret, 80));
-
- // Find the 3rd key and retrieve it.
- gotit = keys_->find("key3");
- ASSERT_TRUE(gotit != keys_->end());
- key = gotit->second;
-
- // Verify the key contents.
- EXPECT_TRUE(checkKey(key, "key3", TSIGKeyInfo::HMAC_SHA256_STR,
- ref_secret, 128));
-
- // Find the 4th key and retrieve it.
- gotit = keys_->find("key4");
- ASSERT_TRUE(gotit != keys_->end());
- key = gotit->second;
-
- // Verify the key contents.
- EXPECT_TRUE(checkKey(key, "key4", TSIGKeyInfo::HMAC_SHA224_STR,
- ref_secret, 112));
-
- // Find the 5th key and retrieve it.
- gotit = keys_->find("key5");
- ASSERT_TRUE(gotit != keys_->end());
- key = gotit->second;
-
- // Verify the key contents.
- EXPECT_TRUE(checkKey(key, "key5", TSIGKeyInfo::HMAC_SHA384_STR,
- ref_secret, 192));
-
- // Find the 6th key and retrieve it.
- gotit = keys_->find("key6");
- ASSERT_TRUE(gotit != keys_->end());
- key = gotit->second;
-
- // Verify the key contents.
- EXPECT_TRUE(checkKey(key, "key6", TSIGKeyInfo::HMAC_SHA512_STR,
- ref_secret, 256));
-}
-
-/// @brief Tests the enforcement of data validation when parsing DnsServerInfos.
-/// It verifies that:
-/// 1. Specifying both a hostname and an ip address is not allowed.
-/// 2. Specifying both blank a hostname and blank ip address is not allowed.
-/// 3. Specifying a negative port number is not allowed.
-TEST_F(DnsServerInfoTest, invalidEntry) {
- // Create a config in which both host and ip address are supplied.
- // Verify that build fails.
- std::string config = "{ \"hostname\": \"pegasus.tmark\", "
- " \"ip-address\": \"127.0.0.1\" } ";
- ASSERT_TRUE(fromJSON(config));
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-
- // Neither host nor ip address supplied
- // Verify that builds fails.
- config = "{ \"hostname\": \"\", "
- " \"ip-address\": \"\" } ";
- ASSERT_TRUE(fromJSON(config));
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-
- // Create a config with a negative port number.
- // Verify that build fails.
- config = "{ \"ip-address\": \"192.168.5.6\" ,"
- " \"port\": -100 }";
- ASSERT_TRUE(fromJSON(config));
- EXPECT_THROW (parser_->build(config_set_), isc::BadValue);
-}
-
-
-/// @brief Verifies that DnsServerInfo parsing creates a proper DnsServerInfo
-/// when given a valid combination of entries.
-/// It verifies that:
-/// 1. A DnsServerInfo entry is correctly made, when given only a hostname.
-/// 2. A DnsServerInfo entry is correctly made, when given ip address and port.
-/// 3. A DnsServerInfo entry is correctly made, when given only an ip address.
-TEST_F(DnsServerInfoTest, validEntry) {
- /// @todo When resolvable hostname is supported you'll need this test.
- /// // Valid entries for dynamic host
- /// std::string config = "{ \"hostname\": \"pegasus.tmark\" }";
- /// ASSERT_TRUE(fromJSON(config));
-
- /// // Verify that it builds and commits without throwing.
- /// ASSERT_NO_THROW(parser_->build(config_set_));
- /// ASSERT_NO_THROW(parser_->commit());
-
- /// //Verify the correct number of servers are present
- /// int count = servers_->size();
- /// EXPECT_EQ(1, count);
-
- /// Verify the server exists and has the correct values.
- /// DnsServerInfoPtr server = (*servers_)[0];
- /// EXPECT_TRUE(checkServer(server, "pegasus.tmark",
- /// DnsServerInfo::EMPTY_IP_STR,
- /// DnsServerInfo::STANDARD_DNS_PORT));
-
- /// // Start over for a new test.
- /// reset();
-
- // Valid entries for static ip
- std::string config = " { \"ip-address\": \"127.0.0.1\" , "
- " \"port\": 100 }";
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that it builds and commits without throwing.
- ASSERT_NO_THROW(parser_->build(config_set_));
- ASSERT_NO_THROW(parser_->commit());
-
- // Verify the correct number of servers are present
- int count = servers_->size();
- EXPECT_EQ(1, count);
-
- // Verify the server exists and has the correct values.
- DnsServerInfoPtr server = (*servers_)[0];
- EXPECT_TRUE(checkServer(server, "", "127.0.0.1", 100));
-
- // Start over for a new test.
- reset();
-
- // Valid entries for static ip, no port
- config = " { \"ip-address\": \"192.168.2.5\" }";
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that it builds and commits without throwing.
- ASSERT_NO_THROW(parser_->build(config_set_));
- ASSERT_NO_THROW(parser_->commit());
-
- // Verify the correct number of servers are present
- count = servers_->size();
- EXPECT_EQ(1, count);
-
- // Verify the server exists and has the correct values.
- server = (*servers_)[0];
- EXPECT_TRUE(checkServer(server, "", "192.168.2.5",
- DnsServerInfo::STANDARD_DNS_PORT));
-}
-
-/// @brief Verifies that attempting to parse an invalid list of DnsServerInfo
-/// entries is detected.
-TEST_F(ConfigParseTest, invalidServerList) {
- // Construct a list of servers with an invalid server entry.
- std::string config = "[ { \"ip-address\": \"127.0.0.1\" }, "
- "{ \"ip-address\": \"\" }, "
- "{ \"ip-address\": \"127.0.0.2\" } ]";
- ASSERT_TRUE(fromJSON(config));
-
- // Create the server storage and list parser.
- DnsServerInfoStoragePtr servers(new DnsServerInfoStorage());
- isc::dhcp::ParserPtr parser;
- ASSERT_NO_THROW(parser.reset(new DnsServerInfoListParser("test", servers)));
-
- // Verify that build fails.
- EXPECT_THROW(parser->build(config_set_), D2CfgError);
-}
-
-/// @brief Verifies that a list of DnsServerInfo entries parses correctly given
-/// a valid configuration.
-TEST_F(ConfigParseTest, validServerList) {
- // Create a valid list of servers.
- std::string config = "[ { \"ip-address\": \"127.0.0.1\" }, "
- "{ \"ip-address\": \"127.0.0.2\" }, "
- "{ \"ip-address\": \"127.0.0.3\" } ]";
- ASSERT_TRUE(fromJSON(config));
-
- // Create the server storage and list parser.
- DnsServerInfoStoragePtr servers(new DnsServerInfoStorage());
- isc::dhcp::ParserPtr parser;
- ASSERT_NO_THROW(parser.reset(new DnsServerInfoListParser("test", servers)));
-
- // Verify that the list builds and commits without error.
- ASSERT_NO_THROW(parser->build(config_set_));
- ASSERT_NO_THROW(parser->commit());
-
- // Verify that the server storage contains the correct number of servers.
- int count = servers->size();
- EXPECT_EQ(3, count);
-
- // Verify the first server exists and has the correct values.
- DnsServerInfoPtr server = (*servers)[0];
- EXPECT_TRUE(checkServer(server, "", "127.0.0.1",
- DnsServerInfo::STANDARD_DNS_PORT));
-
- // Verify the second server exists and has the correct values.
- server = (*servers)[1];
- EXPECT_TRUE(checkServer(server, "", "127.0.0.2",
- DnsServerInfo::STANDARD_DNS_PORT));
-
- // Verify the third server exists and has the correct values.
- server = (*servers)[2];
- EXPECT_TRUE(checkServer(server, "", "127.0.0.3",
- DnsServerInfo::STANDARD_DNS_PORT));
-}
-
-/// @brief Tests the enforcement of data validation when parsing DdnsDomains.
-/// It verifies that:
-/// 1. Domain storage cannot be null when constructing a DdnsDomainParser.
-/// 2. The name entry is not optional.
-/// 3. The server list man not be empty.
-/// 4. That a mal-formed server entry is detected.
-/// 5. That an undefined key name is detected.
-TEST_F(DdnsDomainTest, invalidDdnsDomainEntry) {
- // Verify that attempting to construct the parser with null storage fails.
- DdnsDomainMapPtr domains;
- ASSERT_THROW(isc::dhcp::ParserPtr(
- new DdnsDomainParser("test", domains, keys_)), D2CfgError);
-
- // Create a domain configuration without a name
- std::string config = "{ \"key-name\": \"d2_key.tmark.org\" , "
- " \"dns-servers\" : [ "
- " { \"ip-address\": \"127.0.0.1\" , "
- " \"port\": 100 },"
- " { \"ip-address\": \"127.0.0.2\" , "
- " \"port\": 200 },"
- " { \"ip-address\": \"127.0.0.3\" , "
- " \"port\": 300 } ] } ";
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that the domain configuration builds fails.
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-
- // Create a domain configuration with an empty server list.
- config = "{ \"name\": \"tmark.org\" , "
- " \"key-name\": \"d2_key.tmark.org\" , "
- " \"dns-servers\" : [ "
- " ] } ";
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that the domain configuration build fails.
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-
- // Create a domain configuration with a mal-formed server entry.
- config = "{ \"name\": \"tmark.org\" , "
- " \"key-name\": \"d2_key.tmark.org\" , "
- " \"dns-servers\" : [ "
- " { \"ip-address\": \"127.0.0.3\" , "
- " \"port\": -1 } ] } ";
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that the domain configuration build fails.
- EXPECT_THROW(parser_->build(config_set_), isc::BadValue);
-
- // Create a domain configuration without an defined key name
- config = "{ \"name\": \"tmark.org\" , "
- " \"key-name\": \"d2_key.tmark.org\" , "
- " \"dns-servers\" : [ "
- " { \"ip-address\": \"127.0.0.3\" , "
- " \"port\": 300 } ] } ";
- ASSERT_TRUE(fromJSON(config));
-
- // Verify that the domain configuration build fails.
- EXPECT_THROW(parser_->build(config_set_), D2CfgError);
-}
-
-/// @brief Verifies the basics of parsing DdnsDomains.
-/// It verifies that:
-/// 1. Valid construction of DdnsDomainParser functions.
-/// 2. Given a valid, configuration entry, DdnsDomainParser parses
-/// correctly.
-/// (It indirectly verifies the operation of DdnsDomainMap).
-TEST_F(DdnsDomainTest, ddnsDomainParsing) {
- // Create a valid domain configuration entry containing three valid
- // servers.
- std::string config =
- "{ \"name\": \"tmark.org\" , "
- " \"key-name\": \"d2_key.tmark.org\" , "
- " \"dns-servers\" : [ "
- " { \"ip-address\": \"127.0.0.1\" , "
- " \"port\": 100 },"
- " { \"ip-address\": \"127.0.0.2\" , "
- " \"port\": 200 },"
- " { \"ip-address\": \"127.0.0.3\" , "
- " \"port\": 300 } ] } ";
- ASSERT_TRUE(fromJSON(config));
-
- // Add a TSIG key to the test key map, so key validation will pass.
- addKey("d2_key.tmark.org", "HMAC-MD5", "GWG/Xfbju4O2iXGqkSu4PQ==");
-
- // Verify that the domain configuration builds and commits without error.
- ASSERT_NO_THROW(parser_->build(config_set_));
- ASSERT_NO_THROW(parser_->commit());
-
- // Verify that the domain storage contains the correct number of domains.
- int count = domains_->size();
- EXPECT_EQ(1, count);
-
- // Verify that the expected domain exists and can be retrieved from
- // the storage.
- DdnsDomainMap::iterator gotit = domains_->find("tmark.org");
- ASSERT_TRUE(gotit != domains_->end());
- DdnsDomainPtr& domain = gotit->second;
-
- // Verify the name and key_name values.
- EXPECT_EQ("tmark.org", domain->getName());
- EXPECT_EQ("d2_key.tmark.org", domain->getKeyName());
- ASSERT_TRUE(domain->getTSIGKeyInfo());
- ASSERT_TRUE(domain->getTSIGKeyInfo()->getTSIGKey());
-
- // Verify that the server list exists and contains the correct number of
- // servers.
- const DnsServerInfoStoragePtr& servers = domain->getServers();
- EXPECT_TRUE(servers);
- count = servers->size();
- EXPECT_EQ(3, count);
-
- // Fetch each server and verify its contents.
- DnsServerInfoPtr server = (*servers)[0];
- EXPECT_TRUE(server);
-
- EXPECT_TRUE(checkServer(server, "", "127.0.0.1", 100));
-
- server = (*servers)[1];
- EXPECT_TRUE(server);
-
- EXPECT_TRUE(checkServer(server, "", "127.0.0.2", 200));
-
- server = (*servers)[2];
- EXPECT_TRUE(server);
-
- EXPECT_TRUE(checkServer(server, "", "127.0.0.3", 300));
-}
-
-/// @brief Tests the fundamentals of parsing DdnsDomain lists.
-/// This test verifies that given a valid domain list configuration
-/// it will accurately parse and populate each domain in the list.
-TEST_F(DdnsDomainTest, DdnsDomainListParsing) {
- // Create a valid domain list configuration, with two domains
- // that have three servers each.
- std::string config =
- "[ "
- "{ \"name\": \"tmark.org\" , "
- " \"key-name\": \"d2_key.tmark.org\" , "
- " \"dns-servers\" : [ "
- " { \"ip-address\": \"127.0.0.1\" , "
- " \"port\": 100 },"
- " { \"ip-address\": \"127.0.0.2\" , "
- " \"port\": 200 },"
- " { \"ip-address\": \"127.0.0.3\" , "
- " \"port\": 300 } ] } "
- ", "
- "{ \"name\": \"billcat.net\" , "
- " \"key-name\": \"d2_key.billcat.net\" , "
- " \"dns-servers\" : [ "
- " { \"ip-address\": \"127.0.0.4\" , "
- " \"port\": 400 },"
- " { \"ip-address\": \"127.0.0.5\" , "
- " \"port\": 500 },"
- " { \"ip-address\": \"127.0.0.6\" , "
- " \"port\": 600 } ] } "
- "] ";
-
- ASSERT_TRUE(fromJSON(config));
-
- // Add keys to key map so key validation passes.
- addKey("d2_key.tmark.org", "HMAC-MD5", "GWG/Xfbju4O2iXGqkSu4PQ==");
- addKey("d2_key.billcat.net", "HMAC-MD5", "GWG/Xfbju4O2iXGqkSu4PQ==");
-
- // Create the list parser
- isc::dhcp::ParserPtr list_parser;
- ASSERT_NO_THROW(list_parser.reset(
- new DdnsDomainListParser("test", domains_, keys_)));
-
- // Verify that the domain configuration builds and commits without error.
- ASSERT_NO_THROW(list_parser->build(config_set_));
- ASSERT_NO_THROW(list_parser->commit());
-
- // Verify that the domain storage contains the correct number of domains.
- int count = domains_->size();
- EXPECT_EQ(2, count);
-
- // Verify that the first domain exists and can be retrieved.
- DdnsDomainMap::iterator gotit = domains_->find("tmark.org");
- ASSERT_TRUE(gotit != domains_->end());
- DdnsDomainPtr& domain = gotit->second;
-
- // Verify the name and key_name values of the first domain.
- EXPECT_EQ("tmark.org", domain->getName());
- EXPECT_EQ("d2_key.tmark.org", domain->getKeyName());
- ASSERT_TRUE(domain->getTSIGKeyInfo());
- ASSERT_TRUE(domain->getTSIGKeyInfo()->getTSIGKey());
-
- // Verify the each of the first domain's servers
- DnsServerInfoStoragePtr servers = domain->getServers();
- EXPECT_TRUE(servers);
- count = servers->size();
- EXPECT_EQ(3, count);
-
- DnsServerInfoPtr server = (*servers)[0];
- EXPECT_TRUE(server);
- EXPECT_TRUE(checkServer(server, "", "127.0.0.1", 100));
-
- server = (*servers)[1];
- EXPECT_TRUE(server);
- EXPECT_TRUE(checkServer(server, "", "127.0.0.2", 200));
-
- server = (*servers)[2];
- EXPECT_TRUE(server);
- EXPECT_TRUE(checkServer(server, "", "127.0.0.3", 300));
-
- // Verify second domain
- gotit = domains_->find("billcat.net");
- ASSERT_TRUE(gotit != domains_->end());
- domain = gotit->second;
-
- // Verify the name and key_name values of the second domain.
- EXPECT_EQ("billcat.net", domain->getName());
- EXPECT_EQ("d2_key.billcat.net", domain->getKeyName());
- ASSERT_TRUE(domain->getTSIGKeyInfo());
- ASSERT_TRUE(domain->getTSIGKeyInfo()->getTSIGKey());
-
- // Verify the each of second domain's servers
- servers = domain->getServers();
- EXPECT_TRUE(servers);
- count = servers->size();
- EXPECT_EQ(3, count);
-
- server = (*servers)[0];
- EXPECT_TRUE(server);
- EXPECT_TRUE(checkServer(server, "", "127.0.0.4", 400));
-
- server = (*servers)[1];
- EXPECT_TRUE(server);
- EXPECT_TRUE(checkServer(server, "", "127.0.0.5", 500));
-
- server = (*servers)[2];
- EXPECT_TRUE(server);
- EXPECT_TRUE(checkServer(server, "", "127.0.0.6", 600));
-}
-
-/// @brief Tests that a domain list configuration cannot contain duplicates.
-TEST_F(DdnsDomainTest, duplicateDomain) {
- // Create a domain list configuration that contains two domains with
- // the same name.
- std::string config =
- "[ "
- "{ \"name\": \"tmark.org\" , "
- " \"dns-servers\" : [ "
- " { \"ip-address\": \"127.0.0.3\" , "
- " \"port\": 300 } ] } "
- ", "
- "{ \"name\": \"tmark.org\" , "
- " \"dns-servers\" : [ "
- " { \"ip-address\": \"127.0.0.3\" , "
- " \"port\": 300 } ] } "
- "] ";
- ASSERT_TRUE(fromJSON(config));
-
- // Create the list parser
- isc::dhcp::ParserPtr list_parser;
- ASSERT_NO_THROW(list_parser.reset(
- new DdnsDomainListParser("test", domains_, keys_)));
-
- // Verify that the parse build fails.
- EXPECT_THROW(list_parser->build(config_set_), D2CfgError);
-}
+// DdnsDomainList and TSIGKey tests moved to d2_simple_parser_unittest.cc
/// @brief Tests construction of D2CfgMgr
/// This test verifies that a D2CfgMgr constructs properly.