2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#1662] Checkpoint: code and test, doc to do

This commit is contained in:
Francis Dupont
2021-02-10 09:21:24 +01:00
parent 40a27f5602
commit a512a67351
2 changed files with 42 additions and 1 deletions

View File

@@ -23,7 +23,7 @@
// TLS require client certificates flag. Default is true and means
// require client certificates. False means they are optional.
"file-required": true,
"cert-required": true,
// Optional authentication.
"authentication":

View File

@@ -67,6 +67,25 @@ TEST(CtrlAgentCfgMgr, contextHttpParams) {
EXPECT_EQ("alnitak", ctx.getHttpHost());
}
// Tests if context can store and retrieve TLS parameters.
TEST(CtrlAgentCfgMgr, contextTlsParams) {
CtrlAgentCfgContext ctx;
// Check TLS parameters
ctx.setTrustAnchor("my-ca");
EXPECT_EQ("my-ca", ctx.getTrustAnchor());
ctx.setCertFile("my-cert");
EXPECT_EQ("my-cert", ctx.getCertFile());
ctx.setKeyFile("my-key");
EXPECT_EQ("my-key", ctx.getKeyFile());
EXPECT_TRUE(ctx.getCertRequired());
ctx.setCertRequired(false);
EXPECT_FALSE(ctx.getCertRequired());
}
// Tests if context can store and retrieve control socket information.
TEST(CtrlAgentCfgMgr, contextSocketInfo) {
@@ -342,6 +361,16 @@ const char* AGENT_CONFIGS[] = {
" \"user-context\": { \"version\": 1 }\n"
" }\n"
" }\n"
"}",
// Configuration 9: https aka http over TLS
"{\n"
" \"http-host\": \"betelgeuse\",\n"
" \"http-port\": 8001,\n"
" \"trust-anchor\": \"my-ca\",\n"
" \"cert-file\": \"my-cert\",\n"
" \"key-file\": \"my-key\",\n"
" \"cert-required\": false\n"
"}"
};
@@ -578,4 +607,16 @@ TEST_F(AgentParserTest, comments) {
EXPECT_EQ("true", ctx9->get("no password")->str());
}
// This test checks if a config with TLS parameters is parsed properly.
TEST_F(AgentParserTest, configParseTls) {
configParse(AGENT_CONFIGS[9], 0);
CtrlAgentCfgContextPtr ctx = cfg_mgr_.getCtrlAgentCfgContext();
ASSERT_TRUE(ctx);
EXPECT_EQ("my-ca", ctx->getTrustAnchor());
EXPECT_EQ("my-cert", ctx->getCertFile());
EXPECT_EQ("my-key", ctx->getKeyFile());
EXPECT_FALSE(ctx->getCertRequired());
}
} // end of anonymous namespace