Skip to content

Commit

Permalink
LDEV-4117 switch to rroemhild/test-openldap for build
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Jul 30, 2022
1 parent 195861f commit 87bb311
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 117 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ jobs:
- 3995:3995 #POP3S
- 8080:8080 #API
ldap:
image: kwart/ldap-server
ports:
- 10389:10389
- 10636:10636
# image: kwart/ldap-server
image: rroemhild/test-openldap
ports:
- 10389:10389
- 10636:10636
steps:
# when workflow is run via a workflow_call, these vars are found under input, which doesn't exist otherwise
# so lets copy them over to the normal env vars
Expand Down Expand Up @@ -178,9 +179,9 @@ jobs:
POP_PASSWORD: doesntmatter
LDAP_SERVER: localhost
LDAP_PORT: 10389
LDAP_BASE_DN: dc=example
LDAP_USERNAME: uid=jduke,ou=Users,dc=ldap,dc=example
# LDAP_PASSWORD: theduke
LDAP_BASE_DN: dc=planetexpress,dc=com
LDAP_USERNAME: cn=admin,dc=planetexpress,dc=com
LDAP_PASSWORD: GoodNewsEveryone
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_ID_TEST }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY_TEST }}
# DO_DEPLOY: ${{ github.event_name == 'push' }}
Expand Down
7 changes: 4 additions & 3 deletions test/_setupTestServices.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ component {
server.test_services[arguments.service].valid = true;
} catch (e) {
systemOutput( "ERROR Service [ #arguments.service# ] threw [ #cfcatch.message# ]", true);
if ( cfcatch.message contains "NullPointerException" || request.testDebug )
//if ( cfcatch.message contains "NullPointerException" || request.testDebug )
systemOutput(cfcatch, true);
}
}
Expand Down Expand Up @@ -370,13 +370,14 @@ component {
systemOutput( ldap, true );
cfldap( server=ldap.server,
port=ldap.port,
timeout=5,
timeout=5000,
username=ldap.username,
password=ldap.password,
action="query",
name="local.results",
start=ldap.base_dn,
attributes="cn,ou" );
filter="(objectClass=inetOrgPerson)",
attributes="cn" );
systemOutput( results, true );
return "configured";
}
Expand Down
208 changes: 101 additions & 107 deletions test/tags/LDAP.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
component extends="org.lucee.cfml.test.LuceeTestCase" labels="ldap" {

// uses docke image form docker pull rroemhild/test-openldap

public function beforeAll(){
variables.ldap = server.getTestService( "ldap" );
}
Expand All @@ -11,149 +13,141 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="ldap" {
function run( testResults, textbox ) {
describe(title="checking CFLDAP tag", body = function( currentSpec ) {
it(title="ldap action=query", skip=isDisabled(), body = function( currentSpec ) {
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="query",
name="local.results",
start=ldap.base_dn,
attributes="cn,ou" );
systemOutput( results, true );
// firstly do we have some data in LDAP
var results = ldapQuery( start=ldap.base_dn );
expect( results.recordcount ).toBeGT( 0 );
});

it (title="ldap action=modify", skip=isDisabled(), body = function( currentSpec ) {
// rename user
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="modify",
dn="uid=jduke,ou=Users,dc=ldap,dc=example",
name="local.results",
attributes="cn=Lucee Dev" );
// create a user
ldapAdd( dn="uid=ralio,ou=people,#ldap.base_dn#",
attributes=ldapAddAttributes( cn="Ralio", sn="Fusion", uid="ralio" ) );

// update user
ldapUpdate( dn="uid=ralio,ou=people,#ldap.base_dn#", attributes="cn=Lucee Dev");

// check user is renamed
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="query",
name="local.results",
start=ldap.base_dn,
filter="uid=jduke",
attributes="cn,ou" );

systemOutput( results, true );
var results = ldapQuery( start=ldap.base_dn, filter="(cn=Lucee Dev)" );
expect( results.recordcount ).toBe( 1 );
expect( results.cn ).toBe( "Lucee Dev" );

});

it (title="ldap action=modifyDN", skip=true, body = function( currentSpec ) {
// add user
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="add",
dn="uid=ralio,ou=Users,dc=ldap,dc=example",
name="local.results",
attributes="cn=ralio"
);
ldapAdd( dn="uid=cfml,ou=people,#ldap.base_dn#",
attributes=ldapAddAttributes( cn="Cold Fusion", sn="Fusion", uid="cfml" ) );

// check user exists
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="query",
name="local.results",
start=ldap.base_dn,
filter="uid=ralio",
attributes="cn,ou,uid");

var results = ldapQuery(start=ldap.base_dn, filter="(cn=cfml)");
expect( results.recordcount ).toBe( 1 );
expect( results.cn ).toBe( "ralio" );
expect( results.cn ).toBe( "Cold fusion" );

// rename user
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="modifyDN",
dn="uid=ralio,ou=Users,dc=ldap,dc=example",
name="local.results",
attributes="cn=Lucee" );
ldapRename( dn="uid=cfml,ou=people,#ldap.base_dn#", attributes="cn=Lucee");

// check user is renamed
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="query",
name="local.results",
start=ldap.base_dn,
filter="uid=ralio",
attributes="cn,ou" );

