|
@@ -140,7 +140,7 @@ TEST(Subnet4Test, Subnet4_Pool4_checks) {
|
|
|
}
|
|
|
|
|
|
// Tests whether Subnet4 object is able to store and process properly
|
|
|
-// information about allowed client classes.
|
|
|
+// information about allowed client class (a single class).
|
|
|
TEST(Subnet4Test, clientClasses) {
|
|
|
// Create the V4 subnet.
|
|
|
Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 8, 1, 2, 3));
|
|
@@ -177,6 +177,42 @@ TEST(Subnet4Test, clientClasses) {
|
|
|
EXPECT_TRUE(subnet->clientSupported(three_classes));
|
|
|
}
|
|
|
|
|
|
+// Tests whether Subnet4 object is able to store and process properly
|
|
|
+// information about allowed client classes (multiple classes allowed).
|
|
|
+TEST(Subnet4Test, clientClassesMultiple) {
|
|
|
+ // Create the V4 subnet.
|
|
|
+ Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 8, 1, 2, 3));
|
|
|
+
|
|
|
+ // This client does not belong to any class.
|
|
|
+ isc::dhcp::ClientClasses no_class;
|
|
|
+
|
|
|
+ // This client belongs to foo only.
|
|
|
+ isc::dhcp::ClientClasses foo_class;
|
|
|
+ foo_class.insert("foo");
|
|
|
+
|
|
|
+ // This client belongs to bar only. I like that client.
|
|
|
+ isc::dhcp::ClientClasses bar_class;
|
|
|
+ bar_class.insert("bar");
|
|
|
+
|
|
|
+ // No class restrictions defined, any client should be supported
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(no_class));
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(foo_class));
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(bar_class));
|
|
|
+
|
|
|
+ // Let's allow clients belongning to "bar" or "foo" class.
|
|
|
+ subnet->allowClientClass("bar");
|
|
|
+ subnet->allowClientClass("foo");
|
|
|
+
|
|
|
+ // Class-less clients are to be rejected.
|
|
|
+ EXPECT_FALSE(subnet->clientSupported(no_class));
|
|
|
+
|
|
|
+ // Clients in foo class should be accepted.
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(foo_class));
|
|
|
+
|
|
|
+ // Clients in bar class should be accepted as well.
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(bar_class));
|
|
|
+}
|
|
|
+
|
|
|
TEST(Subnet4Test, addInvalidOption) {
|
|
|
// Create the V4 subnet.
|
|
|
Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 8, 1, 2, 3));
|
|
@@ -455,7 +491,7 @@ TEST(Subnet6Test, PoolTypes) {
|
|
|
}
|
|
|
|
|
|
// Tests whether Subnet6 object is able to store and process properly
|
|
|
-// information about allowed client classes.
|
|
|
+// information about allowed client class (a single class).
|
|
|
TEST(Subnet6Test, clientClasses) {
|
|
|
// Create the V6 subnet.
|
|
|
Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
|
|
@@ -492,6 +528,42 @@ TEST(Subnet6Test, clientClasses) {
|
|
|
EXPECT_TRUE(subnet->clientSupported(three_classes));
|
|
|
}
|
|
|
|
|
|
+// Tests whether Subnet6 object is able to store and process properly
|
|
|
+// information about allowed client class (multiple classes allowed).
|
|
|
+TEST(Subnet6Test, clientClassesMultiple) {
|
|
|
+ // Create the V6 subnet.
|
|
|
+ Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
|
|
|
+
|
|
|
+ // This client does not belong to any class.
|
|
|
+ isc::dhcp::ClientClasses no_class;
|
|
|
+
|
|
|
+ // This client belongs to foo only.
|
|
|
+ isc::dhcp::ClientClasses foo_class;
|
|
|
+ foo_class.insert("foo");
|
|
|
+
|
|
|
+ // This client belongs to bar only. I like that client.
|
|
|
+ isc::dhcp::ClientClasses bar_class;
|
|
|
+ bar_class.insert("bar");
|
|
|
+
|
|
|
+ // No class restrictions defined, any client should be supported
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(no_class));
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(foo_class));
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(bar_class));
|
|
|
+
|
|
|
+ // Let's allow only clients belongning to "foo" or "bar" class.
|
|
|
+ subnet->allowClientClass("foo");
|
|
|
+ subnet->allowClientClass("bar");
|
|
|
+
|
|
|
+ // Class-less clients are to be rejected.
|
|
|
+ EXPECT_FALSE(subnet->clientSupported(no_class));
|
|
|
+
|
|
|
+ // Clients in foo class should be accepted.
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(foo_class));
|
|
|
+
|
|
|
+ // Clients in bar class should be accepted as well.
|
|
|
+ EXPECT_TRUE(subnet->clientSupported(bar_class));
|
|
|
+}
|
|
|
+
|
|
|
TEST(Subnet6Test, Subnet6_Pool6_checks) {
|
|
|
|
|
|
Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
|