diff --git a/lemonldap-ng-portal/t/40-Notifications-JSON-DBI.t b/lemonldap-ng-portal/t/40-Notifications-JSON-DBI.t index 6aa1d42bc..ba8e40090 100644 --- a/lemonldap-ng-portal/t/40-Notifications-JSON-DBI.t +++ b/lemonldap-ng-portal/t/40-Notifications-JSON-DBI.t @@ -1,9 +1,10 @@ use Test::More; use strict; use IO::String; +use JSON qw(from_json); my $res; -my $maintests = 10; +my $maintests = 17; require 't/test-lib.pm'; my $file = tempdb(); @@ -105,7 +106,8 @@ q{INSERT INTO notifications VALUES ('rtyler','testref2','2050-05-30 00:00:00',?, notificationStorageOptions => { dbiChain => "dbi:SQLite:dbname=$file", }, - oldNotifFormat => 0, + oldNotifFormat => 0, + notificationsExplorer => 1, } } ); @@ -179,7 +181,7 @@ q{INSERT INTO notifications VALUES ('rtyler','testref2','2050-05-30 00:00:00',?, !defined( $cookies->{lemonldappdata} ), " Make sure no pdata is returned" ); - $client->logout($id); + $id = expectCookie($res); # Verify that notification was tagged as 'done' my $sth = @@ -189,6 +191,32 @@ q{INSERT INTO notifications VALUES ('rtyler','testref2','2050-05-30 00:00:00',?, while ( $sth->fetchrow_hashref ) { $i++ } ok( $i == 2, 'Notification was deleted' ); + # GET notifications explorer + ok( + $res = $client->_get( + '/mynotifications', cookie => "lemonldap=$id", + ), + 'Notifications explorer query' + ); + + my $json; + ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' ) + or print STDERR "$@\n" . Dumper($res); + ok( $json->{result} == 2, ' Result is 2' ) + or explain( $json, "result => 2" ); + ok( $json->{MSG} == 'myNotifications', ' MSG is myNotifications' ) + or explain( $json, "result => 2" ); + ok( $json->{NOTIFICATIONS}->[0]->{reference} =~ /testref2?/, + ' Notification 1 found' ) + or explain( $json, "Notification 1" ); + ok( $json->{NOTIFICATIONS}->[0]->{reference} =~ /testref2?/, + ' Notification 2 found' ) + or explain( $json, "Notification 2" ); + ok( $json->{NOTIFICATIONS}->[0]->{epoch} =~ /\d{10}/, ' epoch found' ) + or explain( $json, "Epoch found" ); + + $client->logout($id); + # Try to authenticate # ------------------- ok( diff --git a/lemonldap-ng-portal/t/40-Notifications-XML-DBI.t b/lemonldap-ng-portal/t/40-Notifications-XML-DBI.t index e7897e3d3..696a931ac 100644 --- a/lemonldap-ng-portal/t/40-Notifications-XML-DBI.t +++ b/lemonldap-ng-portal/t/40-Notifications-XML-DBI.t @@ -150,6 +150,7 @@ qq{INSERT INTO notifications VALUES ('rtyler','testref2','2050-05-30 00:00:00',' !defined( $cookies->{lemonldappdata} ), " Make sure no pdata is returned" ); + $id = expectCookie($res); $client->logout($id); # Verify that notification was tagged as 'done' diff --git a/lemonldap-ng-portal/t/40-Notifications-explorer-JSON-File.t b/lemonldap-ng-portal/t/40-Notifications-explorer-JSON-File.t index e691d79cb..f3412e39e 100644 --- a/lemonldap-ng-portal/t/40-Notifications-explorer-JSON-File.t +++ b/lemonldap-ng-portal/t/40-Notifications-explorer-JSON-File.t @@ -29,9 +29,10 @@ my $client = LLNG::Manager::Test->new( { notification => 1, notificationStorage => 'File', notificationStorageOptions => { dirName => $main::tmpDir }, + portalMainLogo => 'common/logos/logo_llng_old.png', oldNotifFormat => 0, notificationsExplorer => 1, - portalMainLogo => 'common/logos/logo_llng_old.png', } + } } ); @@ -82,8 +83,7 @@ expectForm( $res, undef, '/notifback', 'reference1x1' ); # Verify that cookie is ciphered (session unvalid) ok( $res = $client->_get( - '/', - cookie => "lemonldap=$id", + '/', cookie => "lemonldap=$id", ), 'Test cookie received' ); diff --git a/lemonldap-ng-portal/t/40-Notifications-explorer-XML-File.t b/lemonldap-ng-portal/t/40-Notifications-explorer-XML-File.t index fd16cf610..14e4cdf68 100644 --- a/lemonldap-ng-portal/t/40-Notifications-explorer-XML-File.t +++ b/lemonldap-ng-portal/t/40-Notifications-explorer-XML-File.t @@ -7,7 +7,7 @@ require 't/test-lib.pm'; my $res; my $file = "$main::tmpDir/20160530_dwho_dGVzdHJlZg==.xml"; -my $maintests = 34; +my $maintests = 36; SKIP: { eval { require XML::LibXML; require XML::LibXSLT; }; @@ -23,6 +23,12 @@ SKIP: { This is a test text Accept test Accept test2 + +Test title +Test subtitle +This is a test text +Accept test +Accept test2 '; close F; @@ -33,9 +39,9 @@ SKIP: { notification => 1, notificationStorage => 'File', notificationStorageOptions => { dirName => $main::tmpDir }, + portalMainLogo => 'common/logos/logo_llng_old.png', oldNotifFormat => 1, notificationsExplorer => 1, - portalMainLogo => 'common/logos/logo_llng_old.png', } } ); @@ -81,13 +87,12 @@ SKIP: { count(1); expectOK($res); $id = expectCookie($res); - expectForm( $res, undef, '/notifback', 'reference1x1' ); + expectForm( $res, undef, '/notifback', 'reference1x1', 'reference1x2' ); # Verify that cookie is ciphered (session unvalid) ok( $res = $client->_get( - '/', - cookie => "lemonldap=$id", + '/', cookie => "lemonldap=$id", ), 'Test cookie received' ); @@ -95,7 +100,8 @@ SKIP: { expectReject($res); # Try to validate notification with accepting all checkboxes - my $str = 'reference1x1=testref&check1x1x1=accepted&check1x1x2=accepted'; + my $str = +'reference1x1=testref&check1x1x1=accepted&check1x1x2=accepted&reference1x2=testref2&check1x2x1=accepted&check1x2x2=accepted'; ok( $res = $client->_post( '/notifback', @@ -140,9 +146,10 @@ SKIP: { ok( $res->[2]->[0] =~ m%%, ' Language icons found' ) or print STDERR Dumper( $res->[2]->[0] ); - ok( $res->[2]->[0] =~ m%%, - ' trspan="myNotification" found' ) - or print STDERR Dumper( $res->[2]->[0] ); + ok( + $res->[2]->[0] =~ m%%, + ' trspan="myNotifications" found' + ) or print STDERR Dumper( $res->[2]->[0] ); ok( $res->[2]->[0] =~ m%Date%, ' trspan="date" found' ) or print STDERR Dumper( $res->[2]->[0] ); @@ -159,8 +166,16 @@ SKIP: { ok( $res->[2]->[0] =~ m%testref%, ' testref found' ) or print STDERR Dumper( $res->[2]->[0] ); + ok( $res->[2]->[0] =~ m%testref2%, + ' testref2 found' ) + or print STDERR Dumper( $res->[2]->[0] ); ok( $res->[2]->[0] =~ m%class="fa fa-eye">%, ' fa-eye found' ) or print STDERR Dumper( $res->[2]->[0] ); + ok( + $res->[2]->[0] =~ + m%%, + ' fa-eye 2 found' + ) or print STDERR Dumper( $res->[2]->[0] ); ok( $res->[2]->[0] =~ m%%, ' Notififcation container found' ) or print STDERR Dumper( $res->[2]->[0] );