mirror of
https://github.com/Yubico/yubico-pam.git
synced 2024-11-29 00:24:11 +01:00
sql: add test for mysql config
This commit is contained in:
parent
371d6048fe
commit
23fb773279
@ -26,7 +26,12 @@ fi
|
||||
|
||||
set -e
|
||||
|
||||
./configure $CONFIGURE_ARGS $COVERAGE
|
||||
if [ ! -z $MYSQL_PORT ]; then
|
||||
CFLAGS="-DTEST_MYSQL_PORT='\"${MYSQL_PORT}\"'" ./configure $CONFIGURE_ARGS $COVERAGE
|
||||
else
|
||||
./configure $CONFIGURE_ARGS $COVERAGE
|
||||
fi
|
||||
|
||||
make check check-doc-dist
|
||||
if [ "x$COVERAGE" != "x" ]; then
|
||||
gem install coveralls-lcov
|
||||
|
@ -56,6 +56,10 @@ pam_sm_authenticate (pam_handle_t * pamh,
|
||||
#define YKVAL_PORT2 "30559"
|
||||
#define LDAP_PORT "52825"
|
||||
|
||||
#ifndef TEST_MYSQL_PORT
|
||||
#define TEST_MYSQL_PORT "3306"
|
||||
#endif
|
||||
|
||||
#define YKVAL SRCDIR"/aux/ykval.pl"
|
||||
#define LDAP SRCDIR"/aux/ldap.pl"
|
||||
#define AUTHFILE SRCDIR"/aux/authfile"
|
||||
@ -97,6 +101,17 @@ static const char *ldap_cfg2[] = {
|
||||
"debug"
|
||||
};
|
||||
|
||||
static const char *mysql_cfg[] = {
|
||||
"id=1",
|
||||
"urllist=http://localhost:"YKVAL_PORT1"/wsapi/2/verify",
|
||||
"mysql_server=127.0.0.1",
|
||||
"mysql_port="TEST_MYSQL_PORT,
|
||||
"mysql_user=user",
|
||||
"mysql_password=password",
|
||||
"mysql_database=otp",
|
||||
"debug"
|
||||
};
|
||||
|
||||
static const struct data *test_get_data(void *id) {
|
||||
return &_data[(long)id];
|
||||
}
|
||||
@ -323,6 +338,14 @@ static int test_authenticate_ldap6(void) {
|
||||
return pam_sm_authenticate((pam_handle_t *)7, 0, sizeof(ldap_cfg) / sizeof(char*), ldap_cfg);
|
||||
}
|
||||
|
||||
static int test_authenticate_mysql1(void) {
|
||||
return pam_sm_authenticate((pam_handle_t *)0, 0, sizeof(mysql_cfg) / sizeof(char*), mysql_cfg);
|
||||
}
|
||||
|
||||
static int test_fail_authenticate_mysql1(void) {
|
||||
return pam_sm_authenticate((pam_handle_t *)1, 0, sizeof(mysql_cfg) / sizeof(char*), mysql_cfg);
|
||||
}
|
||||
|
||||
static pid_t run_mock(const char *port, const char *type) {
|
||||
pid_t pid = fork();
|
||||
if(pid == 0) {
|
||||
@ -420,6 +443,16 @@ int main(void) {
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_MYSQL
|
||||
if(test_authenticate_mysql1() != PAM_SUCCESS) {
|
||||
ret = 2001;
|
||||
goto out;
|
||||
}
|
||||
if(test_fail_authenticate_mysql1() != PAM_USER_UNKNOWN) {
|
||||
ret = 2002;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
out:
|
||||
kill(child, 9);
|
||||
|
Loading…
Reference in New Issue
Block a user