]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3483] Renamed CA callouts
authorFrancis Dupont <fdupont@isc.org>
Tue, 23 Jul 2024 17:25:01 +0000 (19:25 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 22 Aug 2024 08:38:59 +0000 (10:38 +0200)
src/bin/agent/agent_hooks.dox
src/bin/agent/ca_response_creator.cc
src/bin/agent/tests/basic_auth_library.cc
src/bin/agent/tests/ca_response_creator_unittests.cc

index be2c833fd06d00d4735fa7658a9d98920ff96397..8636eccce94bcc340029b95e25ed04c656f8bad0 100644 (file)
@@ -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>
index 5da0e4c4073e8a2ca61fd6eb5bc1439ab413f0df..ffe1d5d3ef42fa35ede00ac8236867e17c80eb85 100644 (file)
@@ -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);
 
index 924d656bc543f29c4dad6d3bec142bc68f43ab93..f5ae12075c7064bdb63ac9caf010c3e50c9d24a3 100644 (file)
@@ -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;
index 174bd277e2ef08ba2930fddaf66c28cc0cdba250..1d64a74f5c362d19677a196c211eab95829a64de 100644 (file)
@@ -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];