diff options
author | Francis Dupont <fdupont@isc.org> | 2017-01-27 20:59:53 +0100 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2017-01-27 20:59:53 +0100 |
commit | a5029481bb825bf877efd73cb395066cfb45511e (patch) | |
tree | db232d7f06885687a7b4c17e0450794a0c916749 | |
parent | [4501] Merged trac5113 (a few new unit tests) (diff) | |
download | kea-a5029481bb825bf877efd73cb395066cfb45511e.tar.xz kea-a5029481bb825bf877efd73cb395066cfb45511e.zip |
[4501] Added invalid (min > max) pool range unit tests
-rw-r--r-- | src/bin/dhcp4/tests/config_parser_unittest.cc | 28 | ||||
-rw-r--r-- | src/bin/dhcp6/tests/config_parser_unittest.cc | 29 |
2 files changed, 57 insertions, 0 deletions
diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index 031301a45e..0d3230b26e 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -4691,5 +4691,33 @@ TEST_F(Dhcp4ParserTest, pooMinMaxlUserContext) { EXPECT_EQ(true, bool_value); } +// Test verifies the error message for an incorrect pool range +// is what we expect. +TEST_F(Dhcp4ParserTest, invalidPoolRange) { + string config = "{ " + genIfaceConfig() + ", \n" + + "\"valid-lifetime\": 4000, \n" + "\"rebind-timer\": 2000, \n" + "\"renew-timer\": 1000, \n" + "\"subnet4\": [ { \n" + " \"pools\": [ { \"pool\": \"192.0.2.1 - 19.2.0.200\" } ], \n" + " \"subnet\": \"192.0.2.0/24\" \n" + " } ] \n" + "} \n"; + + ConstElementPtr json; + ASSERT_NO_THROW(json = parseDHCP4(config, true)); + + ConstElementPtr status; + EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json)); + ASSERT_TRUE(status); + int rcode; + ConstElementPtr comment = parseAnswer(rcode, status); + string text; + ASSERT_NO_THROW(text = comment->stringValue()); + + EXPECT_EQ(1, rcode); + string expected = "Failed to create pool defined by: 192.0.2.1-19.2.0.200 (<string>:6:26)"; + EXPECT_EQ(expected, text); +} } diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index d606ab1a3a..ffe90fc1c1 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -5162,5 +5162,34 @@ TEST_F(Dhcp6ParserTest, pdPoolUserContextlw4over6) { EXPECT_EQ(56L, int_value); } +// Test verifies the error message for an incorrect pool range +// is what we expect. +TEST_F(Dhcp6ParserTest, invalidPoolRange) { + string config = "{ " + genIfaceConfig() + ", \n" + + "\"valid-lifetime\": 4000, \n" + "\"preferred-lifetime\": 3000, \n" + "\"rebind-timer\": 2000, \n" + "\"renew-timer\": 1000, \n" + "\"subnet6\": [ { \n" + " \"pools\": [ { \"pool\": \"2001:db8:: - 200:1db8::ffff\" } ], \n" + " \"subnet\": \"2001:db8::/32\" \n" + " } ] \n" + "} \n"; + + ConstElementPtr json; + ASSERT_NO_THROW(json = parseDHCP6(config, true)); + + ConstElementPtr status; + EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json)); + ASSERT_TRUE(status); + int rcode; + ConstElementPtr comment = parseAnswer(rcode, status); + string text; + ASSERT_NO_THROW(text = comment->stringValue()); + + EXPECT_EQ(1, rcode); + string expected = "Failed to create pool defined by: 2001:db8::-200:1db8::ffff (<string>:7:26)"; + EXPECT_EQ(expected, text); +} }; |