From b140c4b2fdc894c0d53eca2bf2f2bb5cb1982a91 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Mon, 4 Apr 2016 18:07:26 -0400 Subject: [PATCH] Bug 14144: Silence warnings t/db_dependent/Auth_with_ldap.t Revisiting this bug, I noticed that C4::Context->config() was mocked poorly. I expanded the mock function a little and have quieted the test which seemed to be working in a broken manner before. TEST PLAN --------- 1) prove t/db_dependend/Auth_with_ldap.t -- shibboleth noise 2) apply this patch 3) prove t/db_dependend/Auth_with_ldap.t -- no noise 4) run koha qa test tools Signed-off-by: Hector Castro Signed-off-by: Kyle M Hall Signed-off-by: Kyle M Hall --- t/db_dependent/Auth_with_ldap.t | 71 +++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/t/db_dependent/Auth_with_ldap.t b/t/db_dependent/Auth_with_ldap.t index 9d68055aa3..5b4e532b4f 100755 --- a/t/db_dependent/Auth_with_ldap.t +++ b/t/db_dependent/Auth_with_ldap.t @@ -270,37 +270,50 @@ subtest "search_method tests" => sub { # Function that mocks the call to C4::Context->config(param) sub mockedC4Config { - + my $class = shift; my $param = shift; - my %ldap_mapping = ( - firstname => { is => 'givenname' }, - surname => { is => 'sn' }, - address => { is => 'postaladdress' }, - city => { is => 'l' }, - zipcode => { is => 'postalcode' }, - branchcode => { is => 'branch' }, - userid => { is => 'uid' }, - password => { is => 'userpassword' }, - email => { is => 'mail' }, - categorycode => { is => 'employeetype' }, - phone => { is => 'telephonenumber' } - ); - - my %ldap_config = ( - anonymous_bind => $anonymous_bind, - auth_by_bind => $auth_by_bind, - base => 'dc=metavore,dc=com', - hostname => 'localhost', - mapping => \%ldap_mapping, - pass => 'metavore', - principal_name => '%s@my_domain.com', - replicate => $replicate, - update => $update, - user => 'cn=Manager,dc=metavore,dc=com' - ); - - return \%ldap_config; + if ($param eq 'useshibboleth') { + return 0; + } + elsif ($param eq 'ldapserver') { + my %ldap_mapping = ( + firstname => { is => 'givenname' }, + surname => { is => 'sn' }, + address => { is => 'postaladdress' }, + city => { is => 'l' }, + zipcode => { is => 'postalcode' }, + branchcode => { is => 'branch' }, + userid => { is => 'uid' }, + password => { is => 'userpassword' }, + email => { is => 'mail' }, + categorycode => { is => 'employeetype' }, + phone => { is => 'telephonenumber' } + ); + + my %ldap_config = ( + anonymous_bind => $anonymous_bind, + auth_by_bind => $auth_by_bind, + base => 'dc=metavore,dc=com', + hostname => 'localhost', + mapping => \%ldap_mapping, + pass => 'metavore', + principal_name => '%s@my_domain.com', + replicate => $replicate, + update => $update, + user => 'cn=Manager,dc=metavore,dc=com' + ); + return \%ldap_config; + } + elsif ($param =~ /(intranetdir|opachtdocs|intrahtdocs)/ ) { + return ''; + } + elsif (ref $class eq 'HASH') { + return $class->{$param}; + } + else { + return; + } }; # Function that mocks the call to Net::LDAP -- 2.39.5