Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ services:
extends:
file: common/docker/perl.yml
service: perl
command: "prove -r imgsrv/t ls/t mdp-lib/t"
command: "prove -r imgsrv/t ls/t mb/t mdp-lib/t"
profiles:
- testing

Expand Down
6 changes: 3 additions & 3 deletions ls/lib/LS/PIFiller/ListSearchResults.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1309,14 +1309,14 @@ sub handle_ANALYTICS_REPORT_URL_PI
if ( $coll_id ) {
push @parts, 'listis';
push @parts, $coll_id;
push @parts, $cgi->param('lmt') || 'all';
push @parts, (scalar $cgi->param('lmt') || 'all');
} else {
push @parts, $cgi->param('a');
push @parts, scalar $cgi->param('a');
}

foreach my $param ( $cgi->param ) {
if ( $param =~ m,q[0-9]|field[0-9]|anyall[0-9]|op[0-9]|lmt, ) {
$tempCgi->param($param, $cgi->param($param));
$tempCgi->param($param, $cgi->multi_param($param));
Comment thread
moseshll marked this conversation as resolved.
}
}
my $qs = $tempCgi->query_string;
Expand Down
82 changes: 82 additions & 0 deletions ls/t/LS/PIFiller/ListSearchResults.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
use Test::More;
use UUID::Tiny;

use Auth::Auth;
use Data::Dumper;

use lib "$ENV{SDRROOT}/ls/lib";
use lib "$ENV{SDRROOT}/slip-lib";
use lib "$ENV{SDRROOT}/mdp-lib";
use lib "$ENV{SDRROOT}/mdp-lib/t/lib";
use LS::PIFiller::ListSearchResults;
#use Collection;


my $C = new Context;
my $cgi = new CGI;
$C->set_object('CGI', $cgi);
my $config = new MdpConfig(File::Spec->catdir($ENV{SDRROOT}, 'mdp-lib/Config/uber.conf'),
File::Spec->catdir($ENV{SDRROOT}, 'slip-lib/Config/common.conf'));
$C->set_object('MdpConfig', $config);

my $db_user = $ENV{'MARIADB_USER'} || 'ht_testing';
my $db = new Database($db_user);
$C->set_object('Database', $db);

my $dbh = $db->get_DBH;
$C->set_object('DBI', $dbh);


subtest "handle_ANALYTICS_REPORT_URL_PI" => sub {
# Note: these may not be realistic URLs. The point is to check for cgi->param warnings.
subtest "with a collection ID" => sub {
# Track warnings. We don't want any. They clutter the logs.
my @warnings;
local $SIG{__WARN__} = sub {
my $message = shift;
print STDERR $message;
push @warnings, $message;
};

my $cgi = $C->get_object('CGI');
# Given a query c=123&q1=something&sort=cn_a&colltype=featured&a=listcs&lmt-10
# The analytics URL should be /ls/listis/123/10?q1=something&lmt=10
# Be wary of brittleness with generated URL: param order may not be stable.
$cgi->param('c', '123');
$cgi->param('q1', 'something');
$cgi->param('sort', 'cn_a');
$cgi->param('colltype', 'featured');
$cgi->param('lmt', '10');
my $res = LS::PIFiller::ListSearchResults::handle_ANALYTICS_REPORT_URL_PI($C, '', {});
is($res, "/ls/listis/123/10?q1=something&lmt=10");
is(scalar @warnings, 0, 'no warnings encountered');
# Clean up
$C->set_object('CGI', new CGI);
};

subtest "without a collection ID" => sub {
# Track warnings. We don't want any. They clutter the logs.
my @warnings;
local $SIG{__WARN__} = sub {
my $message = shift;
print STDERR $message;
push @warnings, $message;
};

my $cgi = $C->get_object('CGI');
# Given a query q1=something&sort=cn_a&colltype=featured&a=listcs
# The analytics URL should be /ls/listcs?q1=something"
# Be wary of brittleness with generated URL: param order may not be stable.
$cgi->param('q1', 'something');
$cgi->param('sort', 'cn_a');
$cgi->param('colltype', 'featured');
$cgi->param('a', 'listcs');
my $res = LS::PIFiller::ListSearchResults::handle_ANALYTICS_REPORT_URL_PI($C, '', {});
is($res, "/ls/listcs?q1=something");
is(scalar @warnings, 0, 'no warnings encountered');
# Clean up
$C->set_object('CGI', new CGI);
};
};

