Skip to content

Commit

Permalink
Add test: pam_get_item(PAM_USER) fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlonofportland committed Apr 1, 2023
1 parent a283e17 commit 8ccbef9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ static void invalid_module_argument(void)
}


static void no_valid_user(void)
{
memset(&pamh, '\0', sizeof(pam_handle_t));

CU_ASSERT_FATAL(acct_mgmt(&pamh, 0, 0, NULL) == PAM_BAD_ITEM);
CU_ASSERT(pamh.get_item_calls == 1);
CU_ASSERT(pamh.set_data_calls == 0);
CU_ASSERT(pamh.syslog_calls == 0);
}


static void no_config_file(void)
{
const char *arg = "path=data/non-existent";
Expand Down Expand Up @@ -241,6 +252,7 @@ int main(int argc, char **argv)

CU_add_test(suite, "invalid module argument", invalid_module_argument);
CU_add_test(suite, "no config file", no_config_file);
CU_add_test(suite, "no PAM_USER", no_valid_user);
CU_add_test(suite, "config not at start of line",
config_not_at_start_of_line);
CU_add_test(suite, "config file has only comments and whitespace",
Expand Down

0 comments on commit 8ccbef9

Please sign in to comment.