Bug 22478: (follow-up) [18.05.X ONLY] Fix rebase and fix selenium opac_auth
authorroot <root@f1ebe1bec408>
Tue, 7 May 2019 18:01:45 +0000 (18:01 +0000)
committerLucas Gass <lucas@bywatersolutions.com>
Wed, 1 May 2019 22:14:28 +0000 (22:14 +0000)
We missed a case or two in the backport, also picked changes from
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=76414&action=diff
in order to fix opac auth in selenium

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

t/db_dependent/selenium/regressions.t
t/lib/Selenium.pm

index cba2bf0..68a121b 100644 (file)
@@ -25,7 +25,7 @@ use Test::MockModule;
 use C4::Context;
 use C4::Biblio qw( AddBiblio );
 use C4::Circulation;
-use Koha::AuthUtils;
+use Koha::AuthUtils qw(hash_password);
 use t::lib::Selenium;
 use t::lib::TestBuilder;
 use t::lib::Mocks;
@@ -187,8 +187,11 @@ subtest 'XSS vulnerabilities in pagination' => sub {
     }
 
     my $password = Koha::AuthUtils::generate_password();
+    my $dbh   = C4::Context->dbh;
+    my $sth =  $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?");
     t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 );
-    $patron->set_password({ password => $password });
+    my $clave = hash_password( $password );
+    $sth->execute( $clave, $patron->borrowernumber );
     $s->opac_auth( $patron->userid, $password );
 
     my $public_lists = $s->opac_base_url . q|opac-shelves.pl?op=list&category=2|;
index 1a932a1..29f7ef4 100644 (file)
@@ -106,13 +106,12 @@ sub opac_auth {
 
     $login ||= $self->login;
     $password ||= $self->password;
-    my $mainpage = $self->base_url . 'opac-main.pl';
+    my $mainpage = $self->opac_base_url . 'opac-main.pl';
 
     $self->driver->get($mainpage . q|?logout.x=1|); # Logout before, to make sure we will see the login form
     $self->driver->get($mainpage);
     $self->fill_form( { userid => $login, password => $password } );
-    my $login_button = $self->driver->find_element('//input[@id="submit"]');
-    $login_button->submit();
+    $self->submit_form;
 }
 
 sub fill_form {