Update LDAP auth credentials, use built-in LDAP clean-up, fix broken tests.

This commit is contained in:
Colin Kuskie 2010-02-09 18:20:49 -08:00
parent 80a7f7bd53
commit 8563340eff
3 changed files with 10 additions and 25 deletions

View file

@ -27,17 +27,11 @@ use Scope::Guard;
my $session = WebGUI::Test->session;
# Create LDAP Link
my $ldapProps = {
ldapLinkName => "Test LDAP Link",
ldapUrl => "ldaps://smoke.plainblack.com/o=shawshank", # Always test ldaps
connectDn => "cn=Warden,o=shawshank",
identifier => "gooey",
ldapUserRDN => "dn",
ldapIdentity => "uid",
ldapLinkId => sprintf( '%022s', "testlink" ),
};
my $ldapProps = WebGUI::Test->getSmokeLDAPProps();
$session->db->setRow("ldapLink","ldapLinkId",$ldapProps, $ldapProps->{ldapLinkId});
my $ldapLink = WebGUI::LDAPLink->new( $session, $ldapProps->{ldapLinkId} );
addToCleanup($ldapLink);
my $ldap = $ldapLink->bind;
$session->setting->set('ldapConnection', $ldapProps->{ldapLinkId} );
@ -47,17 +41,7 @@ $ldapGroup->set( "ldapLinkId", $ldapProps->{ldapLinkId} );
$ldapGroup->set( "ldapGroup", "cn=Convicts,o=shawshank" );
$ldapGroup->set( "ldapGroupProperty", "member" );
$ldapGroup->set( "ldapRecursiveProperty", "uid" );
# Cleanup
my @cleanup = (
Scope::Guard->new(sub {
$session->db->write("delete from ldapLink where ldapLinkId=?", [$ldapProps->{ldapLinkId}]);
}),
Scope::Guard->new( sub {
$ldapGroup->delete;
}),
);
addToCleanup($ldapGroup);
#----------------------------------------------------------------------------
# Tests
@ -123,7 +107,7 @@ or diag( $auth->error );
WebGUI::Test->addToCleanup( $session->user );
# Test the the automatically registered user is in the right group
ok( $session->user->isInGroup( $ldapGroup->getId ) );
ok( $session->user->isInGroup( $ldapGroup->getId ), 'Automatically registered user is in the correct group');
$session->setting->set('automaticLDAPRegistration', 0);
$session->user({ userId => 1 }); # Restore Visitor

View file

@ -60,7 +60,8 @@ plan tests => 9; # Increment this number for each test you create
cmp_deeply $ldap->get(), superhashof($ldapProps), 'all db properties retrieved';
my $connection = $ldap->bind();
isa_ok $connection, 'Net::LDAP', 'returned by bind';
is $ldap->{'_error'}, undef, 'no errors from binding'
is $ldap->getErrorCode, undef, 'no errors from binding';
}
###########################################################################

View file

@ -508,11 +508,11 @@ Returns a hashref of properties for connecting to smoke's LDAP server.
sub getSmokeLDAPProps {
my $ldapProps = {
ldapLinkName => "Test LDAP Link",
ldapUrl => "ldaps://smoke.plainblack.com/ou=Convicts,o=shawshank", # Always test ldaps
connectDn => "cn=Samuel Norton,ou=Warden,o=shawshank",
ldapUrl => "ldaps://smoke.plainblack.com/o=shawshank", # Always test ldaps
connectDn => "cn=Warden,o=shawshank",
identifier => "gooey",
ldapUserRDN => "dn",
ldapIdentity => "cn",
ldapIdentity => "uid",
ldapLinkId => sprintf( '%022s', "testlink" ),
};
return $ldapProps;