Prepare own slapd server (#1118)
Insert "export LLNGTESTLDAP=1" in your .bashrc to enable LDAP tests
This commit is contained in:
parent
83ab7d59bc
commit
656d631482
|
@ -421,4 +421,7 @@ t/sessions/lock/.exists
|
|||
t/sessions/saml/lock/.exists
|
||||
t/sessions2/6e30af4ffa5689b3e49a104d1b160d316db2b2161a0f45776994eed19dbdc101
|
||||
t/sessions2/lock/Apache-Session-6e30af4ffa5689b3e49a104d1b160d316db2b2161a0f45776994eed19dbdc101.lock
|
||||
t/test-ldap.pm
|
||||
t/test-lib.pm
|
||||
t/testslapd/slapd.ldif
|
||||
t/testslapd/users.ldif
|
||||
|
|
|
@ -7,7 +7,8 @@ require 't/test-lib.pm';
|
|||
my $res;
|
||||
|
||||
SKIP: {
|
||||
skip 'No LDAP server given', 1 unless ( $ENV{LDAPSERVER} );
|
||||
skip 'LLNGTESTLDAP is not set', 1 unless ( $ENV{LLNGTESTLDAP} );
|
||||
require 't/test-ldap.pm';
|
||||
|
||||
my $client = LLNG::Manager::Test->new(
|
||||
{
|
||||
|
@ -18,11 +19,10 @@ SKIP: {
|
|||
portal => 'http://auth.example.com/',
|
||||
userDB => 'Same',
|
||||
registerDB => 'LDAP',
|
||||
LDAPFilter => $ENV{LDAPFILTER} || '(cn=$user)',
|
||||
ldapServer => $ENV{LDAPSERVER},
|
||||
ldapBase => $ENV{LDAPBASE},
|
||||
managerDn => $ENV{MANAGERDN} || '',
|
||||
managerPassword => $ENV{MANAGERPASSWORD} || '',
|
||||
ldapServer => 'ldap://127.0.0.1:19389/',
|
||||
ldapBase => 'dc=example,dc=com',
|
||||
managerDn => '',
|
||||
managerPassword => '',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -47,4 +47,5 @@ SKIP: {
|
|||
clean_sessions();
|
||||
}
|
||||
count(1);
|
||||
stopLdapServer();
|
||||
done_testing( count() );
|
||||
|
|
20
lemonldap-ng-portal/t/test-ldap.pm
Normal file
20
lemonldap-ng-portal/t/test-ldap.pm
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Try to launch an LDAP server
|
||||
|
||||
if($ENV{LLNGTESTLDAP}) {
|
||||
eval { mkdir 't/testslapd/data' };
|
||||
system('/usr/sbin/slapadd -F t/testslapd/ -n 0 -l t/testslapd/slapd.ldif');
|
||||
system('/usr/sbin/slapadd -F t/testslapd/ -l t/testslapd/users.ldif');
|
||||
system('/usr/sbin/slapd -h "ldap://127.0.0.1:19389/" -F t/testslapd');
|
||||
}
|
||||
|
||||
sub stopLdapServer {
|
||||
if($ENV{LLNGTESTLDAP}) {
|
||||
open F, 't/testslapd/slapd.pid';
|
||||
my $pid = join '', <F>;
|
||||
system "kill $pid";
|
||||
system 'rm -rf t/testslapd/cn\=config*';
|
||||
system 'rm -rf t/testslapd/data';
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
63
lemonldap-ng-portal/t/testslapd/slapd.ldif
Normal file
63
lemonldap-ng-portal/t/testslapd/slapd.ldif
Normal file
|
@ -0,0 +1,63 @@
|
|||
dn: cn=config
|
||||
objectClass: olcGlobal
|
||||
cn: config
|
||||
olcPidFile: t/testslapd/slapd.pid
|
||||
olcAttributeOptions: x-hidden lang-
|
||||
|
||||
dn: cn=schema,cn=config
|
||||
objectClass: olcSchemaConfig
|
||||
cn: schema
|
||||
|
||||
include: file:///etc/ldap/schema/core.ldif
|
||||
include: file:///etc/ldap/schema/cosine.ldif
|
||||
include: file:///etc/ldap/schema/nis.ldif
|
||||
include: file:///etc/ldap/schema/inetorgperson.ldif
|
||||
|
||||
dn: olcDatabase=frontend,cn=config
|
||||
objectClass: olcDatabaseConfig
|
||||
objectClass: olcFrontendConfig
|
||||
olcDatabase: frontend
|
||||
olcAccess: to attrs=name;x-hidden by * =cs
|
||||
olcAccess: to attrs=userPassword by * auth
|
||||
olcAccess: to * by * read
|
||||
|
||||
dn: olcDatabase=config,cn=config
|
||||
objectClass: olcDatabaseConfig
|
||||
olcDatabase: config
|
||||
olcRootPW: admin
|
||||
olcAccess: to * by * none
|
||||
|
||||
dn: cn=module,cn=config
|
||||
objectClass: olcModuleList
|
||||
cn: module
|
||||
# Where the dynamically loaded modules are stored
|
||||
olcModulePath: /usr/lib/ldap
|
||||
olcModuleLoad: back_mdb
|
||||
|
||||
dn: olcDatabase=mdb,cn=config
|
||||
objectClass: olcDatabaseConfig
|
||||
objectClass: olcMdbConfig
|
||||
olcDatabase: mdb
|
||||
olcSuffix: dc=example,dc=com
|
||||
olcDbDirectory: t/testslapd/data
|
||||
olcAccess: to * by * read
|
||||
olcRootDN: cn=admin,dc=example,dc=com
|
||||
olcRootPW: admin
|
||||
olcAccess: to * by * read
|
||||
olcLastMod: TRUE
|
||||
|
||||
#dn: olcDatabase=ldap,cn=config
|
||||
#objectClass: olcDatabaseConfig
|
||||
#objectClass: olcLdapConfig
|
||||
#olcDatabase: ldap
|
||||
#olcSuffix: ""
|
||||
#olcDbUri: ldap://auth.example.com:19389/
|
||||
|
||||
#dn: uid=dwho,dc=example,dc=com
|
||||
#objectClass: inetOrgPerson
|
||||
#olcDatabase: mdb
|
||||
#uid: dwho
|
||||
#cn: Dr Who
|
||||
#mail: dwho
|
||||
#userPassword: dwho
|
||||
|
15
lemonldap-ng-portal/t/testslapd/users.ldif
Normal file
15
lemonldap-ng-portal/t/testslapd/users.ldif
Normal file
|
@ -0,0 +1,15 @@
|
|||
dn: dc=example,dc=com
|
||||
objectClass: top
|
||||
objectClass: organization
|
||||
objectClass: dcObject
|
||||
dc: example
|
||||
o: Example
|
||||
|
||||
dn: uid=dwho,dc=example,dc=com
|
||||
objectClass: inetOrgPerson
|
||||
uid: dwho
|
||||
cn: Dr Who
|
||||
sn: Who
|
||||
mail: dwho
|
||||
userPassword: dwho
|
||||
|
Loading…
Reference in New Issue
Block a user