Branch Coverage

blib/lib/Plack/Middleware/ProofOfWork.pm
Criterion Covered Total %
branch 34 80 42.5


line true false branch
35 0 4 unless defined $self->difficulty
36 0 4 unless defined $self->cookie_name
37 0 4 unless defined $self->cookie_duration
38 0 4 unless defined $self->bot_verification_level
39 4 0 unless defined $self->bot_dns_timeout
40 4 0 unless defined $self->timestamp_window
43 4 0 unless (defined $self->bot_patterns)
63 4 0 unless (defined $self->js_file)
69 4 0 unless (defined $self->html_file)
80 4 4 if ($self->_needs_proof_of_work($req))
95 4 4 if (defined $pow_cookie)
97 2 2 if $self->_verify_proof_of_work($req, $pow_cookie)
103 2 2 if ($self->_is_bot($req))
115 1 3 if $verification_level == 0
125 2 21 if ($user_agent =~ /\Q$key\E/i)
131 1 2 unless $bot_type
132 2 0 if $verification_level == 1
135 0 0 unless $remote_addr
138 0 0 unless $hostname
139 0 0 unless $hostname =~ /$bot_patterns->{$bot_type}/
140 0 0 if $verification_level == 2
148 0 0 $ip =~ /:/ ? :
149 0 0 unless my $packed = inet_pton($family, $ip)
163 0 0 if ($ip =~ /:/) { }
164 0 0 unless my $packed = inet_pton(10, $ip)
167 0 0 unless my $packed = inet_pton(2, $ip)
176 0 0 if $@ and $@ =~ /timeout/
193 0 0 unless ($err)
196 0 0 $err_ni ? :
207 0 0 if $@ and $@ =~ /timeout/
208 0 0 unless $success
224 0 4 if $@
240 2 2 unless $hash =~ /^$required_zeros/
243 1 1 if ($fraction > 0)
247 0 1 unless $hex_value < $div
278 8 0 if (not $@ and defined $dist_file and -f $dist_file and -r $dist_file)
289 0 0 if -f $path and -r $path
300 0 8 unless (-f $filepath and -r $filepath)
305 0 8 unless open my $fh, "<:encoding(UTF-8)", $filepath
373 0 4 if (my $custom_css = $self->css)