diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2007-12-22 22:05:57 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2007-12-22 22:05:57 +0100 |
commit | 1ed9e8fa88532086b1544c484aa20bd1e4061123 (patch) | |
tree | 9b2b9c3150bb2232262cebf45cc407b953f5e1b7 /tests/test_myldap.c | |
parent | cb63d4e962577afa4a7475d0ec225a8427e974e5 (diff) |
add limited test for reconnect logic
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@523 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'tests/test_myldap.c')
-rw-r--r-- | tests/test_myldap.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_myldap.c b/tests/test_myldap.c index da88b0c..d84cdbd 100644 --- a/tests/test_myldap.c +++ b/tests/test_myldap.c @@ -257,6 +257,45 @@ static void test_threads(void) } } +static void test_connections(void) +{ + MYLDAP_SESSION *session; + MYLDAP_SEARCH *search; + MYLDAP_ENTRY *entry; + const char *attrs[] = { "uid", "cn", "gid", NULL }; + char *old_uris[NSS_LDAP_CONFIG_URI_MAX+1]; + int i; + /* save the old URIs */ + for (i=0;i<(NSS_LDAP_CONFIG_URI_MAX+1);i++) + { + old_uris[i]=nslcd_cfg->ldc_uris[i]; + nslcd_cfg->ldc_uris[i]=NULL; + } + /* set new URIs */ + i=0; + nslcd_cfg->ldc_uris[i++]="ldapi://%2fdev%2fnull/"; + nslcd_cfg->ldc_uris[i++]="ldap://10.10.10.10/"; + nslcd_cfg->ldc_uris[i++]="ldapi://%2fdev%2fnonexistent/"; + nslcd_cfg->ldc_uris[i++]="ldap://nosuchhost/"; + nslcd_cfg->ldc_uris[i++]=NULL; + /* initialize session */ + printf("test_connections(): getting session...\n"); + session=myldap_create_session(); + assert(session!=NULL); + /* perform search */ + printf("test_connections(): doing search...\n"); + search=myldap_search(session,nslcd_cfg->ldc_base, + LDAP_SCOPE_SUBTREE, + "(objectclass=posixaccount)", + attrs); + assert(search==NULL); + /* clean up */ + myldap_session_close(session); + /* restore the old URIs */ + for (i=0;i<(NSS_LDAP_CONFIG_URI_MAX+1);i++) + nslcd_cfg->ldc_uris[i]=old_uris[i]; +} + /* the main program... */ int main(int argc,char *argv[]) { @@ -268,5 +307,6 @@ int main(int argc,char *argv[]) test_get_values(); test_two_searches(); test_threads(); + test_connections(); return 0; } |