Commit 589cbb4e authored by Francis Dupont's avatar Francis Dupont
Browse files

[5351] Checkpoint: almost finished shared_network

parent 06c31117
......@@ -2689,6 +2689,7 @@ YY_RULE_SETUP
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::SUBNET4:
case isc::dhcp::Parser4Context::POOLS:
case isc::dhcp::Parser4Context::SHARED_NETWORK:
return isc::dhcp::Dhcp4Parser::make_USER_CONTEXT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("user-context", driver.loc_);
......@@ -2702,6 +2703,7 @@ YY_RULE_SETUP
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::SUBNET4:
case isc::dhcp::Parser4Context::POOLS:
case isc::dhcp::Parser4Context::SHARED_NETWORK:
return isc::dhcp::Dhcp4Parser::make_COMMENT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("comment", driver.loc_);
......
......@@ -580,6 +580,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::SUBNET4:
case isc::dhcp::Parser4Context::POOLS:
case isc::dhcp::Parser4Context::SHARED_NETWORK:
return isc::dhcp::Dhcp4Parser::make_USER_CONTEXT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("user-context", driver.loc_);
......@@ -590,6 +591,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::SUBNET4:
case isc::dhcp::Parser4Context::POOLS:
case isc::dhcp::Parser4Context::SHARED_NETWORK:
return isc::dhcp::Dhcp4Parser::make_COMMENT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("comment", driver.loc_);
......
......@@ -15,6 +15,7 @@
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/cfg_subnets4.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcp4/json_config_parser.h>
#include <dhcp4/tests/dhcp4_client.h>
#include <dhcp4/tests/dhcp4_test_utils.h>
#include <stats/stats_mgr.h>
......@@ -45,6 +46,7 @@ const char* NETWORKS_CONFIG[] = {
" {"
" \"name\": \"frog\","
" \"interface\": \"eth1\","
" \"comment\": \"example\","
" \"subnet4\": ["
" {"
" \"subnet\": \"192.0.2.0/26\","
......@@ -1062,6 +1064,38 @@ public:
IfaceMgrTestConfig iface_mgr_test_config_;
};
// Check user-context parsing
TEST_F(Dhcpv4SharedNetworkTest, parse) {
// Create client
Dhcp4Client client1(Dhcp4Client::SELECTING);
// Don't use configure from utils
Parser4Context ctx;
ConstElementPtr json;
ASSERT_NO_THROW(json = parseDHCP4(NETWORKS_CONFIG[0], true));
ConstElementPtr status;
disableIfacesReDetect(json);
EXPECT_NO_THROW(status = configureDhcp4Server(*client1.getServer(), json));
ASSERT_TRUE(status);
int rcode;
ConstElementPtr comment = config::parseAnswer(rcode, status);
ASSERT_EQ(0, rcode);
ASSERT_NO_THROW( {
CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
cfg_db->setAppendedParameters("universe=4");
cfg_db->createManagers();
} );
CfgMgr::instance().commit();
CfgSharedNetworks4Ptr cfg = CfgMgr::instance().getCurrentCfg()->getCfgSharedNetworks4();
SharedNetwork4Ptr network = cfg->getByName("frog");
ConstElementPtr context = network->getContext();
ASSERT_TRUE(context);
ASSERT_EQ(1, context->size());
ASSERT_TRUE(context->get("comment"));
EXPECT_EQ("\"example\"", context->get("comment")->str());
}
// Running out of addresses within a subnet in a shared network.
TEST_F(Dhcpv4SharedNetworkTest, poolInSharedNetworkShortage) {
// Create client #1
......
......@@ -811,6 +811,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
case isc::dhcp::Parser6Context::POOLS:
case isc::dhcp::Parser6Context::PD_POOLS:
case isc::dhcp::Parser6Context::SUBNET6:
case isc::dhcp::Parser6Context::SHARED_NETWORK:
return isc::dhcp::Dhcp6Parser::make_USER_CONTEXT(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("user-context", driver.loc_);
......@@ -822,6 +823,7 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
case isc::dhcp::Parser6Context::POOLS:
case isc::dhcp::Parser6Context::PD_POOLS:
case isc::dhcp::Parser6Context::SUBNET6:
case isc::dhcp::Parser6Context::SHARED_NETWORK:
return isc::dhcp::Dhcp6Parser::make_COMMENT(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("comment", driver.loc_);
......
......@@ -13,8 +13,10 @@
#include <dhcpsrv/cfg_subnets6.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcp6/json_config_parser.h>
#include <dhcp6/tests/dhcp6_client.h>
#include <dhcp6/tests/dhcp6_test_utils.h>
#include <cc/command_interpreter.h>
#include <stats/stats_mgr.h>
#include <boost/pointer_cast.hpp>
#include <functional>
......@@ -38,6 +40,7 @@ const char* NETWORKS_CONFIG[] = {
" {"
" \"name\": \"frog\","
" \"interface\": \"eth1\","
" \"comment\": \"example\","
" \"subnet6\": ["
" {"
" \"subnet\": \"2001:db8:1::/64\","
......@@ -1316,6 +1319,33 @@ public:
IfaceMgrTestConfig iface_mgr_test_config_;
};
// Check user-context parsing
TEST_F(Dhcpv6SharedNetworkTest, parse) {
// Create client
Dhcp6Client client1;
// Don't use configure from utils
Parser6Context ctx;
ConstElementPtr json;
ASSERT_NO_THROW(json = parseDHCP6(NETWORKS_CONFIG[0], true));
ConstElementPtr status;
disableIfacesReDetect(json);
EXPECT_NO_THROW(status = configureDhcp6Server(*client1.getServer(), json));
ASSERT_TRUE(status);
int rcode;
ConstElementPtr comment = config::parseAnswer(rcode, status);
ASSERT_EQ(0, rcode);
CfgMgr::instance().commit();
CfgSharedNetworks6Ptr cfg = CfgMgr::instance().getCurrentCfg()->getCfgSharedNetworks6();
SharedNetwork6Ptr network = cfg->getByName("frog");
ConstElementPtr context = network->getContext();
ASSERT_TRUE(context);
ASSERT_EQ(1, context->size());
ASSERT_TRUE(context->get("comment"));
EXPECT_EQ("\"example\"", context->get("comment")->str());
}
// Running out of addresses within a subnet in a shared network.
TEST_F(Dhcpv6SharedNetworkTest, addressPoolInSharedNetworkShortage) {
// Create client #1.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment