| 1 | #!perl | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Web::Machine; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =pod | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =cut | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||
| 13 | package YAPC::NA::2012::Example020::Resource; | ||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Web::Machine::Util qw[ create_header ]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use parent 'Web::Machine::Resource'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 3 | ▶ | sub content_types_provided { [ { 'text/html' => 'to_html' } ] } | ||||||||||||||||||||||||||
|
Subroutine
content_types_provided: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | sub to_html { '<html><body><h1>Hello World</h1></body></html>' } | ||||||||||||||||||||||||||
|
Subroutine
to_html: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 3 | ▶ | sub is_authorized { | ||||||||||||||||||||||||||
|
Subroutine
is_authorized: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 25 | 3 | my ($self, $auth_header) = @_; | |||||||||||||||||||||||||||
| 26 | 3 | ▶ | if ( $auth_header ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | return 1 if $auth_header->username eq 'foo' && $auth_header->password eq 'bar'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$auth_header->username eq "foo" and $auth_header->password eq "bar"
MC/DC50%1/2
$auth_header->username eq "foo" and $auth_header->password eq "bar"
$auth_header->username eq "foo"
$auth_header->password eq "bar"
Truth table66%2/3
A and B
A= $auth_header->username eq "foo"B= $auth_header->password eq "bar"
| |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 2 | return create_header( 'WWWAuthenticate' => [ 'Basic' => ( realm => 'Webmachine' ) ] ); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | Web::Machine->new( resource => 'YAPC::NA::2012::Example020::Resource' )->to_app; | |||||||||||||||||||||||||||