diff --git a/lemonldap-ng-portal/t/01-AuthDemo.t b/lemonldap-ng-portal/t/01-AuthDemo.t index 95d38f457..2c2e84f6e 100644 --- a/lemonldap-ng-portal/t/01-AuthDemo.t +++ b/lemonldap-ng-portal/t/01-AuthDemo.t @@ -1,6 +1,7 @@ use Test::More; use strict; use IO::String; +use MIME::Base64; require 't/test-lib.pm'; @@ -15,6 +16,38 @@ ok( $res = $client->_get('/'), 'Unauth JSON request' ); count(1); expectReject($res); +# Test "first access" with an unprotected url +ok( + $res = $client->_get( + '/', + query => 'url=' . encode_base64( "http://test.example.fr/", '' ), + accept => 'text/html' + ), + 'Get Menu' +); +ok( $res->[2]->[0] =~ /<\/span><\/div>/, + 'Rejected with PE_BADURL' ) + or print STDERR Dumper( $res->[2]->[0] ); +ok( $res->[2]->[0] =~ m%%, ' Language icons found' ) + or print STDERR Dumper( $res->[2]->[0] ); +count(3); + +# Test "first access" with a wildcard-protected url +ok( + $res = $client->_get( + '/', + query => 'url=' . encode_base64( "http://test.example.llng/", '' ), + accept => 'text/html' + ), + 'Get Menu' +); +ok( $res->[2]->[0] =~ /<\/span><\/div>/, + 'Rejected with PE_FIRSTACCESS' ) + or print STDERR Dumper( $res->[2]->[0] ); +ok( $res->[2]->[0] =~ m%%, ' Language icons found' ) + or print STDERR Dumper( $res->[2]->[0] ); +count(3); + # Test "first access" with good url ok( $res = @@ -40,15 +73,13 @@ ok( ), 'Auth query' ); -count(1); ok( $res->[2]->[0] =~ /<\/span><\/div>/, 'jdoe rejected with PE_BADCREDENTIALS' ) or print STDERR Dumper( $res->[2]->[0] ); -count(1); ok( $res->[2]->[0] =~ m%Connect%, 'Found connect button' ) or print STDERR Dumper( $res->[2]->[0] ); -count(1); +count(3); # Try to authenticate with bad password # ------------------------------------- diff --git a/lemonldap-ng-portal/t/lmConf-1.json b/lemonldap-ng-portal/t/lmConf-1.json index c7ce76324..a8fb266f8 100644 --- a/lemonldap-ng-portal/t/lmConf-1.json +++ b/lemonldap-ng-portal/t/lmConf-1.json @@ -57,6 +57,9 @@ }, "test.example.org": { "default": "accept" + }, + "*.example.llng": { + "default": "accept" } }, "macros": {