systemOutput( results, true );
var results = ldapQuery(start=ldap.base_dn, filter="(cn=Lucee)" );
expect( results.cn ).toBe( "Lucee" );

});

it (title="ldap action=add then delete", skip=isDisabled(), body = function( currentSpec ) {
// add user
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="add",
dn="uid=lucee,ou=Users,dc=ldap,dc=example",
name="local.results",
attributes="cn=Lucee"
);
ldapAdd( dn="uid=Lucee,ou=people,#ldap.base_dn#",
attributes=ldapAddAttributes( cn="Lucee", sn="6.0", uid="Lucee" ) );

// check user exists
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="query",
name="local.results",
start=ldap.base_dn,
filter="uid=lucee",
attributes="cn,ou,uid");

var results = ldapQuery(start=ldap.base_dn, filter="(cn=lucee)");
expect( results.recordcount ).toBe( 1 );
expect( results.cn ).toBe( "Lucee" );

// delete user
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="delete",
dn="uid=lucee,ou=Users,dc=ldap,dc=example",
name="local.results"
);
ldapDelete( dn="uid=lucee,ou=people,#ldap.base_dn#" );

// check user no longer exists
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="query",
name="local.results",
start=ldap.base_dn,
filter="uid=lucee",
attributes="cn,ou,uid");

systemOutput( results, true );
var results = ldapQuery(start=ldap.base_dn, filter="(cn=lucee)");
expect( results.recordcount ).toBe( 0 );

});
});
}

private function ldapQuery(
string start=ldap.base_dn,
string filter="(objectClass=inetOrgPerson)",
string attributes="cn,ou,uid" ) {
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="query",
name="local.results",
start=arguments.start,
filter=arguments.filter,
attributes=arguments.attributes);
// systemOutput( results, true );
return results;
}

private function ldapAdd(
required string dn,
required string attributes) {
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="add",
dn=arguments.dn,
attributes=arguments.attributes
);

}

private function ldapDelete(
required string dn ) {
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="delete",
dn=arguments.dn
);
}

private function ldapRename(
required string dn,
required attributes ){
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="modifyDN",
dn=arguments.dn,
attributes=arguments.attributes
);
}

private function ldapUpdate(
required string dn,
required attributes ){
cfldap( server=ldap.server,
port=ldap.port,
username=ldap.username,
password=ldap.password,
action="modify",
dn=arguments.dn,
attributes=arguments.attributes
);
}

private function ldapAddAttributes(cn, sn, uid){
return "objectclass=inetOrgPerson;"
& "cn=#trim(arguments.cn)#;"
& "sn=#trim(arguments.sn)#;"
& "uid=#trim(arguments.uid)#";
// mail=#Trim(Form.email)#;
// telephonenumber=#Trim(Form.phone)#;
// ou=Human Resources;
}

}

0 comments on commit 87bb311

Please sign in to comment.