Update LDAP auth credentials, use built-in LDAP clean-up, fix broken tests.
This commit is contained in:
parent
80a7f7bd53
commit
8563340eff
3 changed files with 10 additions and 25 deletions
|
|
@ -27,17 +27,11 @@ use Scope::Guard;
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
# Create LDAP Link
|
# Create LDAP Link
|
||||||
my $ldapProps = {
|
my $ldapProps = WebGUI::Test->getSmokeLDAPProps();
|
||||||
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" ),
|
|
||||||
};
|
|
||||||
$session->db->setRow("ldapLink","ldapLinkId",$ldapProps, $ldapProps->{ldapLinkId});
|
$session->db->setRow("ldapLink","ldapLinkId",$ldapProps, $ldapProps->{ldapLinkId});
|
||||||
my $ldapLink = WebGUI::LDAPLink->new( $session, $ldapProps->{ldapLinkId} );
|
my $ldapLink = WebGUI::LDAPLink->new( $session, $ldapProps->{ldapLinkId} );
|
||||||
|
addToCleanup($ldapLink);
|
||||||
my $ldap = $ldapLink->bind;
|
my $ldap = $ldapLink->bind;
|
||||||
$session->setting->set('ldapConnection', $ldapProps->{ldapLinkId} );
|
$session->setting->set('ldapConnection', $ldapProps->{ldapLinkId} );
|
||||||
|
|
||||||
|
|
@ -47,17 +41,7 @@ $ldapGroup->set( "ldapLinkId", $ldapProps->{ldapLinkId} );
|
||||||
$ldapGroup->set( "ldapGroup", "cn=Convicts,o=shawshank" );
|
$ldapGroup->set( "ldapGroup", "cn=Convicts,o=shawshank" );
|
||||||
$ldapGroup->set( "ldapGroupProperty", "member" );
|
$ldapGroup->set( "ldapGroupProperty", "member" );
|
||||||
$ldapGroup->set( "ldapRecursiveProperty", "uid" );
|
$ldapGroup->set( "ldapRecursiveProperty", "uid" );
|
||||||
|
addToCleanup($ldapGroup);
|
||||||
# Cleanup
|
|
||||||
my @cleanup = (
|
|
||||||
Scope::Guard->new(sub {
|
|
||||||
$session->db->write("delete from ldapLink where ldapLinkId=?", [$ldapProps->{ldapLinkId}]);
|
|
||||||
}),
|
|
||||||
Scope::Guard->new( sub {
|
|
||||||
$ldapGroup->delete;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
@ -123,7 +107,7 @@ or diag( $auth->error );
|
||||||
WebGUI::Test->addToCleanup( $session->user );
|
WebGUI::Test->addToCleanup( $session->user );
|
||||||
|
|
||||||
# Test the the automatically registered user is in the right group
|
# 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->setting->set('automaticLDAPRegistration', 0);
|
||||||
$session->user({ userId => 1 }); # Restore Visitor
|
$session->user({ userId => 1 }); # Restore Visitor
|
||||||
|
|
|
||||||
|
|
@ -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';
|
cmp_deeply $ldap->get(), superhashof($ldapProps), 'all db properties retrieved';
|
||||||
my $connection = $ldap->bind();
|
my $connection = $ldap->bind();
|
||||||
isa_ok $connection, 'Net::LDAP', 'returned by 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';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
|
||||||
|
|
@ -508,11 +508,11 @@ Returns a hashref of properties for connecting to smoke's LDAP server.
|
||||||
sub getSmokeLDAPProps {
|
sub getSmokeLDAPProps {
|
||||||
my $ldapProps = {
|
my $ldapProps = {
|
||||||
ldapLinkName => "Test LDAP Link",
|
ldapLinkName => "Test LDAP Link",
|
||||||
ldapUrl => "ldaps://smoke.plainblack.com/ou=Convicts,o=shawshank", # Always test ldaps
|
ldapUrl => "ldaps://smoke.plainblack.com/o=shawshank", # Always test ldaps
|
||||||
connectDn => "cn=Samuel Norton,ou=Warden,o=shawshank",
|
connectDn => "cn=Warden,o=shawshank",
|
||||||
identifier => "gooey",
|
identifier => "gooey",
|
||||||
ldapUserRDN => "dn",
|
ldapUserRDN => "dn",
|
||||||
ldapIdentity => "cn",
|
ldapIdentity => "uid",
|
||||||
ldapLinkId => sprintf( '%022s', "testlink" ),
|
ldapLinkId => sprintf( '%022s', "testlink" ),
|
||||||
};
|
};
|
||||||
return $ldapProps;
|
return $ldapProps;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue