aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jakub.hrozek@posteo.se>2015-10-30 11:40:18 +0100
committerAndreas Schneider <asn@samba.org>2015-12-10 13:31:20 +0100
commitcd44935ec5ff8da73ddb7e38068d12a1487577ab (patch)
tree521283cd2501eb2fdfc516060112591abda15d79
parenta3e52ead6001342dde59bc65806e4d2e850d8a5b (diff)
downloadpam_wrapper-cd44935ec5ff8da73ddb7e38068d12a1487577ab.tar.gz
pam_wrapper-cd44935ec5ff8da73ddb7e38068d12a1487577ab.tar.xz
pam_wrapper-cd44935ec5ff8da73ddb7e38068d12a1487577ab.zip
tests: Also test pam_vprompt
-rw-r--r--tests/test_pam_wrapper.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_pam_wrapper.c b/tests/test_pam_wrapper.c
index 129ea84..5968b92 100644
--- a/tests/test_pam_wrapper.c
+++ b/tests/test_pam_wrapper.c
@@ -610,6 +610,19 @@ static int pwrap_echo_conv(int num_msg,
return PAM_SUCCESS;
}
+static int vprompt_test_fn(pam_handle_t *pamh, int style,
+ char **response, const char *fmt, ...)
+{
+ va_list args;
+ int rv;
+
+ va_start(args, fmt);
+ rv = pam_vprompt(pamh, style, response, fmt, args);
+ va_end(args);
+
+ return rv;
+}
+
static void test_pam_prompt(void **state)
{
struct pwrap_test_ctx *test_ctx;
@@ -633,11 +646,21 @@ static void test_pam_prompt(void **state)
assert_string_equal(response, "echo off: no echo");
free(response);
+ rv = vprompt_test_fn(test_ctx->ph, PAM_PROMPT_ECHO_OFF, &response, "no echo");
+ assert_int_equal(rv, PAM_SUCCESS);
+ assert_string_equal(response, "echo off: no echo");
+ free(response);
+
rv = pam_prompt(test_ctx->ph, PAM_PROMPT_ECHO_ON, &response, "echo");
assert_int_equal(rv, PAM_SUCCESS);
assert_string_equal(response, "echo on: echo");
free(response);
+ rv = vprompt_test_fn(test_ctx->ph, PAM_PROMPT_ECHO_ON, &response, "echo");
+ assert_int_equal(rv, PAM_SUCCESS);
+ assert_string_equal(response, "echo on: echo");
+ free(response);
+
assert_int_equal(resp_array[0], 0);
pam_info(test_ctx->ph, "info");
assert_int_equal(resp_array[0], 1);
@@ -719,6 +742,18 @@ static void test_pam_authenticate_db_opt_err(void **state)
assert_string_equal(auth_err_msg, "Authentication failed");
}
+
+static void vsyslog_test_fn(const pam_handle_t *pamh,
+ int priority,
+ const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ pam_vsyslog(pamh, priority, fmt, args);
+ va_end(args);
+}
+
static void test_pam_vsyslog(void **state)
{
struct pwrap_test_ctx *test_ctx;
@@ -726,6 +761,7 @@ static void test_pam_vsyslog(void **state)
test_ctx = (struct pwrap_test_ctx *) *state;
pam_syslog(test_ctx->ph, LOG_INFO, "This is pam_wrapper test\n");
+ vsyslog_test_fn(test_ctx->ph, LOG_INFO, "This is pam_wrapper test\n");
}
#define test_setenv(env) setenv(env, "test_"env, 1)