aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jakub.hrozek@posteo.se>2015-10-28 14:44:05 +0100
committerAndreas Schneider <asn@samba.org>2015-12-10 13:31:19 +0100
commitb8bfb6ac0f76f9ad5c952a9e36a7a39cf03b11ec (patch)
treed5d3e5a894742453b238fff4c7df7e64303fa988
parentea3a8ffb7b806054372543776ab1d3840b41ad7f (diff)
downloadpam_wrapper-b8bfb6ac0f76f9ad5c952a9e36a7a39cf03b11ec.tar.gz
pam_wrapper-b8bfb6ac0f76f9ad5c952a9e36a7a39cf03b11ec.tar.xz
pam_wrapper-b8bfb6ac0f76f9ad5c952a9e36a7a39cf03b11ec.zip
More libpamtest tests
-rw-r--r--tests/test_pam_wrapper.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_pam_wrapper.c b/tests/test_pam_wrapper.c
index 2d5c017..2c2c4ee 100644
--- a/tests/test_pam_wrapper.c
+++ b/tests/test_pam_wrapper.c
@@ -714,6 +714,7 @@ static void test_get_set(void **state)
{
const char *svc;
enum pamtest_err perr;
+ const struct pamtest_case *failed_tc;
struct pamtest_case tests[] = {
{ PAMTEST_OPEN_SESSION, PAM_SUCCESS, PAMTEST_CASE_INIT },
{ PAMTEST_GETENVLIST, PAM_SUCCESS, PAMTEST_CASE_INIT },
@@ -741,6 +742,9 @@ static void test_get_set(void **state)
assert_non_null(svc);
assert_string_equal(svc, "test_pam_service");
+ failed_tc = pamtest_failed_case(tests);
+ assert_null(failed_tc);
+
//test_getenv(tests[1].case_out.envlist, "PAM_SERVICE");
test_getenv(tests[1].case_out.envlist, "PAM_USER");
test_getenv(tests[1].case_out.envlist, "PAM_USER_PROMPT");
@@ -810,6 +814,31 @@ static void test_libpamtest_get_failed_test(void **state)
assert_true(failed_tc == &tests[0]);
}
+static void test_libpamtest_neg(void **state)
+{
+ enum pamtest_err perr;
+ struct pamtest_conv_data conv_data;
+ const char *trinity_authtoks[] = {
+ "secret",
+ NULL,
+ };
+ struct pamtest_case tests[] = {
+ { PAMTEST_START, PAM_SUCCESS, PAMTEST_CASE_INIT },
+ { PAMTEST_CASE_SENTINEL },
+ };
+
+ (void) state; /* unused */
+
+ ZERO_STRUCT(conv_data);
+ conv_data.in_echo_off = trinity_authtoks;
+
+ perr = pamtest("matrix", "trinity", &conv_data, tests);
+ assert_int_equal(perr, PAMTEST_ERR_INTERNAL);
+
+ perr = pamtest("matrix", "trinity", &conv_data, NULL);
+ assert_int_equal(perr, PAMTEST_ERR_INTERNAL);
+}
+
int main(void) {
int rc;
@@ -872,6 +901,9 @@ int main(void) {
cmocka_unit_test_setup_teardown(test_libpamtest_get_failed_test,
setup_passdb,
teardown_passdb),
+ cmocka_unit_test_setup_teardown(test_libpamtest_neg,
+ setup_passdb,
+ teardown_passdb),
cmocka_unit_test(test_get_set),
};