From 5a1a5d853ddc3062221b99db56d0cc037002245e Mon Sep 17 00:00:00 2001 From: Chris Andrews Date: Jan 12 2011 21:04:40 +0000 Subject: Make the live-login test an author-only test. Can be run if a suitably-configured IdP is available. --- diff --git a/testapp/t/003_live_login.t b/testapp/t/003_live_login.t deleted file mode 100644 index 8bf5293..0000000 --- a/testapp/t/003_live_login.t +++ /dev/null @@ -1,54 +0,0 @@ -use Test::More; -use strict; -use warnings; - -use WWW::Mechanize; - -# the order is important -use Saml2Test; -use Dancer::Test; - -# interact with the IdP live -my $mech = WWW::Mechanize->new; - -## start a login -my $login = dancer_response(GET => '/login'); -ok($login); -ok($login->{status} == 302); -ok($login->{headers}->header('location')); - -## redirected to IdP login form - -$mech->get( $login->{headers}->header('location') ); -my $form = $mech->form_name('Login'); - -## submit login for with test credentials - -my $params = { - IDButton => 'Submit', - IDToken0 => '', - IDToken1 => 'demo', - IDToken2 => 'demodemo', -}; -for my $input ($form->inputs) { - $params->{$input->name} = $input->value; -} - -my $response = $mech->post($form->action, $params); -ok($mech->title eq 'Access rights validated'); - -## post the SAMLResponse form to the app - -$form = $mech->form_number(1); -ok($form); -ok(qr!/consumer-post!, $form->action); - -$params = { - SAMLResponse => $form->param('SAMLResponse'), -}; - -my $post = dancer_response(POST => '/consumer-post', { params => $params }); -is $post->{status}, 200; -ok(qr/User: /, $post->{content}); - -done_testing; diff --git a/testapp/t/author/live_login.t b/testapp/t/author/live_login.t new file mode 100644 index 0000000..8bf5293 --- /dev/null +++ b/testapp/t/author/live_login.t @@ -0,0 +1,54 @@ +use Test::More; +use strict; +use warnings; + +use WWW::Mechanize; + +# the order is important +use Saml2Test; +use Dancer::Test; + +# interact with the IdP live +my $mech = WWW::Mechanize->new; + +## start a login +my $login = dancer_response(GET => '/login'); +ok($login); +ok($login->{status} == 302); +ok($login->{headers}->header('location')); + +## redirected to IdP login form + +$mech->get( $login->{headers}->header('location') ); +my $form = $mech->form_name('Login'); + +## submit login for with test credentials + +my $params = { + IDButton => 'Submit', + IDToken0 => '', + IDToken1 => 'demo', + IDToken2 => 'demodemo', +}; +for my $input ($form->inputs) { + $params->{$input->name} = $input->value; +} + +my $response = $mech->post($form->action, $params); +ok($mech->title eq 'Access rights validated'); + +## post the SAMLResponse form to the app + +$form = $mech->form_number(1); +ok($form); +ok(qr!/consumer-post!, $form->action); + +$params = { + SAMLResponse => $form->param('SAMLResponse'), +}; + +my $post = dancer_response(POST => '/consumer-post', { params => $params }); +is $post->{status}, 200; +ok(qr/User: /, $post->{content}); + +done_testing;