Skip to content

Commit

Permalink
fixup! Responder: generate JSON message for GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ikerexxe committed May 13, 2024
1 parent 10574ed commit 0ab4821
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
19 changes: 18 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2681,23 +2681,40 @@ if BUILD_PASSKEY
endif # BUILD_PASSKEY

test_pamsrv_json_SOURCES = \
$(TEST_MOCK_RESP_OBJ) \
src/responder/pam/pamsrv_cmd.c \
src/responder/pam/pamsrv_json.c \
src/responder/pam/pamsrv_p11.c \
src/responder/pam/pamsrv_gssapi.c \
src/responder/pam/pam_helpers.c \
src/responder/pam/pamsrv_dp.c \
src/responder/pam/pam_prompting_config.c \
src/sss_client/pam_sss_prompt_config.c \
src/tests/cmocka/test_pamsrv_json.c \
$(NULL)
if BUILD_PASSKEY
test_pamsrv_json_SOURCES += src/responder/pam/pamsrv_passkey.c
endif # BUILD_PASSKEY
test_pamsrv_json_CFLAGS = \
$(AM_CFLAGS) \
$(NULL)
test_pamsrv_json_LDFLAGS = \
-Wl,-wrap,json_array_append_new \
-Wl,-wrap,pam_get_prompting_option \
$(NULL)
test_pamsrv_json_LDADD = \
$(LIBADD_DL) \
$(CMOCKA_LIBS) \
$(PAM_LIBS) \
$(SSSD_LIBS) \
$(SSSD_INTERNAL_LTLIBS) \
$(JANSSON_LIBS) \
$(GSSAPI_KRB5_LIBS) \
$(TALLOC_LIBS) \
libsss_test_common.la \
libsss_idmap.la \
libsss_certmap.la \
libsss_iface.la \
libsss_sbus.la \
$(NULL)

test_sss_pam_data_SOURCES = \
Expand Down
27 changes: 7 additions & 20 deletions src/tests/cmocka/test_pamsrv_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,6 @@ __wrap_json_array_append_new(json_t *array, json_t *value)
return ret;
}

errno_t
__wrap_pam_get_prompting_option(struct prompt_config **pc_list, int prompt_type,
int index, const char **_prompt)
{
errno_t ret;

ret = mock();
*_prompt = (char *) mock();

return ret;
}

/***********************
* TEST
**********************/
Expand Down Expand Up @@ -233,7 +221,7 @@ void test_generate_json_message_integration(void **state)
{
TALLOC_CTX *test_ctx;
struct pam_data *pd = NULL;
struct prompt_config *pc_list = NULL;
struct prompt_config **pc_list = NULL;
int ret;

test_ctx = talloc_new(NULL);
Expand All @@ -247,15 +235,14 @@ void test_generate_json_message_integration(void **state)
pd->resp_list->data = discard_const(OAUTH2_STR);
pd->resp_list->next = NULL;

will_return(__wrap_pam_get_prompting_option, EOK);
will_return(__wrap_pam_get_prompting_option, PASSWORD_PROMPT);
will_return(__wrap_pam_get_prompting_option, EOK);
will_return(__wrap_pam_get_prompting_option, OAUTH2_INIT_PROMPT);
will_return(__wrap_pam_get_prompting_option, EOK);
will_return(__wrap_pam_get_prompting_option, OAUTH2_LINK_PROMPT);
ret = pc_list_add_password(&pc_list, PASSWORD_PROMPT);
assert_int_equal(ret, EOK);
ret = pc_list_add_eidp(&pc_list, OAUTH2_INIT_PROMPT, OAUTH2_LINK_PROMPT);
assert_int_equal(ret, EOK);

will_return(__wrap_json_array_append_new, false);
will_return(__wrap_json_array_append_new, false);
ret = generate_json_auth_message(NULL, &pc_list, pd);
ret = generate_json_auth_message(NULL, pc_list, pd);
assert_int_equal(ret, EOK);
assert_string_equal((char*) pd->resp_list->data, AUTH_SELECTION_ALL);

Expand Down

0 comments on commit 0ab4821

Please sign in to comment.