mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[#2430] Addressed review comments
src/lib/dhcpsrv/parsers/client_class_def_parser.cc ClientClassDefParser::parse() - throws if user-context is not a map src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc TEST_F(ClientClassDefParserTest, invalidUserContext) - new test src/hooks/dhcp/pgsql_cb/pgsql_cb_dhcp6.cc src/share/database/scripts/mysql/dhcpdb_create.mysql src/share/database/scripts/pgsql/dhcpdb_create.pgsql src/share/database/scripts/pgsql/upgrade_011_to_012.sh.in typos
This commit is contained in:
@@ -4448,7 +4448,7 @@ TaggedStatementArray tagged_statements = { {
|
||||
OID_INT8, // 10 min_preferred_lifetime
|
||||
OID_INT8, // 11 max_preferred_lifetime
|
||||
OID_TIMESTAMP, // 12 modification_ts
|
||||
OID_TEXT, // 13 user_conetx
|
||||
OID_TEXT, // 13 user_context
|
||||
OID_VARCHAR // 14 name (of class to update)
|
||||
},
|
||||
"UPDATE_CLIENT_CLASS6",
|
||||
@@ -4472,7 +4472,7 @@ TaggedStatementArray tagged_statements = { {
|
||||
OID_INT8, // 10 min_preferred_lifetime
|
||||
OID_INT8, // 11 max_preferred_lifetime
|
||||
OID_TIMESTAMP, // 12 modification_ts
|
||||
OID_TEXT, // 13 user_conetx
|
||||
OID_TEXT, // 13 user_context
|
||||
OID_VARCHAR // 14 name (of class to update)
|
||||
},
|
||||
"UPDATE_CLIENT_CLASS6_SAME_POSITION",
|
||||
|
@@ -142,6 +142,12 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary,
|
||||
|
||||
// Parse user context
|
||||
ConstElementPtr user_context = class_def_cfg->get("user-context");
|
||||
if (user_context) {
|
||||
if (user_context->getType() != Element::map) {
|
||||
isc_throw(isc::dhcp::DhcpConfigError, "User context has to be a map ("
|
||||
<< user_context->getPosition() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
// Let's try to parse the only-if-required flag
|
||||
bool required = false;
|
||||
|
@@ -1438,5 +1438,17 @@ TEST_F(ClientClassDefParserTest, preferredLifetimeTests) {
|
||||
}
|
||||
}
|
||||
|
||||
// Verifies that an invalid user-context fails to parse.
|
||||
TEST_F(ClientClassDefParserTest, invalidUserContext) {
|
||||
std::string cfg_text =
|
||||
"{ \n"
|
||||
" \"name\": \"one\", \n"
|
||||
" \"user-context\": \"i am not a map\" \n"
|
||||
"} \n";
|
||||
|
||||
ClientClassDefPtr cclass;
|
||||
ASSERT_THROW_MSG(cclass = parseClientClassDef(cfg_text, AF_INET),
|
||||
DhcpConfigError, "User context has to be a map (<string>:3:20)");
|
||||
}
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
@@ -4344,7 +4344,7 @@ CREATE TRIGGER dhcp6_shared_network_BDEL BEFORE DELETE ON dhcp6_shared_network
|
||||
END $$
|
||||
DELIMITER ;
|
||||
|
||||
-- Add user_context column to Client class tables.
|
||||
-- Add user_context column to client class tables.
|
||||
ALTER TABLE dhcp4_client_class ADD COLUMN user_context LONGTEXT NULL;
|
||||
ALTER TABLE dhcp6_client_class ADD COLUMN user_context LONGTEXT NULL;
|
||||
|
||||
|
@@ -110,7 +110,7 @@ CREATE TRIGGER dhcp6_shared_network_BDEL BEFORE DELETE ON dhcp6_shared_network
|
||||
END $$
|
||||
DELIMITER ;
|
||||
|
||||
-- Add user_context column to Client class tables.
|
||||
-- Add user_context column to client class tables.
|
||||
ALTER TABLE dhcp4_client_class ADD COLUMN user_context LONGTEXT NULL;
|
||||
ALTER TABLE dhcp6_client_class ADD COLUMN user_context LONGTEXT NULL;
|
||||
|
||||
|
@@ -4969,7 +4969,7 @@ END;
|
||||
$dhcp6_shared_network_BDEL$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
-- Add user_context column to Client class tables.
|
||||
-- Add user_context column to client class tables.
|
||||
ALTER TABLE dhcp4_client_class ADD COLUMN user_context JSON DEFAULT NULL;
|
||||
ALTER TABLE dhcp6_client_class ADD COLUMN user_context JSON DEFAULT NULL;
|
||||
|
||||
|
@@ -90,7 +90,7 @@ END;
|
||||
\$dhcp6_shared_network_BDEL\$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
-- Add user_context column to Client class tables.
|
||||
-- Add user_context column to client class tables.
|
||||
ALTER TABLE dhcp4_client_class ADD COLUMN user_context JSON DEFAULT NULL;
|
||||
ALTER TABLE dhcp6_client_class ADD COLUMN user_context JSON DEFAULT NULL;
|
||||
|
||||
|
Reference in New Issue
Block a user