From ab58974be7836e1c130c2f7cbc7455129baef118 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 patch 3) prove t/db_dependend/Auth_with_ldap.t -- no noise 4) run koha qa test tools --- 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 9d68055..5b4e532 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.1.4