Skip to content

Commit 6045a46

Browse files
committed
[#3483] Renamed CA callouts
1 parent bb6a1d3 commit 6045a46

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

src/bin/agent/agent_hooks.dox

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC")
1+
// Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC")
22
//
33
// This Source Code Form is subject to the terms of the Mozilla Public
44
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -23,7 +23,7 @@ command.
2323

2424
@section agentHooksHookPoints Hooks in the Control Agent
2525

26-
@subsection agentHooksAuth auth
26+
@subsection agentHooksAuth http_auth
2727

2828
- @b Arguments:
2929
- name: @b request, type: isc::http::HttpRequestPtr, direction: <b>in/out</b>
@@ -39,7 +39,7 @@ command.
3939
response is set the processing will stop and the response is returned.
4040
In particular the command is not forwarded.
4141

42-
@subsection agentHooksResponse response
42+
@subsection agentHooksResponse http_response
4343

4444
- @b Arguments:
4545
- name: @b request, type: isc::http::HttpRequestPtr, direction: <b>in</b>

src/bin/agent/ca_response_creator.cc

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC")
1+
// Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC")
22
//
33
// This Source Code Form is subject to the terms of the Mozilla Public
44
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -28,13 +28,13 @@ namespace {
2828

2929
/// Structure that holds registered hook indexes.
3030
struct CtrlAgentHooks {
31-
int hook_index_auth_; ///< index of "auth" hook point.
32-
int hook_index_response_; ///< index of "response" hook point.
31+
int hook_index_http_auth_; ///< index of "http_auth" hook point.
32+
int hook_index_http_response_; ///< index of "http_response" hook point.
3333

3434
/// Constructor that registers hook points.
3535
CtrlAgentHooks() {
36-
hook_index_auth_ = HooksManager::registerHook("auth");
37-
hook_index_response_ = HooksManager::registerHook("response");
36+
hook_index_http_auth_ = HooksManager::registerHook("http_auth");
37+
hook_index_http_response_ = HooksManager::registerHook("http_response");
3838
}
3939
};
4040

@@ -116,9 +116,9 @@ createDynamicHttpResponse(HttpRequestPtr request) {
116116
}
117117
}
118118

119-
// Callout point for "auth".
119+
// Callout point for "http_auth".
120120
bool reset_handle = false;
121-
if (HooksManager::calloutsPresent(Hooks.hook_index_auth_)) {
121+
if (HooksManager::calloutsPresent(Hooks.hook_index_http_auth_)) {
122122
// Get callout handle.
123123
CalloutHandlePtr callout_handle = request->getCalloutHandle();
124124
ScopedCalloutHandleState callout_handle_state(callout_handle);
@@ -128,7 +128,8 @@ createDynamicHttpResponse(HttpRequestPtr request) {
128128
callout_handle->setArgument("response", http_response);
129129

130130
// Call callouts.
131-
HooksManager::callCallouts(Hooks.hook_index_auth_, *callout_handle);
131+
HooksManager::callCallouts(Hooks.hook_index_http_auth_,
132+
*callout_handle);
132133
callout_handle->getArgument("request", request);
133134
callout_handle->getArgument("response", http_response);
134135

@@ -180,8 +181,8 @@ createDynamicHttpResponse(HttpRequestPtr request) {
180181
http_response->setBodyAsJson(response);
181182
http_response->finalize();
182183

183-
// Callout point for "response".
184-
if (HooksManager::calloutsPresent(Hooks.hook_index_response_)) {
184+
// Callout point for "http_response".
185+
if (HooksManager::calloutsPresent(Hooks.hook_index_http_response_)) {
185186
// Get callout handle.
186187
CalloutHandlePtr callout_handle = request->getCalloutHandle();
187188
ScopedCalloutHandleState callout_handle_state(callout_handle);
@@ -191,7 +192,7 @@ createDynamicHttpResponse(HttpRequestPtr request) {
191192
callout_handle->setArgument("response", http_response);
192193

193194
// Call callouts.
194-
HooksManager::callCallouts(Hooks.hook_index_response_,
195+
HooksManager::callCallouts(Hooks.hook_index_http_response_,
195196
*callout_handle);
196197
callout_handle->getArgument("response", http_response);
197198

src/bin/agent/tests/basic_auth_library.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ unload() {
158158

159159
// Callout functions.
160160

161-
/// @brief This callout is called at the "auth" hook.
161+
/// @brief This callout is called at the "http_auth" hook.
162162
///
163163
/// @param handle CalloutHandle.
164164
/// @return 0 upon success, non-zero otherwise.
165165
int
166-
auth(CalloutHandle& handle) {
166+
http_auth(CalloutHandle& handle) {
167167
// Sanity.
168168
if (!impl) {
169169
std::cerr << "no implementation" << std::endl;
@@ -222,12 +222,12 @@ auth(CalloutHandle& handle) {
222222
return (0);
223223
}
224224

225-
/// @brief This callout is called at the "response" hook.
225+
/// @brief This callout is called at the "http_response" hook.
226226
///
227227
/// @param handle CalloutHandle.
228228
/// @return 0 upon success, non-zero otherwise.
229229
int
230-
response(CalloutHandle& handle) {
230+
http_response(CalloutHandle& handle) {
231231
// Sanity.
232232
if (!impl) {
233233
std::cerr << "no implementation" << std::endl;

src/bin/agent/tests/ca_response_creator_unittests.cc

+10-9
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,16 @@ TEST_F(CtrlAgentResponseCreatorTest, hookBasicAuth) {
389389

390390
// Body: "list-commands" is natively supported by the command manager.
391391
// We add a random value in the extra entry:
392-
// - this proves that the auth callout can get the request argument
393-
// - this proves that the auth callout can modify the request argument
394-
// before the request is executed (the extra entry if still present
395-
// would make the command to be rejected as malformed)
396-
// - this proves that a value can be communicate between the auth
397-
// and response callout points
398-
// - this proves that the response callout can get the response argument
399-
// - this proves that the response callout can modify the response
400-
// argument
392+
// - this proves that the http_auth callout can get the request argument
393+
// - this proves that the http_auth callout can modify the request
394+
// argument before the request is executed (the extra entry
395+
// if still present would make the command to be rejected as malformed)
396+
// - this proves that a value can be communicate between the http_auth
397+
// and http_response callout points
398+
// - this proves that the http_response callout can get the
399+
// response argument
400+
// - this proves that the http_response callout can modify the
401+
// response argument
401402
auto r32 = isc::cryptolink::random(4);
402403
ASSERT_EQ(4, r32.size());
403404
int extra = r32[0];

0 commit comments

Comments
 (0)