Branch Coverage

blib/lib/Mojolicious/Plugin/OpenAPI/Cors.pm
Criterion Covered Total %
branch 46 56 82.1


line true false branch
24 1 58 if ($config->{'add_preflighted_routes'})
45 1 3 if $self->_takeover_exchange_route($route)
46 0 3 if $match->find($c, {"method", "options", "path", $route_path})
60 2 0 scalar grep({$origin =~ /$_/u;} @$allowed) ? :
68 3 8 unless (defined $c->req->headers->origin)
71 1 0 if $method eq "OPTIONS" and $c->match->endpoint->to->{'openapi.cors_preflighted'}
79 2 6 if $errors
82 3 3 $type eq 'preflighted' ? :
89 4 4 unless $c->req->method eq "OPTIONS"
90 1 3 if $req_h->header("Access-Control-Request-Headers")
91 1 2 if $req_h->header("Access-Control-Request-Method")
94 2 0 if $ct and $PREFLIGHTED_CONTENT_TYPES{$ct}
101 5 3 unless $SIMPLE_METHODS{$c->req->method}
105 3 0 if @names
108 0 0 if $ct and $SIMPLE_CONTENT_TYPES{$ct}
116 3 1 if not ref $errors and $errors =~ m[^/([\w-]+)]u
118 1 3 unless ref $errors
128 3 4 unless ($res_h->access_control_allow_origin)
132 3 4 unless $c->stash("openapi_cors_type") eq "preflighted"
134 3 1 unless ($res_h->header("Access-Control-Allow-Headers"))
139 3 1 unless ($res_h->header("Access-Control-Allow-Methods"))
141 0 3 unless $op_spec
145 3 1 unless ($res_h->header("Access-Control-Max-Age"))
154 0 4 if $defaults->{'controller'}
155 3 1 unless $defaults->{'action'} and $defaults->{'action'} eq "openapi_plugin_cors_exchange"
156 0 1 unless grep {$_ eq "OPTIONS";} @{$route->$methods;}
160 1 2 unless $c->openapi->valid_input
161 1 1 unless $c->req->headers->origin