Skip to content

Commit

Permalink
Explicit uncoverable statements for the server sub
Browse files Browse the repository at this point in the history
  • Loading branch information
josegomezr committed Nov 15, 2023
1 parent 6cc8e28 commit 7a6c5bb
Showing 1 changed file with 36 additions and 31 deletions.
67 changes: 36 additions & 31 deletions t/ui/27-plugin_obs_rsync_obs_status.t
Original file line number Diff line number Diff line change
Expand Up @@ -93,49 +93,54 @@ my $auth_header_exact
note 'Starting fake API server';

my $server_process = sub {
# uncoverable subroutine
my $mock = Mojolicious->new;
$mock->mode('test');
my $mock = Mojolicious->new; # uncoverable statement
$mock->mode('test'); # uncoverable statement

my $www_authenticate = qq(Signature realm="Use your developer account",headers="(created)"); # uncoverable statement
$mock->routes->get(
'/build/ProjWithAuth/_result' => sub {
my $c = shift;
my $c = shift; # uncoverable statement

if ($c->req->headers->authorization) {
return $c->render(status => 200, text => $fake_response_by_project{Proj1});
if ($c->req->headers->authorization) { # uncoverable statement
return $c->render(status => 200, text => $fake_response_by_project{Proj1}); # uncoverable statement
}

$c->res->headers->www_authenticate(qq(Signature realm="Use your developer account",headers="(created)"));
return $c->render(status => 401, text => 'login');
});
$c->res->headers->www_authenticate($www_authenticate); # uncoverable statement
; # uncoverable statement
return $c->render(status => 401, text => 'login'); # uncoverable statement
}); # uncoverable statement

$mock->routes->get(
'/build/ProjTestingSignature/_result' => sub {
my $c = shift;
'/build/ProjTestingSignature/_result' => sub { # uncoverable statement
my $c = shift; # uncoverable statement

if ($c->req->headers->authorization && $auth_header_exact eq $c->req->headers->authorization) {
return $c->render(status => 200, text => $fake_response_by_project{Proj1});
}
my $client_auth_header = $c->req->headers->authorization // ''; # uncoverable statement

if ($auth_header_exact eq $client_auth_header) { # uncoverable statement

return $c->render(status => 200, text => $fake_response_by_project{Proj1}); # uncoverable statement
} # uncoverable statement

$c->res->headers->www_authenticate($www_authenticate); # uncoverable statement
return $c->render(status => 401, text => 'login'); # uncoverable statement
}); # uncoverable statement

$c->res->headers->www_authenticate(qq(Signature realm="Use your developer account",headers="(created)"));
return $c->render(status => 401, text => 'login');
});

for my $project (sort keys %fake_response_by_project) {
$mock->routes->get(
"/build/$project/_result" => sub {
my $c = shift;
my $pkg = $c->param('package');
return $c->render(status => 404) if !$pkg and $project ne 'Proj1';
return $c->render(status => 200, text => $fake_response_by_project{$project});
});
for my $project (sort keys %fake_response_by_project) { # uncoverable statement
$mock->routes->get( # uncoverable statement
"/build/$project/_result" => sub { # uncoverable statement
my $c = shift; # uncoverable statement
my $pkg = $c->param('package'); # uncoverable statement
return $c->render(status => 404) if !$pkg and $project ne 'Proj1'; # uncoverable statement
return $c->render(status => 200, text => $fake_response_by_project{$project}); # uncoverable statement
}); # uncoverable statement
}
my $daemon = Mojo::Server::Daemon->new(app => $mock, listen => [$host]);
$daemon->run;
note 'Fake API server stopped';
_exit(0);
my $daemon = Mojo::Server::Daemon->new(app => $mock, listen => [$host]); # uncoverable statement
$daemon->run; # uncoverable statement
note 'Fake API server stopped'; # uncoverable statement
_exit(0); # uncoverable statement
};

my $server_instance = process ($server_process);
my $server_instance = process($server_process);
$server_instance->set_pipes(0)->start;
wait_for_or_bail_out { IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => $port) } 'API';

Expand Down

0 comments on commit 7a6c5bb

Please sign in to comment.