summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2024-11-16 09:44:38 +0100
committerFrancis Dupont <fdupont@isc.org>2024-11-22 09:55:31 +0100
commit5485a3d27df2d60cec52f074e70700b2589cfcde (patch)
tree79fc99f871037d111bd2c61fd83e6b7235e39061 /src
parent[#3609] Checkpoint: done syntax (diff)
downloadkea-5485a3d27df2d60cec52f074e70700b2589cfcde.tar.xz
kea-5485a3d27df2d60cec52f074e70700b2589cfcde.zip
[#3609] Checkpoint before rebase
Diffstat (limited to 'src')
-rw-r--r--src/bin/agent/tests/ca_cfg_mgr_unittests.cc44
-rw-r--r--src/bin/dhcp4/tests/config_parser_unittest.cc17
-rw-r--r--src/bin/dhcp6/tests/config_parser_unittest.cc17
3 files changed, 63 insertions, 15 deletions
diff --git a/src/bin/agent/tests/ca_cfg_mgr_unittests.cc b/src/bin/agent/tests/ca_cfg_mgr_unittests.cc
index a7b40c5567..7c9a6364f1 100644
--- a/src/bin/agent/tests/ca_cfg_mgr_unittests.cc
+++ b/src/bin/agent/tests/ca_cfg_mgr_unittests.cc
@@ -358,6 +358,11 @@ const char* AGENT_CONFIGS[] = {
" \"user-context\": { \"comment\": \"Indirect comment\" },\n"
" \"http-host\": \"betelgeuse\",\n"
" \"http-port\": 8001,\n"
+ " \"http-headers\": [ {\n"
+ " \"comment\": \"HSTS header\",\n"
+ " \"name\": \"Strict-Transport-Security\",\n"
+ " \"value\": \"max-age=31536000\"\n"
+ " } ],\n"
" \"authentication\": {\n"
" \"comment\": \"basic HTTP authentication\",\n"
" \"type\": \"basic\",\n"
@@ -624,14 +629,23 @@ TEST_F(AgentParserTest, comments) {
ASSERT_TRUE(ctx6->get("version"));
EXPECT_EQ("1", ctx6->get("version")->str());
- // Check authentication comment.
- const HttpAuthConfigPtr& auth = agent_ctx->getAuthConfig();
- ASSERT_TRUE(auth);
- ConstElementPtr ctx7 = auth->getContext();
+ // Check HTTP header comment.
+ const CfgHttpHeaders& headers = agent_ctx->getHttpHeaders();
+ ASSERT_EQ(1, headers.size());
+ ConstElementPtr ctx7 = headers[0].getContext();
ASSERT_TRUE(ctx7);
ASSERT_EQ(1, ctx7->size());
ASSERT_TRUE(ctx7->get("comment"));
- EXPECT_EQ("\"basic HTTP authentication\"", ctx7->get("comment")->str());
+ EXPECT_EQ("\"HSTS header\"", ctx7->get("comment")->str());
+
+ // Check authentication comment.
+ const HttpAuthConfigPtr& auth = agent_ctx->getAuthConfig();
+ ASSERT_TRUE(auth);
+ ConstElementPtr ctx8 = auth->getContext();
+ ASSERT_TRUE(ctx8);
+ ASSERT_EQ(1, ctx8->size());
+ ASSERT_TRUE(ctx8->get("comment"));
+ EXPECT_EQ("\"basic HTTP authentication\"", ctx8->get("comment")->str());
// Check basic HTTP authentication client comment.
const BasicHttpAuthConfigPtr& basic_auth =
@@ -639,18 +653,18 @@ TEST_F(AgentParserTest, comments) {
ASSERT_TRUE(basic_auth);
auto clients = basic_auth->getClientList();
ASSERT_EQ(2, clients.size());
- ConstElementPtr ctx8 = clients.front().getContext();
- ASSERT_TRUE(ctx8);
- ASSERT_EQ(1, ctx8->size());
- ASSERT_TRUE(ctx8->get("comment"));
- EXPECT_EQ("\"foo is authorized\"", ctx8->get("comment")->str());
-
- // Check basic HTTP authentication client user context.
- ConstElementPtr ctx9 = clients.back().getContext();
+ ConstElementPtr ctx9 = clients.front().getContext();
ASSERT_TRUE(ctx9);
ASSERT_EQ(1, ctx9->size());
- ASSERT_TRUE(ctx9->get("no password"));
- EXPECT_EQ("true", ctx9->get("no password")->str());
+ ASSERT_TRUE(ctx9->get("comment"));
+ EXPECT_EQ("\"foo is authorized\"", ctx9->get("comment")->str());
+
+ // Check basic HTTP authentication client user context.
+ ConstElementPtr ctx10 = clients.back().getContext();
+ ASSERT_TRUE(ctx10);
+ ASSERT_EQ(1, ctx10->size());
+ ASSERT_TRUE(ctx10->get("no password"));
+ EXPECT_EQ("true", ctx10->get("no password")->str());
}
// This test checks if a config with TLS parameters is parsed properly.
diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc
index 396b4ae9a4..d178dce589 100644
--- a/src/bin/dhcp4/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp4/tests/config_parser_unittest.cc
@@ -246,6 +246,11 @@ const char* PARSER_CONFIGS[] = {
" \"socket-type\": \"http\","
" \"socket-address\": \"::1\","
" \"socket-port\": 8000,"
+ " \"http-headers\": [ {"
+ " \"comment\": \"HSTS header\","
+ " \"name\": \"Strict-Transport-Security\","
+ " \"value\": \"max-age=31536000\""
+ " } ],"
" \"authentication\": {"
" \"comment\": \"basic HTTP authentication\","
" \"type\": \"basic\","
@@ -7110,6 +7115,18 @@ TEST_F(Dhcp4ParserTest, comments) {
ASSERT_TRUE(ctx_socket->get("comment"));
EXPECT_EQ("\"HTTP control socket\"", ctx_socket->get("comment")->str());
+ // HTTP headers.
+ ConstElementPtr headers = socket->get("http-headers");
+ ASSERT_TRUE(headers);
+ ASSERT_EQ(1, headers->size());
+ ConstElementPtr header = headers->get(0);
+ ASSERT_TRUE(header);
+ ConstElementPtr ctx_header = header->get("user-context");
+ ASSERT_TRUE(ctx_header);
+ ASSERT_EQ(1, ctx_header->size());
+ ASSERT_TRUE(ctx_header->get("comment"));
+ EXPECT_EQ("\"HSTS header\"", ctx_header->get("comment")->str());
+
// HTTP authentication.
ConstElementPtr auth = socket->get("authentication");
ASSERT_TRUE(auth);
diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc
index e91da6b796..c3f20bf3f4 100644
--- a/src/bin/dhcp6/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp6/tests/config_parser_unittest.cc
@@ -327,6 +327,11 @@ const char* PARSER_CONFIGS[] = {
" \"socket-type\": \"http\","
" \"socket-address\": \"127.0.0.1\","
" \"socket-port\": 8000,"
+ " \"http-headers\": [ {"
+ " \"comment\": \"HSTS header\","
+ " \"name\": \"Strict-Transport-Security\","
+ " \"value\": \"max-age=31536000\""
+ " } ],"
" \"authentication\": {"
" \"comment\": \"basic HTTP authentication\","
" \"type\": \"basic\","
@@ -7924,6 +7929,18 @@ TEST_F(Dhcp6ParserTest, comments) {
ASSERT_TRUE(ctx_socket->get("comment"));
EXPECT_EQ("\"HTTP control socket\"", ctx_socket->get("comment")->str());
+ // HTTP headers.
+ ConstElementPtr headers = socket->get("http-headers");
+ ASSERT_TRUE(headers);
+ ASSERT_EQ(1, headers->size());
+ ConstElementPtr header = headers->get(0);
+ ASSERT_TRUE(header);
+ ConstElementPtr ctx_header = header->get("user-context");
+ ASSERT_TRUE(ctx_header);
+ ASSERT_EQ(1, ctx_header->size());
+ ASSERT_TRUE(ctx_header->get("comment"));
+ EXPECT_EQ("\"HSTS header\"", ctx_header->get("comment")->str());
+
// HTTP authentication.
ConstElementPtr auth = socket->get("authentication");
ASSERT_TRUE(auth);