-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix status reporting for successful connects but bad binds. Fixes bug…
… #11216
- Loading branch information
1 parent
7c94f6f
commit bc21f90
Showing
5 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# vim:syntax=perl | ||
#------------------------------------------------------------------- | ||
# WebGUI is Copyright 2001-2009 Plain Black Corporation. | ||
#------------------------------------------------------------------- | ||
# Please read the legal notices (docs/legal.txt) and the license | ||
# (docs/license.txt) that came with this distribution before using | ||
# this software. | ||
#------------------------------------------------------------------ | ||
# http://www.plainblack.com info@plainblack.com | ||
#------------------------------------------------------------------ | ||
|
||
# Test Auth::LDAP to make sure it works with both ldap and ldaps | ||
# | ||
# | ||
|
||
use FindBin; | ||
use strict; | ||
use lib "$FindBin::Bin/lib"; | ||
use Test::More; | ||
use Test::Deep; | ||
use Data::Dumper; | ||
use WebGUI::Test; # Must use this before any other WebGUI modules | ||
use WebGUI::Session; | ||
use WebGUI::LDAPLink; | ||
|
||
#---------------------------------------------------------------------------- | ||
# Init | ||
my $session = WebGUI::Test->session; | ||
|
||
#---------------------------------------------------------------------------- | ||
# Tests | ||
|
||
plan tests => 8; # Increment this number for each test you create | ||
|
||
|
||
########################################################################### | ||
# | ||
# new | ||
# | ||
########################################################################### | ||
|
||
{ | ||
my $ldap = WebGUI::LDAPLink->new($session, "new"); | ||
addToCleanup($ldap); | ||
isa_ok($ldap, 'WebGUI::LDAPLink'); | ||
is $ldap->{_ldapLinkId}, "new", '... created with correct linkId'; | ||
} | ||
|
||
########################################################################### | ||
# | ||
# successful bind | ||
# | ||
########################################################################### | ||
|
||
{ | ||
my $ldapProps = WebGUI::Test->getSmokeLDAPProps(); | ||
$session->db->setRow('ldapLink', 'ldapLinkId', $ldapProps, $ldapProps->{ldapLinkId}); | ||
my $ldap = WebGUI::LDAPLink->new($session, $ldapProps->{ldapLinkId}); | ||
addToCleanup($ldap); | ||
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' | ||
} | ||
|
||
########################################################################### | ||
# | ||
# failed bind | ||
# | ||
########################################################################### | ||
|
||
{ | ||
my $ldapProps = WebGUI::Test->getSmokeLDAPProps(); | ||
$ldapProps->{identifier} = 'hadley'; | ||
$session->db->setRow('ldapLink', 'ldapLinkId', $ldapProps, $ldapProps->{ldapLinkId}); | ||
my $ldap = WebGUI::LDAPLink->new($session, $ldapProps->{ldapLinkId}); | ||
addToCleanup($ldap); | ||
my $connection = $ldap->bind(); | ||
isa_ok $connection, 'Net::LDAP', 'returned by bind'; | ||
is $ldap->{_error}, 104, 'auth error due to bad identifier'; | ||
is $ldap->getErrorCode, 104, 'getErrorCode returns the stored error code'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters