Data Structures | |
struct | pam_testcase |
The PAM testcase struction. More... | |
struct | pamtest_conv_data |
This structure should be used when using run_pamtest, which uses an internal conversation function. More... | |
Defines | |
#define | pam_test(op, expected) { op, expected, 0, 0, { .envlist = NULL } } |
Initializes a pam_tescase structure. | |
#define | pam_test_flags(op, expected, flags) { op, expected, flags, 0, { .envlist = NULL } } |
Initializes a CMUnitTest structure with additional PAM flags. | |
Typedefs | |
typedef int(* | pam_conv_fn )(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) |
PAM conversation function, defined in pam_conv(3). | |
Enumerations | |
enum | pamtest_err { PAMTEST_ERR_OK, PAMTEST_ERR_START, PAMTEST_ERR_CASE, PAMTEST_ERR_OP, PAMTEST_ERR_END, PAMTEST_ERR_KEEPHANDLE, PAMTEST_ERR_INTERNAL } |
The return code of the pamtest function. More... | |
enum | pamtest_ops { PAMTEST_AUTHENTICATE, PAMTEST_SETCRED, PAMTEST_ACCOUNT, PAMTEST_OPEN_SESSION, PAMTEST_CLOSE_SESSION, PAMTEST_CHAUTHTOK, PAMTEST_GETENVLIST = 20, PAMTEST_KEEPHANDLE } |
The enum which describes the operations performed by pamtest(). More... | |
Functions | |
struct pam_testcase * | pamtest_failed_case (struct pam_testcase *test_cases) |
Helper you can call if run_pamtest() fails. | |
void | pamtest_free_env (char **envlist) |
This frees the string array returned by the PAMTEST_GETENVLIST test. | |
const char * | pamtest_strerror (enum pamtest_err perr) |
return a string representation of libpamtest error code. | |
enum pamtest_err | run_pamtest (const char *service, const char *user, struct pamtest_conv_data *conv_data, struct pam_testcase test_cases[]) |
Run libpamtest test cases. | |
enum pamtest_err | run_pamtest_conv (const char *service, const char *user, pam_conv_fn conv_fn, void *conv_userdata, struct pam_testcase test_cases[]) |
Run libpamtest test cases. |
#define pam_test | ( | op, | |||
expected | ) | { op, expected, 0, 0, { .envlist = NULL } } |
Initializes a pam_tescase structure.
#define pam_test_flags | ( | op, | |||
expected, | |||||
flags | ) | { op, expected, flags, 0, { .envlist = NULL } } |
Initializes a CMUnitTest structure with additional PAM flags.
typedef int(* pam_conv_fn)(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) |
PAM conversation function, defined in pam_conv(3).
This is just a typedef to use in our declarations. See man pam_conv(3) for more details.
enum pamtest_err |
The return code of the pamtest function.
enum pamtest_ops |
The enum which describes the operations performed by pamtest().
struct pam_testcase* pamtest_failed_case | ( | struct pam_testcase * | test_cases | ) | [read] |
Helper you can call if run_pamtest() fails.
If PAMTEST_ERR_CASE is returned by run_pamtest() you should call this function get a pointer to the failed test case.
[in] | test_cases | The array of tests. |
void pamtest_free_env | ( | char ** | envlist | ) |
This frees the string array returned by the PAMTEST_GETENVLIST test.
[in] | envlist | The array to free. |
const char* pamtest_strerror | ( | enum pamtest_err | perr | ) |
return a string representation of libpamtest error code.
[in] | perr | libpamtest error code |
References PAMTEST_ERR_CASE, PAMTEST_ERR_END, PAMTEST_ERR_INTERNAL, PAMTEST_ERR_KEEPHANDLE, PAMTEST_ERR_OK, PAMTEST_ERR_OP, and PAMTEST_ERR_START.
enum pamtest_err run_pamtest | ( | const char * | service, | |
const char * | user, | |||
struct pamtest_conv_data * | conv_data, | |||
struct pam_testcase | test_cases[] | |||
) |
Run libpamtest test cases.
This is using the default libpamtest conversation function.
[in] | service | The PAM service to use in the conversation |
[in] | user | The user to run conversation as |
[in] | conv_data | Test-specific conversation data |
[in] | test_cases | List of libpamtest test cases. Must end with PAMTEST_CASE_SENTINEL |
int main(void) { int rc; const struct pam_testcase tests[] = { pam_test(PAM_AUTHENTICATE, PAM_SUCCESS), }; rc = run_pamtest(tests, NULL, NULL); return rc; }
enum pamtest_err run_pamtest_conv | ( | const char * | service, | |
const char * | user, | |||
pam_conv_fn | conv_fn, | |||
void * | conv_userdata, | |||
struct pam_testcase | test_cases[] | |||
) |
Run libpamtest test cases.
This is using the default libpamtest conversation function.
[in] | service | The PAM service to use in the conversation |
[in] | user | The user to run conversation as |
[in] | conv_fn | Test-specific conversation function |
[in] | conv_userdata | Test-specific conversation data |
[in] | test_cases | List of libpamtest test cases. Must end with PAMTEST_CASE_SENTINEL |
int main(void) { int rc; const struct pam_testcase tests[] = { pam_test(PAM_AUTHENTICATE, PAM_SUCCESS), }; rc = run_pamtest(tests, NULL, NULL); return rc; }