Skip to content

Commit

Permalink
add %test.fail() which always returns XLAT_ACTION_FAIL
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Oct 11, 2023
1 parent 26822e0 commit cb23611
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/modules/rlm_test/rlm_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,22 @@ static xlat_action_t test_xlat_passthrough(TALLOC_CTX *ctx, fr_dcursor_t *out,
}


static xlat_arg_parser_t const test_xlat_fail_args[] = {
{ .required = false, .concat = true, .type = FR_TYPE_STRING },
XLAT_ARG_PARSER_TERMINATOR
};


/** Always return XLAT_ACTION_FAIL
*/
static xlat_action_t test_xlat_fail(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out,
UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request,
UNUSED fr_value_box_list_t *in)
{
return XLAT_ACTION_FAIL;
}


static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
{
rlm_test_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_test_t);
Expand Down Expand Up @@ -468,6 +484,9 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
if (!(xlat = xlat_func_register_module(inst, mctx, "passthrough", test_xlat_passthrough, FR_TYPE_VOID))) return -1;
xlat_func_args_set(xlat, test_xlat_passthrough_args);

if (!(xlat = xlat_func_register_module(inst, mctx, "fail", test_xlat_fail, FR_TYPE_VOID))) return -1;
xlat_func_args_set(xlat, test_xlat_fail_args);

return 0;
}

Expand Down

0 comments on commit cb23611

Please sign in to comment.