done_testing();
2 changes: 1 addition & 1 deletion mb/lib/MBooks/Operation/LogoutTrap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ sub redirect_and_exit {

my $cgi = $C->get_object('CGI');
my $temp_cgi = new CGI($redir_params);
$temp_cgi->param('debug', $cgi->param('debug'));
$temp_cgi->param('debug', scalar $cgi->param('debug'));

my $redirect_url = $temp_cgi->self_url();
MBooks::View::P_redirect_HTTP($C, $redirect_url);
Expand Down
4 changes: 2 additions & 2 deletions mb/lib/MBooks/PIFiller/ListUtils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1122,12 +1122,12 @@ sub handle_ANALYTICS_REPORT_URL_PI
my @parts = ('/mb');
my $tempCgi = new CGI({});

push @parts, $cgi->param('a');
push @parts, scalar $cgi->param('a');
push @parts, $coll_id;

foreach my $param ( $cgi->param ) {
if ( $param =~ m,q[0-9]|field[0-9]|anyall[0-9]|op[0-9]|lmt|sort|facet, ) {
$tempCgi->param( $param, $cgi->param($param) );
$tempCgi->param( $param, $cgi->multi_param($param) );
}
}
my $qs = $tempCgi->query_string;
Expand Down
49 changes: 49 additions & 0 deletions mb/t/MBooks/PIFiller/ListUtils.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use Test::More;
use UUID::Tiny;

use Auth::Auth;
use Data::Dumper;

use lib "$ENV{SDRROOT}/mb/lib";
use lib "$ENV{SDRROOT}/slip-lib";
use MBooks::PIFiller::ListUtils;
use Collection;


my $C = new Context;
my $cgi = new CGI;
$C->set_object('CGI', $cgi);
my $config = new MdpConfig(File::Spec->catdir($ENV{SDRROOT}, 'mdp-lib/Config/uber.conf'),
File::Spec->catdir($ENV{SDRROOT}, 'slip-lib/Config/common.conf'));
$C->set_object('MdpConfig', $config);

my $db_user = $ENV{'MARIADB_USER'} || 'ht_testing';
my $db = new Database($db_user);
$C->set_object('Database', $db);

my $dbh = $db->get_DBH;
$C->set_object('DBI', $dbh);

subtest "handle_ANALYTICS_REPORT_URL_PI" => sub {
# Given a query a=listis&c=123&sort=title_d
# The analytics URL should be /mb/listis/<COLLID>?sort=title_d
# Be wary of brittleness if additional parameters are added: order may be random.
# Track warnings. We don't want any. They clutter the logs.
my @warnings;
local $SIG{__WARN__} = sub {
my $message = shift;
print STDERR $message;
push @warnings, $message;
};

$cgi->param('a', 'listis');
$cgi->param('c', '123');
$cgi->param('sort', 'title_d');
my $res = MBooks::PIFiller::ListUtils::handle_ANALYTICS_REPORT_URL_PI($C, '', {});
is($res, '/mb/listis/123?sort=title_d', 'expected URL returned');
is(scalar @warnings, 0, 'no warnings encountered');
# Clean up
$C->set_object('CGI', new CGI);
};

done_testing();
2 changes: 1 addition & 1 deletion pt/lib/PT/Prolog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ sub Run {
$cgi->param('seq', $ownerid_seq);
} else {
# log the ownerid failure to the appropriate seq
$ses->set_transient_subkey('messages', $cgi->param('seq'), 'ownerid');
$ses->set_transient_subkey('messages', scalar $cgi->param('seq'), 'ownerid');
}
}

Expand Down
Loading