|
@@ -182,6 +182,9 @@ protected:
|
|
|
|
|
|
/// @brief Vector holding circuit id used by tests.
|
|
|
std::vector<uint8_t> circuit_id_;
|
|
|
+
|
|
|
+ /// @brief Vector holding client id used by tests.
|
|
|
+ std::vector<uint8_t> client_id_;
|
|
|
};
|
|
|
|
|
|
void
|
|
@@ -199,6 +202,11 @@ HostReservationParserTest::SetUp() {
|
|
|
|
|
|
const std::string circuit_id_str = "howdy";
|
|
|
circuit_id_.assign(circuit_id_str.begin(), circuit_id_str.end());
|
|
|
+
|
|
|
+ client_id_.push_back(0x01); // Client identifier type.
|
|
|
+ // Often client id comprises HW address.
|
|
|
+ client_id_.insert(client_id_.end(), hwaddr_->hwaddr_.begin(),
|
|
|
+ hwaddr_->hwaddr_.end());
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -252,6 +260,22 @@ TEST_F(HostReservationParserTest, dhcp4CircuitIdHexWithPrefix) {
|
|
|
circuit_id_);
|
|
|
}
|
|
|
|
|
|
+// This test verifies that the parser can parse a reservation entry for
|
|
|
+// which client-id is an identifier. The client-id is specified in
|
|
|
+// hexadecimal format.
|
|
|
+TEST_F(HostReservationParserTest, dhcp4ClientIdHex) {
|
|
|
+ testIdentifier4("client-id", "01010203040506", Host::IDENT_CLIENT_ID,
|
|
|
+ client_id_);
|
|
|
+}
|
|
|
+
|
|
|
+// This test verifies that the parser can parse a reservation entry for
|
|
|
+// which client-id is an identifier. The client-id is specified in
|
|
|
+// hexadecimal format with a '0x' prefix.
|
|
|
+TEST_F(HostReservationParserTest, dhcp4ClientIdHexWithPrefix) {
|
|
|
+ testIdentifier4("client-id", "0x01010203040506", Host::IDENT_CLIENT_ID,
|
|
|
+ client_id_);
|
|
|
+}
|
|
|
+
|
|
|
// This test verifies that the parser can parse the reservation entry
|
|
|
// when IPv4 address is specified, but hostname is not.
|
|
|
TEST_F(HostReservationParserTest, dhcp4NoHostname) {
|
|
@@ -465,6 +489,17 @@ TEST_F(HostReservationParserTest, dhcp6CircuitId) {
|
|
|
testInvalidConfig<HostReservationParser6>(config);
|
|
|
}
|
|
|
|
|
|
+// This test verifies that host reservation parser for DHCPv6 rejects
|
|
|
+// "client-id" as a host identifier.
|
|
|
+TEST_F(HostReservationParserTest, dhcp6ClientId) {
|
|
|
+ // Use DHCPv4 specific identifier 'client-id' with DHCPv6 parser.
|
|
|
+ std::string config = "{ \"client-id\": \"01010203040506\","
|
|
|
+ "\"ip-addresses\": [ \"2001:db8:1::100\", \"2001:db8:1::200\" ],"
|
|
|
+ "\"prefixes\": [ ],"
|
|
|
+ "\"hostname\": \"foo.example.com\" }";
|
|
|
+ testInvalidConfig<HostReservationParser6>(config);
|
|
|
+}
|
|
|
+
|
|
|
// This test verfies that the parser can parse the IPv6 reservation entry
|
|
|
// which lacks hostname parameter.
|
|
|
TEST_F(HostReservationParserTest, dhcp6NoHostname) {
|
|
@@ -818,7 +853,8 @@ public:
|
|
|
// Test that list of supported DHCPv4 identifiers list is correctly
|
|
|
// parsed.
|
|
|
TEST_F(HostReservationIdsParserTest, dhcp4Identifiers) {
|
|
|
- std::string config = "[ \"circuit-id\", \"duid\", \"hw-address\" ]";
|
|
|
+ std::string config =
|
|
|
+ "[ \"circuit-id\", \"duid\", \"hw-address\", \"client-id\" ]";
|
|
|
|
|
|
ElementPtr config_element = Element::fromJSON(config);
|
|
|
|
|
@@ -828,12 +864,13 @@ TEST_F(HostReservationIdsParserTest, dhcp4Identifiers) {
|
|
|
ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
|
|
|
getCfgHostOperations4();
|
|
|
const CfgHostOperations::IdentifierTypes& ids = cfg->getIdentifierTypes();
|
|
|
- ASSERT_EQ(3, ids.size());
|
|
|
+ ASSERT_EQ(4, ids.size());
|
|
|
|
|
|
CfgHostOperations::IdentifierTypes::const_iterator id = ids.begin();
|
|
|
EXPECT_EQ(*id++, Host::IDENT_CIRCUIT_ID);
|
|
|
EXPECT_EQ(*id++, Host::IDENT_DUID);
|
|
|
EXPECT_EQ(*id++, Host::IDENT_HWADDR);
|
|
|
+ EXPECT_EQ(*id++, Host::IDENT_CLIENT_ID);
|
|
|
}
|
|
|
|
|
|
// Test that list of supported DHCPv6 identifiers list is correctly
|
|
@@ -883,12 +920,13 @@ TEST_F(HostReservationIdsParserTest, dhcp4AutoIdentifiers) {
|
|
|
ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
|
|
|
getCfgHostOperations4();
|
|
|
const CfgHostOperations::IdentifierTypes& ids = cfg->getIdentifierTypes();
|
|
|
- ASSERT_EQ(3, ids.size());
|
|
|
+ ASSERT_EQ(4, ids.size());
|
|
|
|
|
|
CfgHostOperations::IdentifierTypes::const_iterator id = ids.begin();
|
|
|
EXPECT_EQ(*id++, Host::IDENT_HWADDR);
|
|
|
EXPECT_EQ(*id++, Host::IDENT_DUID);
|
|
|
EXPECT_EQ(*id++, Host::IDENT_CIRCUIT_ID);
|
|
|
+ EXPECT_EQ(*id++, Host::IDENT_CLIENT_ID);
|
|
|
}
|
|
|
|
|
|
// This test verifies that use of "auto" together with an explicit
|