Lines 20-25
use Modern::Perl;
Link Here
|
20 |
use Test::More tests => 4; |
20 |
use Test::More tests => 4; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::MockObject; |
22 |
use Test::MockObject; |
|
|
23 |
use t::lib::TestBuilder; |
23 |
use Test::Warn; |
24 |
use Test::Warn; |
24 |
|
25 |
|
25 |
use C4::Context; |
26 |
use C4::Context; |
Lines 29-34
my $dbh = C4::Context->dbh;
Link Here
|
29 |
$dbh->{ AutoCommit } = 0; |
30 |
$dbh->{ AutoCommit } = 0; |
30 |
$dbh->{ RaiseError } = 1; |
31 |
$dbh->{ RaiseError } = 1; |
31 |
|
32 |
|
|
|
33 |
my $builder = t::lib::TestBuilder->new(); |
34 |
|
32 |
# Variables controlling LDAP server config |
35 |
# Variables controlling LDAP server config |
33 |
my $update = 0; |
36 |
my $update = 0; |
34 |
my $replicate = 0; |
37 |
my $replicate = 0; |
Lines 61-66
$ldap->mock( 'new', sub {
Link Here
|
61 |
} |
64 |
} |
62 |
}); |
65 |
}); |
63 |
|
66 |
|
|
|
67 |
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; |
68 |
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; |
69 |
my $attrType = $builder->build({ |
70 |
source => 'BorrowerAttributeType', |
71 |
value => { |
72 |
category_code => $categorycode |
73 |
} |
74 |
}); |
75 |
|
76 |
my $borrower = $builder->build({ |
77 |
source => 'Borrower', |
78 |
value => { |
79 |
userid => 'hola', |
80 |
branchcode => $branchcode, |
81 |
categorycode => $categorycode |
82 |
} |
83 |
}); |
84 |
|
85 |
$builder->build({ |
86 |
source => 'BorrowerAttribute', |
87 |
value => { |
88 |
borrowernumber => $borrower->{borrowernumber}, |
89 |
code => $attrType->{code}, |
90 |
attribute => 'FOO' |
91 |
} |
92 |
}); |
64 |
|
93 |
|
65 |
# C4::Auth_with_ldap needs several stuff set first ^^^ |
94 |
# C4::Auth_with_ldap needs several stuff set first ^^^ |
66 |
use_ok( 'C4::Auth_with_ldap' ); |
95 |
use_ok( 'C4::Auth_with_ldap' ); |
Lines 84-90
subtest "checkpw_ldap tests" => sub {
Link Here
|
84 |
|
113 |
|
85 |
subtest "auth_by_bind = 1 tests" => sub { |
114 |
subtest "auth_by_bind = 1 tests" => sub { |
86 |
|
115 |
|
87 |
plan tests => 7; |
116 |
plan tests => 8; |
88 |
|
117 |
|
89 |
$auth_by_bind = 1; |
118 |
$auth_by_bind = 1; |
90 |
|
119 |
|
Lines 105-112
subtest "checkpw_ldap tests" => sub {
Link Here
|
105 |
$anonymous_bind = 1; |
134 |
$anonymous_bind = 1; |
106 |
$desired_bind_result = 'success'; |
135 |
$desired_bind_result = 'success'; |
107 |
$desired_search_result = 'success'; |
136 |
$desired_search_result = 'success'; |
108 |
$desired_count_result = 0; # user auth problem |
137 |
$desired_count_result = 1; |
109 |
$non_anonymous_bind_result = 'success'; |
138 |
$non_anonymous_bind_result = 'success'; |
|
|
139 |
$update = 1; |
140 |
reload_ldap_module(); |
141 |
|
142 |
my $auth = new Test::MockModule('C4::Auth_with_ldap'); |
143 |
$auth->mock( 'update_local', sub { |
144 |
return $borrower->{cardnumber}; |
145 |
}); |
146 |
|
147 |
C4::Auth_with_ldap::checkpw_ldap( $dbh, 'hola', password => 'hey'); |
148 |
ok(@{ C4::Members::Attributes::GetBorrowerAttributes($borrower->{borrowernumber}) }, 'Extended attributes are not deleted'); |
149 |
$auth->unmock('update_local'); |
150 |
|
151 |
$update = 0; |
152 |
$desired_count_result = 0; # user auth problem |
153 |
C4::Members::DelMember($borrower->{borrowernumber}); |
110 |
reload_ldap_module(); |
154 |
reload_ldap_module(); |
111 |
is ( C4::Auth_with_ldap::checkpw_ldap( $dbh, 'hola', password => 'hey' ), |
155 |
is ( C4::Auth_with_ldap::checkpw_ldap( $dbh, 'hola', password => 'hey' ), |
112 |
0, "checkpw_ldap returns 0 if user lookup returns 0"); |
156 |
0, "checkpw_ldap returns 0 if user lookup returns 0"); |
113 |
- |
|
|