From: Francis Dupont Date: Fri, 20 Nov 2020 08:58:12 +0000 (+0100) Subject: [#1421] Addressed comments X-Git-Tag: Kea-1.9.2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef340bff3b7cbeb1a9e4c950c561d792596874ff;p=thirdparty%2Fkea.git [#1421] Addressed comments --- diff --git a/ChangeLog b/ChangeLog index 30965c56f0..03300c3b3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +1834. [func] fdupont + Added two new callouts (hook points) in the control agent. + The "auth" callout is executed after the basic authentication + (if configured) and the command processing. The "response" + callout is executed after the command processing and before + the HTTP response is returned. + (Gitlab #1421) + 1833. [doc] sgoldlust Many documentation corrections. (Gitlab #1539) diff --git a/src/bin/agent/agent_hooks.dox b/src/bin/agent/agent_hooks.dox index 641eb55c27..fcde63901e 100644 --- a/src/bin/agent/agent_hooks.dox +++ b/src/bin/agent/agent_hooks.dox @@ -51,6 +51,6 @@ command. reference and for callout contexts. The "response" argument is the response which will be sent back to the resquesting client. It is called after command processing. The next step status is ignored: - the response eventually modified will be sent back. + the response possibly modified will be sent back. */ \ No newline at end of file diff --git a/src/bin/agent/tests/ca_response_creator_unittests.cc b/src/bin/agent/tests/ca_response_creator_unittests.cc index eb3658146a..38ae18e9f2 100644 --- a/src/bin/agent/tests/ca_response_creator_unittests.cc +++ b/src/bin/agent/tests/ca_response_creator_unittests.cc @@ -327,6 +327,8 @@ TEST_F(CtrlAgentResponseCreatorTest, hookNoAuth) { setBasicContext(request_); // Body: "list-commands" is natively supported by the command manager. + // We add a random value in the extra entry: see next unit test + // for an explanation about how it is used. auto r32 = isc::cryptolink::random(4); ASSERT_EQ(4, r32.size()); int extra = r32[0]; @@ -381,6 +383,16 @@ TEST_F(CtrlAgentResponseCreatorTest, hookBasicAuth) { setBasicContext(request_); // Body: "list-commands" is natively supported by the command manager. + // We add a random value in the extra entry: + // - this proves that the auth callout can get the request argument + // - this proves that the auth callout can modify the request argument + // before the request is executed (the extra entry if still present + // would make the command to be rejected as malformed) + // - this proves that a value can be communicate between the auth + // and response callout points + // - this proves that the response callout can get the response argument + // - this proves that the response callout can modify the response + // argument auto r32 = isc::cryptolink::random(4); ASSERT_EQ(4, r32.size()); int extra = r32[0];