| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Mojolicious::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Cwd qw(abs_path); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use File::Find qw(find); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use File::Spec::Functions qw(catdir catfile); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use File::Temp qw(tempdir); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use IO::Compress::Zip qw($ZipError); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use MIME::Base64 qw(encode_base64); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | our $API_DIR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | $API_DIR = dirname( abs_path(__FILE__) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | require lib; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | lib->import("$API_DIR/../../lib"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use Convert::Pheno::HTTP::Service qw(catalog execute execute_files health is_service_error lookup_omop_concept); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use Convert::Pheno::HTTP::Jobs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use Mojo::Util qw(secure_compare); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use Mojo::File (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | use Mojo::JSON qw(decode_json false); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | ▶ | my $MAX_UPLOAD_BYTES = $ENV{CONVERT_PHENO_HTTP_MAX_UPLOAD_BYTES} || 100 * 1024 * 1024; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'CONVERT_PHENO_HTTP_MAX_UPLOAD_BYTES'} || 104857600
MC/DC0%0/1
$ENV{'CONVERT_PHENO_HTTP_MAX_UPLOAD_BYTES'} || 104857600
$ENV{'CONVERT_PHENO_HTTP_MAX_UPLOAD_BYTES'}
Truth table50%1/2
A
A= $ENV{'CONVERT_PHENO_HTTP_MAX_UPLOAD_BYTES'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | my $token = $ENV{CONVERT_PHENO_API_TOKEN} || die "Set CONVERT_PHENO_API_TOKEN before starting the API\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'CONVERT_PHENO_API_TOKEN'} || die("Set CONVERT_PHENO_API_TOKEN before starting the API\n")
MC/DC0%0/1
$ENV{'CONVERT_PHENO_API_TOKEN'} || die("Set CONVERT_PHENO_API_TOKEN before starting the API\n")
$ENV{'CONVERT_PHENO_API_TOKEN'}
Truth table50%1/2
A
A= $ENV{'CONVERT_PHENO_API_TOKEN'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | die "API token must contain at least 32 characters\n" if length($token) < 32; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | my $jobs = Convert::Pheno::HTTP::Jobs->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | root => $ENV{CONVERT_PHENO_STATE_DIR} || catdir($ENV{HOME} || $ENV{LOCALAPPDATA} || '.', '.convert-pheno', 'runs'), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition12%1/8
$ENV{'CONVERT_PHENO_STATE_DIR'} || catdir($ENV{'HOME'} || $ENV{'LOCALAPPDATA'} || '.', '.convert-pheno', 'runs')
$ENV{'HOME'} || $ENV{'LOCALAPPDATA'} || '.'
$ENV{"HOME"} or $ENV{"LOCALAPPDATA"}
MC/DC0%0/2
$ENV{'CONVERT_PHENO_STATE_DIR'} || catdir($ENV{'HOME'} || $ENV{'LOCALAPPDATA'} || '.', '.convert-pheno', 'runs')
$ENV{'CONVERT_PHENO_STATE_DIR'}
catdir($ENV{'HOME'} || $ENV{'LOCALAPPDATA'} || '.', '.convert-pheno', 'runs')
MC/DC0%0/2
$ENV{'HOME'} || $ENV{'LOCALAPPDATA'} || '.'
$ENV{"HOME"}
$ENV{"LOCALAPPDATA"}
Truth table33%1/3
A || B
A= $ENV{'CONVERT_PHENO_STATE_DIR'}B= catdir($ENV{'HOME'} || $ENV{'LOCALAPPDATA'} || '.', '.convert-pheno', 'runs')
Truth table0%0/3
A or B
A= $ENV{"HOME"}B= $ENV{"LOCALAPPDATA"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | worker => catfile($API_DIR, 'worker.pl'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | END { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # Reaping workers must not replace the server or test process exit status. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | local $?; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | $jobs->shutdown if $jobs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 23 | ▶ | hook before_dispatch => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=35.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 23 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 23 | ▶ | my $host = $c->req->url->to_abs->host || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->req->url->to_abs->host || ''
MC/DC0%0/1
$c->req->url->to_abs->host || ''
$c->req->url->to_abs->host
Truth table50%1/2
A
A= $c->req->url->to_abs->host
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 23 | ▶ | my %hosts = map { $_ => 1 } split /,/, ($ENV{CONVERT_PHENO_API_HOSTS} || '127.0.0.1,localhost'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'CONVERT_PHENO_API_HOSTS'} || '127.0.0.1,localhost'
MC/DC0%0/1
$ENV{'CONVERT_PHENO_API_HOSTS'} || '127.0.0.1,localhost'
$ENV{'CONVERT_PHENO_API_HOSTS'}
Truth table50%1/2
A
A= $ENV{'CONVERT_PHENO_API_HOSTS'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 23 | ▶ | unless ($hosts{$host}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $c->app->log->warn("Rejected service host <$host>"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | return $c->render(status=>403,json=>{ok=>false,error=>{message=>'Unrecognized service host'}}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 23 | my $origin = $c->req->headers->origin; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 23 | ▶ | if (defined $origin) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my %origins = map { $_ => 1 } split /,/, ($ENV{CONVERT_PHENO_API_ORIGINS} || 'tauri://localhost,http://tauri.localhost,https://tauri.localhost'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'CONVERT_PHENO_API_ORIGINS'} || 'tauri://localhost,http://tauri.localhost,https://tauri.localhost'
MC/DC0%0/1
$ENV{'CONVERT_PHENO_API_ORIGINS'} || 'tauri://localhost,http://tauri.localhost,https://tauri.localhost'
$ENV{'CONVERT_PHENO_API_ORIGINS'}
Truth table0%0/2
A
A= $ENV{'CONVERT_PHENO_API_ORIGINS'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | unless ($origins{$origin}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $c->app->log->warn("Rejected application origin <$origin>"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return $c->render(status=>403,json=>{ok=>false,error=>{message=>'Unrecognized application origin'}}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $c->res->headers->header('Access-Control-Allow-Origin' => $origin); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $c->res->headers->header('Vary' => 'Origin'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $c->res->headers->header('Access-Control-Allow-Headers' => 'Authorization, Content-Type'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $c->res->headers->header('Access-Control-Allow-Methods' => 'GET, POST, OPTIONS'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return $c->render(status=>204,text=>'') if $c->req->method eq 'OPTIONS'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 23 | ▶ | return $c->render(status=>401,json=>{ok=>false,error=>{message=>'API authentication required'}}) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$c->req->headers->authorization || ''
MC/DC0%0/1
$c->req->headers->authorization || ''
$c->req->headers->authorization
Truth table50%1/2
A
A= $c->req->headers->authorization
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | unless secure_compare($c->req->headers->authorization || '', "Bearer $token"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | my %EXAMPLE_FIXTURE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | beacon => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | file => catfile( $API_DIR, '..', '..', 't', 'bff2pxf', 'in', 'individuals.json' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | filename => 'beacon-individuals-example.json', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | pxf => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | file => catfile( $API_DIR, '..', '..', 't', 'pxf2bff', 'in', 'pxf.json' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | filename => 'phenopacket-example.json', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | fhir => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | file => catfile( $API_DIR, '..', '..', 't', 'fhir2bff', 'in', 'patient-bundle.json' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | filename => 'fhir-bundle-example.json', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | openehr => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | file => catfile( $API_DIR, '..', '..', 't', 'openehr2bff', 'in', 'gecco_personendaten_patient.json' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | filename => 'openehr-patient-example.json', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | omop => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | file => catfile( $API_DIR, '..', '..', 't', 'fixtures', 'http-omop-request.json' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | filename => 'omop-tables-example.json', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | unwrap => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 3 | my $TEST_DIR = catdir( $API_DIR, '..', '..', 't' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | my %EXAMPLE_FILE_FIXTURE = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | cbioportal => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | { role => 'source', directory => catdir( $TEST_DIR, 'cbioportal2bff', 'in', 'acyc_mgh_2016' ), filename => 'acyc_mgh_2016.zip' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | { role => 'mapping', file => catfile( $TEST_DIR, 'cbioportal2bff', 'in', 'cbioportal_mapping.yaml' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 'cdisc-odm' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | { role => 'source', file => catfile( $TEST_DIR, 'cdiscodm2bff', 'in', 'cdisc_odm_data.xml' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | { role => 'dictionary', file => catfile( $TEST_DIR, 'redcap2bff', 'in', 'redcap_dictionary.csv' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | { role => 'mapping', file => catfile( $TEST_DIR, 'redcap2bff', 'in', 'redcap_mapping.yaml' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | csv => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | options => { separator => ',' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | { role => 'source', file => catfile( $TEST_DIR, 'csv2bff', 'in', 'csv_data.csv' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | { role => 'mapping', file => catfile( $TEST_DIR, 'csv2bff', 'in', 'csv_mapping.yaml' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | fhir => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | json_default => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | { role => 'source', file => catfile( $TEST_DIR, 'fhir2bff', 'in', 'patient-bundle.json' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 'dataset-json' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 30 | ( map { +{ role => 'source', file => $_ } } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | sort glob catfile( $TEST_DIR, 'datasetjson2bff', 'in', '*.json' ) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | { role => 'mapping', file => catfile( $TEST_DIR, 'datasetjson2bff', 'in', 'sdtm_terminology.yaml' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 'dataset-xml' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 12 | ( map { +{ role => 'source', file => catfile( $TEST_DIR, 'datasetxml2bff', 'in', "$_.xml" ) } } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | qw(dm mh lb ts) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | { role => 'define', file => catfile( $TEST_DIR, 'datasetxml2bff', 'in', 'define.xml' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | i2b2 => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | { role => 'source', directory => catdir( $TEST_DIR, 'i2b22bff', 'in' ), filename => 'i2b2-tables.zip' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | omop => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | files => [ map { +{ role => 'source', file => catfile( $TEST_DIR, 'omop2bff', 'in', $_ ) } } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | qw(CONCEPT.csv DRUG_EXPOSURE.csv PERSON.csv) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | openehr => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | json_default => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | { role => 'source', file => catfile( $TEST_DIR, 'openehr2bff', 'in', 'gecco_personendaten_patient.json' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | pxf => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | json_default => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | { role => 'source', file => catfile( $TEST_DIR, 'pxf2bff', 'in', 'pxf.json' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | redcap => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | { role => 'source', file => catfile( $TEST_DIR, 'redcap2bff', 'in', 'redcap_data.csv' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { role => 'dictionary', file => catfile( $TEST_DIR, 'redcap2bff', 'in', 'redcap_dictionary.csv' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | { role => 'mapping', file => catfile( $TEST_DIR, 'redcap2bff', 'in', 'redcap_mapping.yaml' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | pcornet => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { role => 'source', directory => catdir( $TEST_DIR, 'pcornet2bff', 'in' ), filename => 'pcornet-tables.zip' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | sentinel => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | files => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | { role => 'source', directory => catdir( $TEST_DIR, 'sentinel2bff', 'in' ), filename => 'sentinel-tables.zip' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | ▶ | sub zip_fixture_directory { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
zip_fixture_directory: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | my ($directory) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | find( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | no_chdir => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 36 | ▶ | wanted => sub { push @files, $File::Find::name if -f $File::Find::name }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 4 | $directory, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | my $content = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | my $zip; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | for my $file ( sort @files ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 31 | my $name = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 31 | $name =~ s{^\Q$directory\E[\\/]*}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 31 | $name =~ tr{\\}{/}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 31 | ▶ | if ($zip) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 27 | ▶ | $zip->newStream( Name => $name ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | or die "Cannot add <$name> to example ZIP: $ZipError"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 4 | ▶ | $zip = IO::Compress::Zip->new( \$content, Name => $name ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | or die "Cannot create example ZIP: $ZipError"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 31 | $zip->print( Mojo::File::path($file)->slurp ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 4 | ▶ | $zip->close if $zip; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 4 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 29 | ▶ | sub encoded_example_file { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encoded_example_file: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 29 | my ($definition) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | my $filename = $definition->{filename} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 29 | ▶ | || Mojo::File::path( $definition->{file} )->basename; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$definition->{'filename'} || Mojo::File::path($definition->{'file'})->basename
MC/DC0%0/2
$definition->{'filename'} || Mojo::File::path($definition->{'file'})->basename
$definition->{'filename'}
Mojo::File::path($definition->{'file'})->basename
Truth table66%2/3
A || B
A= $definition->{'filename'}B= Mojo::File::path($definition->{'file'})->basename
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | my $content = $definition->{directory} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | ? zip_fixture_directory( $definition->{directory} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 29 | ▶ | : Mojo::File::path( $definition->{file} )->slurp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | role => $definition->{role}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 29 | filename => $filename, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | encoding => 'base64', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | content => encode_base64( $content, q{} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | ▶ | sub render_error { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_error: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | my ( $c, $status, $code, $message, $conversion ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | my $body = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | ok => false, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | error => { code => $code, message => $message }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | ▶ | $body->{meta} = { conversion => $conversion } if defined $conversion; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 | return $c->render( json => $body, status => $status ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | sub render_service_call { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_service_call: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | my ( $c, $conversion, $code ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | my $result = eval { $code->() }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ( is_service_error($error) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | return render_error( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | $c, $error->status, $error->code, $error->message, $conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | return render_error( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | $c, 500, 'infrastructure_error', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 'The local conversion service failed unexpectedly', $conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | return $c->render( json => $result ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | get '/api/health' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | return render_service_call( $c, undef, sub { health() } ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | ▶ | get '/api/conversions' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | ▶ | return render_service_call( $c, undef, sub { catalog() } ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | get '/api/ontology/omop/:concept' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | return render_service_call($c, undef, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | return {ok => Mojo::JSON->true, data => lookup_omop_concept($c->param('concept'))}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 4 | ▶ | sub job_call { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
job_call: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | my ($c,$callback,$status)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | my $result=eval {$callback->()}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 4 | ▶ | if ($@) { my $message="$@"; $message =~ s/\s+at \S+ line \d+.*//s; return render_error($c,422,'invalid_request',$message) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | ▶ | return $c->render(status=>$status || 200,json=>{ok=>Mojo::JSON->true,data=>$result}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$status || 200
MC/DC0%0/1
$status || 200
$status
Truth table50%1/2
A
A= $status
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | post '/api/shutdown' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $local = $ENV{CONVERT_PHENO_LOCAL_TOKEN}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | return render_error($c,403,'local_access_denied','Native shutdown is not authorized') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$local and secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
$c->req->headers->header('X-Convert-Pheno-Local') || ''
MC/DC0%0/2
$local and secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
$local
secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
MC/DC0%0/1
$c->req->headers->header('X-Convert-Pheno-Local') || ''
$c->req->headers->header('X-Convert-Pheno-Local')
Truth table0%0/3
A and B
A= $localB= secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
Truth table0%0/2
A
A= $c->req->headers->header('X-Convert-Pheno-Local')
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | unless $local && secure_compare($c->req->headers->header('X-Convert-Pheno-Local') || '',$local); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $jobs->shutdown; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $c->render(json => {ok => Mojo::JSON->true}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | Mojo::IOLoop->timer(0.2 => sub { Mojo::IOLoop->stop }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | post '/api/inputs/local' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $c=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $local=$ENV{CONVERT_PHENO_LOCAL_TOKEN}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | return render_error($c,403,'local_access_denied','Native file selection is not authorized') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$local and secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
$c->req->headers->header('X-Convert-Pheno-Local') || ''
MC/DC0%0/2
$local and secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
$local
secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
MC/DC0%0/1
$c->req->headers->header('X-Convert-Pheno-Local') || ''
$c->req->headers->header('X-Convert-Pheno-Local')
Truth table0%0/3
A and B
A= $localB= secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
Truth table0%0/2
A
A= $c->req->headers->header('X-Convert-Pheno-Local')
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | unless $local && secure_compare($c->req->headers->header('X-Convert-Pheno-Local') || '',$local); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | job_call($c,sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $body=$c->req->json; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | die "Provide selected paths\n" unless ref($body) eq 'HASH' && ref($body->{paths}) eq 'ARRAY' && @{$body->{paths}} <=128; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $body eq "HASH" and ref $body->{"paths"} eq "ARRAY" and @{$body->{"paths"};} <= 128
ref $body eq "HASH" and ref $body->{"paths"} eq "ARRAY"
MC/DC0%0/3
ref $body eq "HASH" and ref $body->{"paths"} eq "ARRAY" and @{$body->{"paths"};} <= 128
ref $body eq "HASH"
ref $body->{"paths"} eq "ARRAY"
@{$body->{"paths"};} <= 128
Truth table0%0/4
A and B and C
A= ref $body eq "HASH"B= ref $body->{"paths"} eq "ARRAY"C= @{$body->{"paths"};} <= 128
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return [map {$jobs->register_file($_)} @{$body->{paths}}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | },201); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | post '/api/inputs' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $c=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | job_call($c,sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | my $uploads=$c->req->uploads || []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c->req->uploads || []
MC/DC0%0/1
$c->req->uploads || []
$c->req->uploads
Truth table0%0/2
A
A= $c->req->uploads
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | die "Provide at least one file\n" unless @$uploads && @$uploads<=128; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$uploads and @$uploads <= 128
MC/DC0%0/2
@$uploads and @$uploads <= 128
@$uploads
@$uploads <= 128
Truth table0%0/3
A and B
A= @$uploadsB= @$uploads <= 128
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $total=0; $total+=$_->size for @$uploads; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | die "Uploaded files exceed the request limit\n" if $total>$MAX_UPLOAD_BYTES; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $folder=tempdir('uploads-XXXXXX',DIR=>$jobs->{root},CLEANUP=>0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | for my $upload (@$uploads) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | my $name=$upload->filename || 'input'; $name =~ s{.*[\\/]}{}; $name =~ s{[^A-Za-z0-9._-]}{_}g; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$upload->filename || 'input'
MC/DC0%0/1
$upload->filename || 'input'
$upload->filename
Truth table0%0/2
A
A= $upload->filename
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | $name='input' if $name eq '.' || $name eq '..'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name eq "." or $name eq ".."
MC/DC0%0/2
$name eq "." or $name eq ".."
$name eq "."
$name eq ".."
Truth table0%0/3
A or B
A= $name eq "."B= $name eq ".."
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $file=catfile($folder,sprintf('%03d-',scalar @result).$name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $upload->move_to($file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | push @result,$jobs->register_file($file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | return \@result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | },201); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | get '/api/jobs' => sub { my $c=shift; job_call($c,sub {$jobs->list}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | get '/api/jobs/settings' => sub { my $c=shift; job_call($c,sub {$jobs->settings}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | post '/api/jobs/settings' => sub { my $c=shift; job_call($c,sub {$jobs->update_settings($c->req->json)}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | post '/api/jobs/cancel-pending' => sub { my $c=shift; job_call($c,sub {$jobs->cancel_pending}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | get '/api/inputs/:id/preview' => sub {my $c=shift; job_call($c,sub {$jobs->input_preview($c->param('id'))})}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | post '/api/mappings' => sub {my $c=shift; job_call($c,sub {$jobs->save_mapping(($c->req->json || {})->{text})},201)}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=4.6
Subroutine
__ANON__: not called CC=2 SCAR=14.6
Condition0%0/2
$c->req->json || {}
MC/DC0%0/1
$c->req->json || {}
$c->req->json
Truth table0%0/2
A
A= $c->req->json
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 3 | ▶ | post '/api/projects/local/:operation' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 3 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 3 | my $local = $ENV{CONVERT_PHENO_LOCAL_TOKEN}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 3 | ▶ | return render_error($c,403,'local_access_denied','Native project access is not authorized') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$local and secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
$c->req->headers->header('X-Convert-Pheno-Local') || ''
MC/DC50%1/2
$local and secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
$local
secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
MC/DC100%1/1
$c->req->headers->header('X-Convert-Pheno-Local') || ''
$c->req->headers->header('X-Convert-Pheno-Local')
Truth table66%2/3
A and B
A= $localB= secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
Truth table100%2/2
A
A= $c->req->headers->header('X-Convert-Pheno-Local')
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | unless $local && secure_compare($c->req->headers->header('X-Convert-Pheno-Local') || '', $local); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | job_call($c, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | require Convert::Pheno::HTTP::Projects; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1 | ▶ | my $body = $c->req->json || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->req->json || {}
MC/DC0%0/1
$c->req->json || {}
$c->req->json
Truth table50%1/2
A
A= $c->req->json
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | ▶ | my $file = $body->{handle} ? $jobs->resolve_grant($body->{handle}) : $body->{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | return Convert::Pheno::HTTP::Projects::save($jobs, $file, $body->{data}) if $c->param('operation') eq 'save'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | ▶ | return Convert::Pheno::HTTP::Projects::open($jobs, $file) if $c->param('operation') eq 'open'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | die "Unknown project operation\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | ▶ | get '/api/resources' => sub {my $c=shift; job_call($c,sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | my $manifest=Convert::Pheno::DB::Bundle::bundle_manifest($Convert::Pheno::share_dir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 6 | return [map {my $id=$_; my $entry=$manifest->{databases}{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 6 | ▶ | my $file=$id eq 'ohdsi' && $ENV{CONVERT_PHENO_OHDSI_DB_DIR} ? catfile($ENV{CONVERT_PHENO_OHDSI_DB_DIR},'ohdsi.db') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$id eq "ohdsi" and $ENV{"CONVERT_PHENO_OHDSI_DB_DIR"}
MC/DC50%1/2
$id eq "ohdsi" and $ENV{"CONVERT_PHENO_OHDSI_DB_DIR"}
$id eq "ohdsi"
$ENV{"CONVERT_PHENO_OHDSI_DB_DIR"}
Truth table66%2/3
A and B
A= $id eq "ohdsi"B= $ENV{"CONVERT_PHENO_OHDSI_DB_DIR"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | : Convert::Pheno::DB::Bundle::bundled_database_path($Convert::Pheno::share_dir,$id); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 6 | ▶ | +{id=>$id,%$entry,installed=>-f $file ? Mojo::JSON->true : false}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | } sort keys %{$manifest->{databases}}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | })}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | ▶ | post '/api/resources/local-directory' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 3 | my $c=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 3 | my $local=$ENV{CONVERT_PHENO_LOCAL_TOKEN}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 3 | ▶ | return render_error($c,403,'local_access_denied','Native resource selection is not authorized') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$local and secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
$c->req->headers->header('X-Convert-Pheno-Local') || ''
MC/DC50%1/2
$local and secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
$local
secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
MC/DC100%1/1
$c->req->headers->header('X-Convert-Pheno-Local') || ''
$c->req->headers->header('X-Convert-Pheno-Local')
Truth table66%2/3
A and B
A= $localB= secure_compare($c->req->headers->header("X-Convert-Pheno-Local") || "", $local)
Truth table100%2/2
A
A= $c->req->headers->header('X-Convert-Pheno-Local')
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | unless $local && secure_compare($c->req->headers->header('X-Convert-Pheno-Local') || '',$local); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | ▶ | job_call($c,sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | die "Wait for active and queued conversions before changing the resource folder\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if grep {$_->{status} =~ /\A(?:queued|running|cancelling)\z/} @{$jobs->list}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | ▶ | my $directory=($c->req->json || {})->{directory}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->req->json || {}
MC/DC0%0/1
$c->req->json || {}
$c->req->json
Truth table50%1/2
A
A= $c->req->json
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | ▶ | die "Select an existing resource folder\n" unless defined $directory && !ref $directory && -d $directory; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $directory and not ref $directory and -d $directory
defined $directory and not ref $directory
MC/DC33%1/3
defined $directory and not ref $directory and -d $directory
defined $directory
not ref $directory
-d $directory
Truth table50%2/4
A and not(B) and C
A= defined $directoryB= not ref $directoryC= -d $directory
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | $ENV{CONVERT_PHENO_OHDSI_DB_DIR}=abs_path($directory); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | return {directory=>$ENV{CONVERT_PHENO_OHDSI_DB_DIR}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | post '/api/jobs' => sub { my $c=shift; job_call($c,sub {$jobs->submit($c->req->json)},202) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | get '/api/jobs/:id' => sub { my $c=shift; job_call($c,sub {$jobs->status($c->param('id'))}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | post '/api/jobs/:id/cancel' => sub { my $c=shift; job_call($c,sub {$jobs->cancel($c->param('id'))}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | del '/api/jobs/:id' => sub { my $c=shift; job_call($c,sub {$jobs->delete_history($c->param('id'))}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | del '/api/jobs' => sub { my $c=shift; job_call($c,sub {$jobs->delete_all(0)}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | post '/api/jobs/delete-all-files' => sub { my $c=shift; job_call($c,sub {$jobs->delete_all(1)}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | del '/api/jobs/:id/files' => sub { my $c=shift; job_call($c,sub {$jobs->delete_files($c->param('id'))}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | get '/api/jobs/:id/outputs/:artifact/preview' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | my $c=shift; job_call($c,sub {$jobs->preview($c->param('id'),$c->param('artifact'))}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | get '/api/jobs/:id/outputs/:artifact/download' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $c=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my ($file,$entry)=eval {$jobs->artifact($c->param('id'),$c->param('artifact'))}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | return render_error($c,404,'output_unavailable','Output is unavailable') if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $c->res->headers->content_type($entry->{mediaType}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $c->res->headers->content_disposition('attachment; filename="'.$entry->{filename}.'"'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | return $c->reply->file("$file"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # The workbench can load only these bundled, synthetic examples. The source | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # name is resolved through the allowlist above and is never treated as a path. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 15 | ▶ | get '/examples/:source' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=15 SCAR=29.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 15 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 15 | my $source = $c->param('source'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 15 | my $package = $EXAMPLE_FILE_FIXTURE{$source}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 15 | my $transport = $c->param('transport'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # Accepted input transports do not imply that every transport has a fixture. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # Desktop callers ask the engine to choose the available example format. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 15 | ▶ | $transport = $EXAMPLE_FIXTURE{$source} ? 'json' : 'multipart' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $transport and $transport eq "auto"
MC/DC0%0/2
defined $transport and $transport eq "auto"
defined $transport
$transport eq "auto"
Truth table33%1/3
A and B
A= defined $transportB= $transport eq "auto"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | if defined($transport) && $transport eq 'auto'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 15 | ▶ | $transport = $package && $package->{json_default} ? 'json' : 'multipart' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
defined $transport and length $transport
$package and $package->{"json_default"}
MC/DC0%0/2
defined $transport and length $transport
defined $transport
length $transport
MC/DC0%0/2
$package and $package->{"json_default"}
$package
$package->{"json_default"}
Truth table33%1/3
A and B
A= defined $transportB= length $transport
Truth table0%0/3
A and B
A= $packageB= $package->{"json_default"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | unless defined $transport && length $transport; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 15 | ▶ | if ( $package && $transport eq 'multipart' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$package and $transport eq "multipart"
MC/DC100%2/2
$package and $transport eq "multipart"
$package
$transport eq "multipart"
Truth table100%3/3
A and B
A= $packageB= $transport eq "multipart"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 9 | my $files = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 9 | [ map { encoded_example_file($_) } @{ $package->{files} } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 9 | ▶ | return render_error( $c, 500, 'infrastructure_error', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 'The bundled example could not be loaded' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | return $c->render( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | json => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | ok => Mojo::JSON->true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | data => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | transport => 'multipart', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | files => $files, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | options => $package->{options} || {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 9 | ▶ | meta => { source => $source, filename => 'synthetic-fixture-package' }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$package->{'options'} || {}
MC/DC100%1/1
$package->{'options'} || {}
$package->{'options'}
Truth table100%2/2
A
A= $package->{'options'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 6 | my $fixture = $EXAMPLE_FIXTURE{$source}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 6 | ▶ | return render_error( $c, 404, 'unknown_example', 'No example is available for this source' ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | unless $fixture; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 6 | my $data = eval { decode_json( Mojo::File::path( $fixture->{file} )->slurp ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 6 | ▶ | return render_error( $c, 500, 'infrastructure_error', 'The bundled example could not be loaded' ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 6 | ▶ | $data = $data->{input}{data} if $fixture->{unwrap}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | return $c->render( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | json => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | ok => Mojo::JSON->true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | meta => { source => $source, filename => $fixture->{filename} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # The desktop frontend is bundled by Tauri. This process serves the API only. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 3 | app->config( hypnotoad => { listen => ['http://*:8080'] } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | app->max_request_size( $MAX_UPLOAD_BYTES + 1024 * 1024 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 3 | ▶ | app->start unless caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | app; | |||||||||||||||||||||||||||||||||||||||||||||||||