Bugzilla – Attachment 161078 Details for
Bug 29930
'cardnumber' overwritten with userid when not mapped (LDAP auth)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29930: Regression tests
Bug-29930-Regression-tests.patch (text/plain), 3.63 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-01-16 23:26:04 UTC
(
hide
)
Description:
Bug 29930: Regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-01-16 23:26:04 UTC
Size:
3.63 KB
patch
obsolete
>From 7f567c52e086c0847b27cbf0547aaccdddec29be Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 16 Jan 2024 20:01:22 -0300 >Subject: [PATCH] Bug 29930: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Auth_with_ldap.t | 65 ++++++++++++++++++++++++++++++++- > 1 file changed, 63 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Auth_with_ldap.t b/t/db_dependent/Auth_with_ldap.t >index 7afba770140..19e95d24fb5 100755 >--- a/t/db_dependent/Auth_with_ldap.t >+++ b/t/db_dependent/Auth_with_ldap.t >@@ -51,6 +51,7 @@ my $auth_by_bind = 1; > my $anonymous_bind = 1; > my $user = 'cn=Manager,dc=metavore,dc=com'; > my $pass = 'metavore'; >+my $attrs = {}; > > # Variables controlling LDAP behaviour > my $desired_authentication_result = 'success'; >@@ -137,7 +138,7 @@ can_ok( > > subtest 'checkpw_ldap tests' => sub { > >- plan tests => 4; >+ plan tests => 5; > > ## Connection fail tests > $desired_connection_result = 'error'; >@@ -372,6 +373,66 @@ qr/LDAP Auth rejected : invalid password for user 'hola'./, > is( $ret, -1, 'checkpw_ldap returns -1 if bind fails (Bug 8148)' ); > > }; >+ >+ subtest "'update' config tets" => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $cardnumber = '123456789'; >+ my $userid = '987654321'; >+ >+ # test safety cleanup >+ Koha::Patrons->search( [ { cardnumber => $cardnumber }, { userid => $userid } ] )->delete; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { cardnumber => $cardnumber, userid => $userid }, >+ } >+ ); >+ >+ # avoid noise >+ t::lib::Mocks::mock_preference( 'ExtendedPatronAttributes', 0 ); >+ $welcome = 0; >+ $replicate = 0; >+ >+ # the scenario >+ $update = 1; >+ >+ $anonymous_bind = 0; >+ $desired_count_result = 1; >+ $desired_authentication_result = 'success'; >+ $desired_admin_bind_result = 'success'; >+ $desired_search_result = 'success'; >+ $desired_bind_result = 'success'; >+ >+ $attrs = { >+ branch => [ $patron->branchcode ], >+ employeetype => [ $patron->categorycode ], >+ givenname => [ $patron->firstname ], >+ mail => [ $patron->email ], >+ postaladdress => [ $patron->address ], >+ sn => [ $patron->surname ], >+ uid => [ $patron->userid ], >+ userpassword => ['some password'], >+ }; >+ >+ reload_ldap_module(); >+ >+ my ( $ret_val, $ret_cardnumber, $ret_userid ) = >+ C4::Auth_with_ldap::checkpw_ldap( $patron->userid, password => 'hey' ); >+ >+ ok( $ret_val, 'Authentication success returns 1' ); >+ is( $ret_cardnumber, $cardnumber, "The correct 'cardnumber' is returned" ); >+ is( $ret_userid, $userid, "The correct 'userid' is returned" ); >+ >+ $patron->discard_changes; >+ is( $patron->cardnumber, $cardnumber, 'The cardnumber is not mistakenly changed to userid when not mapped' ); >+ >+ $schema->storage->txn_rollback; >+ }; > }; > > subtest 'search_method tests' => sub { >@@ -542,7 +603,7 @@ sub mock_net_ldap_message { > sub mock_net_ldap_entry { > my ( $dn, $exists ) = @_; > >- my $mocked_entry = Test::MockObject->new(); >+ my $mocked_entry = Test::MockObject->new( { attrs => $attrs } ); > $mocked_entry->mock( 'dn', sub { return $dn; } ); > $mocked_entry->mock( 'exists', sub { return $exists } ); > >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29930
:
130926
|
154347
|
161078
|
161079
|
161085
|
161089
|
161090
|
161200
|
161201