Commit c49d5606 authored by Marcin Siodelski's avatar Marcin Siodelski

[3409] Unit tests check that the error message contains line number etc.

parent 17db85fe
......@@ -1466,6 +1466,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
src/lib/dhcp_ddns/tests/Makefile
src/lib/dhcp/Makefile
src/lib/dhcpsrv/Makefile
src/lib/dhcpsrv/testutils/Makefile
src/lib/dhcpsrv/tests/Makefile
src/lib/dhcpsrv/tests/test_libraries.h
src/lib/dhcp/tests/Makefile
......
......@@ -106,6 +106,7 @@ dhcp4_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
endif
noinst_PROGRAMS = $(TESTS)
......@@ -27,6 +27,7 @@
#include <dhcp/classify.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/testutils/config_result_check.h>
#include <hooks/hooks_manager.h>
#include "marker_file.h"
......@@ -286,9 +287,8 @@ public:
std::string config = createConfigWithOption(param_value, parameter);
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(1, rcode_);
checkResult(x, 1);
EXPECT_TRUE(errorContainsPosition(x, "<string>"));
}
/// @brief Test invalid option paramater value.
......@@ -304,9 +304,8 @@ public:
std::string config = createConfigWithOption(params);
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(1, rcode_);
checkResult(x, 1);
EXPECT_TRUE(errorContainsPosition(x, "<string>"));
}
/// @brief Test option against given code and data.
......@@ -580,9 +579,7 @@ TEST_F(Dhcp4ParserTest, multipleSubnets) {
do {
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
const Subnet4Collection* subnets = CfgMgr::instance().getSubnets4();
ASSERT_TRUE(subnets);
......@@ -635,9 +632,7 @@ TEST_F(Dhcp4ParserTest, multipleSubnetsExplicitIDs) {
int cnt = 0; // Number of reconfigurations
do {
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
const Subnet4Collection* subnets = CfgMgr::instance().getSubnets4();
ASSERT_TRUE(subnets);
......@@ -686,9 +681,8 @@ TEST_F(Dhcp4ParserTest, multipleSubnetsOverlapingIDs) {
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
EXPECT_NE(rcode_, 0);
checkResult(x, 2);
EXPECT_TRUE(errorContainsPosition(x, "<string>"));
}
// Goal of this test is to verify that a previously configured subnet can be
......@@ -769,9 +763,7 @@ TEST_F(Dhcp4ParserTest, reconfigureRemoveSubnet) {
ElementPtr json = Element::fromJSON(config4);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
const Subnet4Collection* subnets = CfgMgr::instance().getSubnets4();
ASSERT_TRUE(subnets);
......@@ -780,9 +772,7 @@ TEST_F(Dhcp4ParserTest, reconfigureRemoveSubnet) {
// Do the reconfiguration (the last subnet is removed)
json = Element::fromJSON(config_first3);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
subnets = CfgMgr::instance().getSubnets4();
ASSERT_TRUE(subnets);
......@@ -799,16 +789,12 @@ TEST_F(Dhcp4ParserTest, reconfigureRemoveSubnet) {
/// @todo: Uncomment subnet removal test as part of #3281.
json = Element::fromJSON(config4);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
// Do reconfiguration
json = Element::fromJSON(config_second_removed);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
subnets = CfgMgr::instance().getSubnets4();
ASSERT_TRUE(subnets);
......@@ -932,12 +918,15 @@ TEST_F(Dhcp4ParserTest, nextServerNegative) {
// check if returned status is always a failure
EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json1));
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json2));
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json3));
checkResult(status, 0);
EXPECT_FALSE(errorContainsPosition(status, "<string>"));
}
// Checks if the next-server defined as global value is overridden by subnet
......@@ -1065,6 +1054,7 @@ TEST_F(Dhcp4ParserTest, poolOutOfSubnet) {
// returned value must be 1 (values error)
// as the pool does not belong to that subnet
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
// Goal of this test is to verify if pools can be defined
......@@ -1284,6 +1274,7 @@ TEST_F(Dhcp4ParserTest, optionDefDuplicate) {
EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(status);
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
// The goal of this test is to verify that the option definition
......@@ -1392,6 +1383,7 @@ TEST_F(Dhcp4ParserTest, optionDefInvalidName) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The purpose of this test is to verify that the option definition
......@@ -1418,6 +1410,7 @@ TEST_F(Dhcp4ParserTest, optionDefInvalidType) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The purpose of this test is to verify that the option definition
......@@ -1444,6 +1437,7 @@ TEST_F(Dhcp4ParserTest, optionDefInvalidRecordType) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The goal of this test is to verify that the invalid encapsulated
......@@ -1470,6 +1464,7 @@ TEST_F(Dhcp4ParserTest, optionDefInvalidEncapsulatedSpace) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The goal of this test is to verify that the encapsulated
......@@ -1498,6 +1493,7 @@ TEST_F(Dhcp4ParserTest, optionDefEncapsulatedSpaceAndArray) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The goal of this test is to verify that the option may not
......@@ -1524,6 +1520,7 @@ TEST_F(Dhcp4ParserTest, optionDefEncapsulateOwnSpace) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The purpose of this test is to verify that it is not allowed
......@@ -1588,6 +1585,7 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
/// @todo The option 65 is a standard DHCPv4 option. However, at this point
/// there is no definition for this option in libdhcp++, so it should be
......@@ -1655,9 +1653,7 @@ TEST_F(Dhcp4ParserTest, optionDataDefaults) {
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.200"),
classify_);
......@@ -1960,9 +1956,7 @@ TEST_F(Dhcp4ParserTest, optionDataInSingleSubnet) {
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.24"),
classify_);
......@@ -2113,9 +2107,7 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) {
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
Subnet4Ptr subnet1 = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.100"),
classify_);
......@@ -2218,9 +2210,7 @@ TEST_F(Dhcp4ParserTest, optionDataLowerCase) {
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.5"),
classify_);
......@@ -2263,9 +2253,7 @@ TEST_F(Dhcp4ParserTest, stdOptionData) {
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.5"),
classify_);
......@@ -2343,6 +2331,7 @@ TEST_F(Dhcp4ParserTest, DISABLED_Uint32Parser) {
// returned value must be rejected (1 configuration error)
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
// CASE 4: -1 (UINT_MIN -1 ) should not work
EXPECT_NO_THROW(status = configureDhcp4Server(*srv_,
......@@ -2351,6 +2340,7 @@ TEST_F(Dhcp4ParserTest, DISABLED_Uint32Parser) {
// returned value must be rejected (1 configuration error)
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
// The goal of this test is to verify that the standard option can
......@@ -2935,6 +2925,7 @@ TEST_F(Dhcp4ParserTest, invalidD2ClientConfig) {
// check if returned status is failed.
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
// Verify that the D2 configuraiton can be fetched and is set to disabled.
D2ClientConfigPtr d2_client_config = CfgMgr::instance().getD2ClientConfig();
......@@ -3008,9 +2999,7 @@ TEST_F(Dhcp4ParserTest, classifySubnets) {
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp4Server(*srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
const Subnet4Collection* subnets = CfgMgr::instance().getSubnets4();
ASSERT_TRUE(subnets);
......
......@@ -101,6 +101,7 @@ dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
......
......@@ -25,6 +25,7 @@
#include <dhcpsrv/addr_utilities.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/testutils/config_result_check.h>
#include <hooks/hooks_manager.h>
#include "test_data_files_config.h"
......@@ -375,9 +376,8 @@ public:
std::string config = createConfigWithOption(param_value, parameter);
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(1, rcode_);
checkResult(x, 1);
EXPECT_TRUE(errorContainsPosition(x, "<string>"));
}
/// @brief Test invalid option paramater value.
......@@ -393,9 +393,8 @@ public:
std::string config = createConfigWithOption(params);
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(1, rcode_);
checkResult(x, 1);
EXPECT_TRUE(errorContainsPosition(x, "<string>"));
}
/// @brief Test option against given code and data.
......@@ -491,9 +490,7 @@ TEST_F(Dhcp6ParserTest, version) {
Element::fromJSON("{\"version\": 0}")));
// returned value must be 0 (configuration accepted)
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
EXPECT_EQ(0, rcode_);
checkResult(x, 0);
}
/// The goal of this test is to verify that the code accepts only
......@@ -506,9 +503,7 @@ TEST_F(Dhcp6ParserTest, bogusCommand) {
Element::fromJSON("{\"bogus\": 5}")));
// returned value must be 1 (configuration parse error)
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
EXPECT_EQ(1, rcode_);
checkResult(x, 1);
}
/// The goal of this test is to verify if configuration without any
......@@ -526,9 +521,7 @@ TEST_F(Dhcp6ParserTest, emptySubnet) {
"\"valid-lifetime\": 4000 }")));
// returned value should be 0 (success)
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(0, rcode_);
checkResult(status, 0);
}
/// The goal of this test is to verify if defined subnet uses global
......@@ -551,9 +544,7 @@ TEST_F(Dhcp6ParserTest, subnetGlobalDefaults) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// check if returned status is OK
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(0, rcode_);
checkResult(status, 0);
// Now check if the configuration was indeed handled and we have
// expected pool configured.
......@@ -602,9 +593,7 @@ TEST_F(Dhcp6ParserTest, multipleSubnets) {
do {
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
const Subnet6Collection* subnets = CfgMgr::instance().getSubnets6();
ASSERT_TRUE(subnets);
......@@ -659,9 +648,7 @@ TEST_F(Dhcp6ParserTest, multipleSubnetsExplicitIDs) {
do {
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
const Subnet6Collection* subnets = CfgMgr::instance().getSubnets6();
ASSERT_TRUE(subnets);
......@@ -711,9 +698,8 @@ TEST_F(Dhcp6ParserTest, multipleSubnetsOverlapingIDs) {
ElementPtr json = Element::fromJSON(config);
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_NE(rcode_, 0);
checkResult(x, 2);
EXPECT_TRUE(errorContainsPosition(x, "<string>"));
}
......@@ -798,9 +784,7 @@ TEST_F(Dhcp6ParserTest, reconfigureRemoveSubnet) {
ElementPtr json = Element::fromJSON(config4);
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
const Subnet6Collection* subnets = CfgMgr::instance().getSubnets6();
ASSERT_TRUE(subnets);
......@@ -809,9 +793,7 @@ TEST_F(Dhcp6ParserTest, reconfigureRemoveSubnet) {
// Do the reconfiguration (the last subnet is removed)
json = Element::fromJSON(config_first3);
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
subnets = CfgMgr::instance().getSubnets6();
ASSERT_TRUE(subnets);
......@@ -826,16 +808,12 @@ TEST_F(Dhcp6ParserTest, reconfigureRemoveSubnet) {
json = Element::fromJSON(config4);
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
// Do reconfiguration
json = Element::fromJSON(config_second_removed);
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
checkResult(x, 0);
subnets = CfgMgr::instance().getSubnets6();
ASSERT_TRUE(subnets);
......@@ -873,9 +851,7 @@ TEST_F(Dhcp6ParserTest, subnetLocal) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// returned value should be 0 (configuration success)
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(0, rcode_);
checkResult(status, 0);
Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(IOAddress("2001:db8:1::5"),
classify_);
......@@ -910,9 +886,7 @@ TEST_F(Dhcp6ParserTest, subnetInterface) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// returned value should be 0 (configuration success)
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(0, rcode_);
checkResult(status, 0);
Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(IOAddress("2001:db8:1::5"),
classify_);
......@@ -944,9 +918,8 @@ TEST_F(Dhcp6ParserTest, subnetInterfaceBogus) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// returned value should be 1 (configuration error)
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(1, rcode_);
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(IOAddress("2001:db8:1::5"),
classify_);
......@@ -976,9 +949,8 @@ TEST_F(Dhcp6ParserTest, interfaceGlobal) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// returned value should be 1 (parse error)
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(1, rcode_);
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
......@@ -1007,9 +979,7 @@ TEST_F(Dhcp6ParserTest, subnetInterfaceId) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// Returned value should be 0 (configuration success)
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(0, rcode_);
checkResult(status, 0);
// Try to get a subnet based on bogus interface-id option
OptionBuffer tmp(bogus_interface_id.begin(), bogus_interface_id.end());
......@@ -1046,9 +1016,8 @@ TEST_F(Dhcp6ParserTest, interfaceIdGlobal) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// Returned value should be 1 (parse error)
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(1, rcode_);
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
// This test checks if it is not possible to define a subnet with an
......@@ -1071,10 +1040,8 @@ TEST_F(Dhcp6ParserTest, subnetInterfaceAndInterfaceId) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// Returned value should be 1 (configuration error)
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(1, rcode_);
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
......@@ -1101,9 +1068,8 @@ TEST_F(Dhcp6ParserTest, poolOutOfSubnet) {
// returned value must be 1 (values error)
// as the pool does not belong to that subnet
ASSERT_TRUE(status);
comment_ = parseAnswer(rcode_, status);
EXPECT_EQ(1, rcode_);
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
// Goal of this test is to verify if pools can be defined
......@@ -1129,9 +1095,7 @@ TEST_F(Dhcp6ParserTest, poolPrefixLen) {
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
// returned value must be 1 (configuration parse error)
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
EXPECT_EQ(0, rcode_);
checkResult(x, 0);
Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(IOAddress("2001:db8:1::5"),
classify_);
......@@ -1172,9 +1136,7 @@ TEST_F(Dhcp6ParserTest, pdPoolBasics) {
// Returned value must be non-empty ConstElementPtr to config result.
// rcode should be 0 which indicates successful configuration processing.
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
EXPECT_EQ(0, rcode_);
checkResult(x, 0);
// Test that we can retrieve the subnet.
Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(IOAddress("2001:db8:1::5"),
......@@ -1246,9 +1208,7 @@ TEST_F(Dhcp6ParserTest, pdPoolList) {
// Returned value must be non-empty ConstElementPtr to config result.
// rcode should be 0 which indicates successful configuration processing.
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
EXPECT_EQ(0, rcode_);
checkResult(x, 0);
// Test that we can retrieve the subnet.
Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(IOAddress("2001:db8:1::5"),
......@@ -1304,9 +1264,7 @@ TEST_F(Dhcp6ParserTest, subnetAndPrefixDelegated) {
// Returned value must be non-empty ConstElementPtr to config result.
// rcode should be 0 which indicates successful configuration processing.
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
EXPECT_EQ(0, rcode_);
checkResult(x, 0);
// Test that we can retrieve the subnet.
Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(IOAddress("2001:db8:1::5"),
......@@ -1423,9 +1381,8 @@ TEST_F(Dhcp6ParserTest, invalidPdPools) {
// Returned value must be non-empty ConstElementPtr to config result.
// rcode should be 1 which indicates configuration error.
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
EXPECT_EQ(1, rcode_);
checkResult(x, 1);
EXPECT_TRUE(errorContainsPosition(x, "<string>"));
}
}
......@@ -1611,6 +1568,7 @@ TEST_F(Dhcp6ParserTest, optionDefDuplicate) {
EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
ASSERT_TRUE(status);
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
// The goal of this test is to verify that the option definition
......@@ -1718,6 +1676,7 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidName) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The purpose of this test is to verify that the option definition
......@@ -1744,6 +1703,7 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidType) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The purpose of this test is to verify that the option definition
......@@ -1770,6 +1730,7 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidRecordType) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The goal of this test is to verify that the invalid encapsulated
......@@ -1796,6 +1757,7 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidEncapsulatedSpace) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The goal of this test is to verify that the encapsulated
......@@ -1824,6 +1786,7 @@ TEST_F(Dhcp6ParserTest, optionDefEncapsulatedSpaceAndArray) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The goal of this test is to verify that the option may not
......@@ -1850,6 +1813,7 @@ TEST_F(Dhcp6ParserTest, optionDefEncapsulateOwnSpace) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
/// The purpose of this test is to verify that it is not allowed
......@@ -1915,6 +1879,7 @@ TEST_F(Dhcp6ParserTest, optionStandardDefOverride) {
ASSERT_TRUE(status);
// Expecting parsing error (error code 1).
checkResult(status, 1);
EXPECT_TRUE(errorContainsPosition(status, "<string>"));