diff options
-rw-r--r-- | src/bin/agent/agent_hooks.dox | 6 | ||||
-rw-r--r-- | src/bin/agent/ca_response_creator.cc | 23 | ||||
-rw-r--r-- | src/bin/agent/tests/basic_auth_library.cc | 8 | ||||
-rw-r--r-- | src/bin/agent/tests/ca_response_creator_unittests.cc | 19 |
4 files changed, 29 insertions, 27 deletions
diff --git a/src/bin/agent/agent_hooks.dox b/src/bin/agent/agent_hooks.dox index be2c833fd0..8636eccce9 100644 --- a/src/bin/agent/agent_hooks.dox +++ b/src/bin/agent/agent_hooks.dox @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -23,7 +23,7 @@ command. @section agentHooksHookPoints Hooks in the Control Agent - @subsection agentHooksAuth auth + @subsection agentHooksAuth http_auth - @b Arguments: - name: @b request, type: isc::http::HttpRequestPtr, direction: <b>in/out</b> @@ -39,7 +39,7 @@ command. response is set the processing will stop and the response is returned. In particular the command is not forwarded. - @subsection agentHooksResponse response + @subsection agentHooksResponse http_response - @b Arguments: - name: @b request, type: isc::http::HttpRequestPtr, direction: <b>in</b> diff --git a/src/bin/agent/ca_response_creator.cc b/src/bin/agent/ca_response_creator.cc index 5da0e4c407..ffe1d5d3ef 100644 --- a/src/bin/agent/ca_response_creator.cc +++ b/src/bin/agent/ca_response_creator.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -28,13 +28,13 @@ namespace { /// Structure that holds registered hook indexes. struct CtrlAgentHooks { - int hook_index_auth_; ///< index of "auth" hook point. - int hook_index_response_; ///< index of "response" hook point. + int hook_index_http_auth_; ///< index of "http_auth" hook point. + int hook_index_http_response_; ///< index of "http_response" hook point. /// Constructor that registers hook points. CtrlAgentHooks() { - hook_index_auth_ = HooksManager::registerHook("auth"); - hook_index_response_ = HooksManager::registerHook("response"); + hook_index_http_auth_ = HooksManager::registerHook("http_auth"); + hook_index_http_response_ = HooksManager::registerHook("http_response"); } }; @@ -116,9 +116,9 @@ createDynamicHttpResponse(HttpRequestPtr request) { } } - // Callout point for "auth". + // Callout point for "http_auth". bool reset_handle = false; - if (HooksManager::calloutsPresent(Hooks.hook_index_auth_)) { + if (HooksManager::calloutsPresent(Hooks.hook_index_http_auth_)) { // Get callout handle. CalloutHandlePtr callout_handle = request->getCalloutHandle(); ScopedCalloutHandleState callout_handle_state(callout_handle); @@ -128,7 +128,8 @@ createDynamicHttpResponse(HttpRequestPtr request) { callout_handle->setArgument("response", http_response); // Call callouts. - HooksManager::callCallouts(Hooks.hook_index_auth_, *callout_handle); + HooksManager::callCallouts(Hooks.hook_index_http_auth_, + *callout_handle); callout_handle->getArgument("request", request); callout_handle->getArgument("response", http_response); @@ -180,8 +181,8 @@ createDynamicHttpResponse(HttpRequestPtr request) { http_response->setBodyAsJson(response); http_response->finalize(); - // Callout point for "response". - if (HooksManager::calloutsPresent(Hooks.hook_index_response_)) { + // Callout point for "http_response". + if (HooksManager::calloutsPresent(Hooks.hook_index_http_response_)) { // Get callout handle. CalloutHandlePtr callout_handle = request->getCalloutHandle(); ScopedCalloutHandleState callout_handle_state(callout_handle); @@ -191,7 +192,7 @@ createDynamicHttpResponse(HttpRequestPtr request) { callout_handle->setArgument("response", http_response); // Call callouts. - HooksManager::callCallouts(Hooks.hook_index_response_, + HooksManager::callCallouts(Hooks.hook_index_http_response_, *callout_handle); callout_handle->getArgument("response", http_response); diff --git a/src/bin/agent/tests/basic_auth_library.cc b/src/bin/agent/tests/basic_auth_library.cc index 924d656bc5..f5ae12075c 100644 --- a/src/bin/agent/tests/basic_auth_library.cc +++ b/src/bin/agent/tests/basic_auth_library.cc @@ -158,12 +158,12 @@ unload() { // Callout functions. -/// @brief This callout is called at the "auth" hook. +/// @brief This callout is called at the "http_auth" hook. /// /// @param handle CalloutHandle. /// @return 0 upon success, non-zero otherwise. int -auth(CalloutHandle& handle) { +http_auth(CalloutHandle& handle) { // Sanity. if (!impl) { std::cerr << "no implementation" << std::endl; @@ -222,12 +222,12 @@ auth(CalloutHandle& handle) { return (0); } -/// @brief This callout is called at the "response" hook. +/// @brief This callout is called at the "http_response" hook. /// /// @param handle CalloutHandle. /// @return 0 upon success, non-zero otherwise. int -response(CalloutHandle& handle) { +http_response(CalloutHandle& handle) { // Sanity. if (!impl) { std::cerr << "no implementation" << std::endl; diff --git a/src/bin/agent/tests/ca_response_creator_unittests.cc b/src/bin/agent/tests/ca_response_creator_unittests.cc index 174bd277e2..1d64a74f5c 100644 --- a/src/bin/agent/tests/ca_response_creator_unittests.cc +++ b/src/bin/agent/tests/ca_response_creator_unittests.cc @@ -389,15 +389,16 @@ TEST_F(CtrlAgentResponseCreatorTest, hookBasicAuth) { // 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 + // - this proves that the http_auth callout can get the request argument + // - this proves that the http_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 http_auth + // and http_response callout points + // - this proves that the http_response callout can get the + // response argument + // - this proves that the http_response callout can modify the + // response argument auto r32 = isc::cryptolink::random(4); ASSERT_EQ(4, r32.size()); int extra = r32[0]; |