From 22704130b2b9f1054cf71d119f7d7b6c3d788078 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Wed, 25 Jan 2017 12:02:27 +0000 Subject: [PATCH] Start token test (#1140) --- lemonldap-ng-portal/MANIFEST | 2 ++ lemonldap-ng-portal/t/42-Token.t | 25 +++++++++++++++++++++++++ lemonldap-ng-portal/t/test-lib.pm | 3 ++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 lemonldap-ng-portal/t/42-Token.t diff --git a/lemonldap-ng-portal/MANIFEST b/lemonldap-ng-portal/MANIFEST index 483af8e80..e547e84c7 100644 --- a/lemonldap-ng-portal/MANIFEST +++ b/lemonldap-ng-portal/MANIFEST @@ -41,6 +41,7 @@ lib/Lemonldap/NG/Portal/Issuer/Get.pm lib/Lemonldap/NG/Portal/Issuer/OpenID.pm lib/Lemonldap/NG/Portal/Issuer/OpenIDConnect.pm lib/Lemonldap/NG/Portal/Issuer/SAML.pm +lib/Lemonldap/NG/Portal/Lib/Captcha.pm lib/Lemonldap/NG/Portal/Lib/CAS.pm lib/Lemonldap/NG/Portal/Lib/Choice.pm lib/Lemonldap/NG/Portal/Lib/DBI.pm @@ -362,6 +363,7 @@ t/35-REST-sessions-with-REST-server.t t/35-SOAP-sessions-with-SOAP-server.t t/40-Notifications-DBI.t t/41-Register-Demo.t +t/42-Token.t t/50-IssuerGet.t t/60-status.t t/90-translations.t diff --git a/lemonldap-ng-portal/t/42-Token.t b/lemonldap-ng-portal/t/42-Token.t new file mode 100644 index 000000000..2876c0b2d --- /dev/null +++ b/lemonldap-ng-portal/t/42-Token.t @@ -0,0 +1,25 @@ +use Test::More; +use strict; +use IO::String; + +require 't/test-lib.pm'; + +my $res; + +my $client = LLNG::Manager::Test->new( + { ini => { logLevel => 'debug', useSafeJail => 1, requireToken => 1, } } ); + +# Test normal first access +# ------------------------ +ok( $res = $client->_get('/'), 'Unauth JSON request' ); +count(1); +expectReject($res); + +ok( $res = $client->_get( '/', accept => 'text/html' ), 'Unauth request' ); +count(1); + +my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' ); + +clean_sessions(); + +done_testing( count() ); diff --git a/lemonldap-ng-portal/t/test-lib.pm b/lemonldap-ng-portal/t/test-lib.pm index fb3e4040e..798af9de4 100644 --- a/lemonldap-ng-portal/t/test-lib.pm +++ b/lemonldap-ng-portal/t/test-lib.pm @@ -110,7 +110,8 @@ m@[2]->[0] =~ m#[2]->[0] =~ + m#]+?value="([^"]*?)"#gs ); my $query = join( '&', map { "$_=" . uri_escape( uri_unescape( $fields{$_} ) ) } keys(%fields) );