From 30da196e2ee007d0a7e3d2e3875c94204b73f1b1 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Tue, 5 Mar 2024 15:45:40 +0100 Subject: [PATCH] Test: adapt test_pam_srv to JSON message Include JSON message where applies. Signed-off-by: Iker Pedrosa --- src/responder/pam/pamsrv_json.c | 6 ++++-- src/tests/cmocka/test_pam_srv.c | 6 ++++++ src/tests/cmocka/test_pamsrv_json.c | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/responder/pam/pamsrv_json.c b/src/responder/pam/pamsrv_json.c index 7b37a47a05a..c95d6044a3a 100644 --- a/src/responder/pam/pamsrv_json.c +++ b/src/responder/pam/pamsrv_json.c @@ -218,9 +218,10 @@ json_format_mechanisms(bool password_auth, const char *password_prompt, } if (password_auth) { - json_pass = json_pack("{s:s,s:s,s:s}", + json_pass = json_pack("{s:s,s:s,s:b,s:s}", "name", "Password", "role", "password", + "selectable", true, "prompt", password_prompt); if (json_pass == NULL) { DEBUG(SSSDBG_OP_FAILURE, "json_pack failed.\n"); @@ -238,9 +239,10 @@ json_format_mechanisms(bool password_auth, const char *password_prompt, } if (oauth2_auth) { - json_oauth2 = json_pack("{s:s,s:s,s:s,s:s,s:s,s:s,s:i}", + json_oauth2 = json_pack("{s:s,s:s,s:b,s:s,s:s,s:s,s:s,s:i}", "name", "Web Login", "role", "eidp", + "selectable", true, "init_prompt", oauth2_init_prompt, "link_prompt", oauth2_link_prompt, "uri", uri, diff --git a/src/tests/cmocka/test_pam_srv.c b/src/tests/cmocka/test_pam_srv.c index faa434328fd..6d4ba6f9615 100644 --- a/src/tests/cmocka/test_pam_srv.c +++ b/src/tests/cmocka/test_pam_srv.c @@ -612,6 +612,8 @@ static void mock_input_pam_passkey(TALLOC_CTX *mem_ctx, pi.pam_rhost_size = strlen(pi.pam_rhost) + 1; pi.requested_domains = ""; pi.cli_pid = 12345; + pi.json_auth_msg = discard_const(""); + pi.json_auth_selected = ""; ret = pack_message_v3(&pi, &buf_size, &m_buf); assert_int_equal(ret, 0); @@ -707,6 +709,8 @@ static void mock_input_pam_ex(TALLOC_CTX *mem_ctx, pi.pam_rhost_size = strlen(pi.pam_rhost) + 1; pi.requested_domains = ""; pi.cli_pid = 12345; + pi.json_auth_msg = discard_const(""); + pi.json_auth_selected = ""; ret = pack_message_v3(&pi, &buf_size, &m_buf); assert_int_equal(ret, 0); @@ -788,6 +792,8 @@ static void mock_input_pam_cert(TALLOC_CTX *mem_ctx, const char *name, pi.pam_rhost_size = strlen(pi.pam_rhost) + 1; pi.requested_domains = ""; pi.cli_pid = 12345; + pi.json_auth_msg = discard_const(""); + pi.json_auth_selected = ""; ret = pack_message_v3(&pi, &buf_size, &m_buf); free(pi.pam_authtok); diff --git a/src/tests/cmocka/test_pamsrv_json.c b/src/tests/cmocka/test_pamsrv_json.c index 599ba851d1a..8e32c4e5c0f 100644 --- a/src/tests/cmocka/test_pamsrv_json.c +++ b/src/tests/cmocka/test_pamsrv_json.c @@ -39,9 +39,10 @@ #define BASIC_PASSWORD "\"password\": {" \ "\"name\": \"Password\", \"role\": \"password\", " \ - "\"prompt\": \"Password\"}" + "\"selectable\": true, \"prompt\": \"Password\"}" #define BASIC_OAUTH2 "\"eidp\": {" \ "\"name\": \"Web Login\", \"role\": \"eidp\", " \ + "\"selectable\": true, " \ "\"init_prompt\": \"" OAUTH2_INIT_PROMPT "\", " \ "\"link_prompt\": \"" OAUTH2_LINK_PROMPT "\", " \ "\"uri\": \"short.url.com/tmp\", \"code\": \"1234-5678\", " \