From 8563340eff6b23b7fbd018f06f38cedae1d3910a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 9 Feb 2010 18:20:49 -0800 Subject: [PATCH] Update LDAP auth credentials, use built-in LDAP clean-up, fix broken tests. --- t/Auth/LDAP.t | 26 +++++--------------------- t/LDAPLink.t | 3 ++- t/lib/WebGUI/Test.pm | 6 +++--- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/t/Auth/LDAP.t b/t/Auth/LDAP.t index 89381ca69..39bf8a19c 100644 --- a/t/Auth/LDAP.t +++ b/t/Auth/LDAP.t @@ -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 diff --git a/t/LDAPLink.t b/t/LDAPLink.t index 251832811..bc243002d 100644 --- a/t/LDAPLink.t +++ b/t/LDAPLink.t @@ -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'; + } ########################################################################### diff --git a/t/lib/WebGUI/Test.pm b/t/lib/WebGUI/Test.pm index 20f1d9fdb..f1c3dfa8a 100644 --- a/t/lib/WebGUI/Test.pm +++ b/t/lib/WebGUI/Test.pm @@ -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;