View | Details | Raw Unified | Return to bug 17615
Collapse All | Expand All

(-)a/C4/Auth_with_ldap.pm (-1 / +1 lines)
Lines 222-228 sub checkpw_ldap { Link Here
222
                next;
222
                next;
223
            }
223
            }
224
            if (C4::Members::Attributes::CheckUniqueness($code, $borrower{$code}, $borrowernumber)) {
224
            if (C4::Members::Attributes::CheckUniqueness($code, $borrower{$code}, $borrowernumber)) {
225
                C4::Members::Attributes::UpdateBorrowerAttribute($borrowernumber, {code => $code, value => $borrower{$code}});
225
                C4::Members::Attributes::UpdateBorrowerAttribute($borrowernumber, {code => $code, attribute => $borrower{$code}});
226
            } else {
226
            } else {
227
                warn "ERROR_extended_unique_id_failed $code $borrower{$code}";
227
                warn "ERROR_extended_unique_id_failed $code $borrower{$code}";
228
            }
228
            }
(-)a/t/db_dependent/Auth_with_ldap.t (-5 / +29 lines)
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::Mocks;
23
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
24
use Test::Warn;
25
use Test::Warn;
25
26
Lines 27-34 use C4::Context; Link Here
27
28
28
use Koha::Patrons;
29
use Koha::Patrons;
29
30
30
my $schema = Koha::Database->new->schema;
31
my $dbh = '';
31
$schema->storage->txn_begin;
32
33
# Start transaction
34
my $database = Koha::Database->new();
35
my $schema = $database->schema();
36
$schema->storage->txn_begin();
32
37
33
my $builder = t::lib::TestBuilder->new();
38
my $builder = t::lib::TestBuilder->new();
34
39
Lines 80-85 my $attr_type = $builder->build( Link Here
80
        }
85
        }
81
    }
86
    }
82
);
87
);
88
my $attr_type2    = $builder->build(
89
    {
90
        source => 'BorrowerAttributeType',
91
        value  => {
92
            category_code => $categorycode
93
        }
94
    }
95
);
83
96
84
my $borrower = $builder->build(
97
my $borrower = $builder->build(
85
    {
98
    {
Lines 131-137 subtest 'checkpw_ldap tests' => sub { Link Here
131
144
132
    subtest 'auth_by_bind = 1 tests' => sub {
145
    subtest 'auth_by_bind = 1 tests' => sub {
133
146
134
        plan tests => 8;
147
        plan tests => 9;
135
148
136
        $auth_by_bind = 1;
149
        $auth_by_bind = 1;
137
150
Lines 158-163 subtest 'checkpw_ldap tests' => sub { Link Here
158
        $update                        = 1;
171
        $update                        = 1;
159
        reload_ldap_module();
172
        reload_ldap_module();
160
173
174
        t::lib::Mocks::mock_preference( 'ExtendedPatronAttributes', 1 );
161
        my $auth = Test::MockModule->new('C4::Auth_with_ldap');
175
        my $auth = Test::MockModule->new('C4::Auth_with_ldap');
162
        $auth->mock(
176
        $auth->mock(
163
            'update_local',
177
            'update_local',
Lines 165-170 subtest 'checkpw_ldap tests' => sub { Link Here
165
                return $borrower->{cardnumber};
179
                return $borrower->{cardnumber};
166
            }
180
            }
167
        );
181
        );
182
        $auth->mock(
183
            'ldap_entry_2_hash',
184
            sub {
185
                return (
186
                    $attr_type2->{code}, 'BAR'
187
                );
188
            }
189
        );
168
190
169
        C4::Auth_with_ldap::checkpw_ldap( $dbh, 'hola', password => 'hey' );
191
        C4::Auth_with_ldap::checkpw_ldap( $dbh, 'hola', password => 'hey' );
170
        ok(
192
        ok(
Lines 175-181 subtest 'checkpw_ldap tests' => sub { Link Here
175
            },
197
            },
176
            'Extended attributes are not deleted'
198
            'Extended attributes are not deleted'
177
        );
199
        );
200
201
        is( C4::Members::Attributes::GetBorrowerAttributeValue($borrower->{borrowernumber}, $attr_type2->{code}), 'BAR', 'Mapped attribute is BAR' );
178
        $auth->unmock('update_local');
202
        $auth->unmock('update_local');
203
        $auth->unmock('ldap_entry_2_hash');
179
204
180
        $update               = 0;
205
        $update               = 0;
181
        $desired_count_result = 0;    # user auth problem
206
        $desired_count_result = 0;    # user auth problem
Lines 506-511 sub reload_ldap_module { Link Here
506
    return;
531
    return;
507
}
532
}
508
533
509
$schema->storage->txn_rollback;
534
$schema->storage->txn_rollback();
510
535
511
1;
536
1;
512
- 

Return to bug 17615