Remove underscores in notifications reference (#2135)
This commit is contained in:
parent
8cacd5e802
commit
e11c189141
|
@ -15,10 +15,13 @@ sub newNotification {
|
||||||
eval { $self->logger->error("Unable to decode JSON file: $err") };
|
eval { $self->logger->error("Unable to decode JSON file: $err") };
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @notifs;
|
my @notifs;
|
||||||
$json = [$json] unless ( ref($json) eq 'ARRAY' );
|
$json = [$json] unless ( ref($json) eq 'ARRAY' );
|
||||||
|
|
||||||
foreach my $notif (@$json) {
|
foreach my $notif (@$json) {
|
||||||
my @data;
|
my @data;
|
||||||
|
$notif->{reference} =~ s/_/-/g; # Remove underscores (#2135)
|
||||||
|
|
||||||
# Mandatory information
|
# Mandatory information
|
||||||
foreach (qw(date uid reference)) {
|
foreach (qw(date uid reference)) {
|
||||||
|
|
|
@ -25,12 +25,15 @@ sub newNotification {
|
||||||
eval { $self->logger->error("Unable to read XML file : $err") };
|
eval { $self->logger->error("Unable to read XML file : $err") };
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @notifs;
|
my @notifs;
|
||||||
my ( $version, $encoding ) = ( $xml->version(), $xml->encoding() );
|
my ( $version, $encoding ) = ( $xml->version(), $xml->encoding() );
|
||||||
|
|
||||||
foreach
|
foreach
|
||||||
my $notif ( $xml->documentElement->getElementsByTagName('notification') )
|
my $notif ( $xml->documentElement->getElementsByTagName('notification') )
|
||||||
{
|
{
|
||||||
my @data = ();
|
my @data = ();
|
||||||
|
$notif->{reference} =~ s/_/-/g; # Remove underscores (#2135)
|
||||||
|
|
||||||
# Mandatory information
|
# Mandatory information
|
||||||
foreach (qw(date uid reference)) {
|
foreach (qw(date uid reference)) {
|
||||||
|
|
|
@ -271,6 +271,8 @@ sub newNotification {
|
||||||
return $self->sendError( $req, undef, 200 );
|
return $self->sendError( $req, undef, 200 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$json->{reference} =~ s/_/-/g; # Remove underscores (#2135)
|
||||||
|
|
||||||
foreach my $r (qw(uid reference xml)) {
|
foreach my $r (qw(uid reference xml)) {
|
||||||
return $self->sendError( $req, "Missing $r", 200 )
|
return $self->sendError( $req, "Missing $r", 200 )
|
||||||
unless ( $json->{$r} );
|
unless ( $json->{$r} );
|
||||||
|
|
|
@ -41,7 +41,7 @@ my $jsonbis = '{
|
||||||
|
|
||||||
my $json2 = q%{
|
my $json2 = q%{
|
||||||
"date": "2016-05-30",
|
"date": "2016-05-30",
|
||||||
"reference": "testref2",
|
"reference": "test_ref2",
|
||||||
"uid": "dwho",
|
"uid": "dwho",
|
||||||
"title": "Test2 title",
|
"title": "Test2 title",
|
||||||
"text": "This is a second test text",
|
"text": "This is a second test text",
|
||||||
|
@ -187,7 +187,7 @@ ok( scalar @{ $json->{result} } == 3, 'Three notifications found' )
|
||||||
or print STDERR Dumper($json);
|
or print STDERR Dumper($json);
|
||||||
|
|
||||||
foreach ( @{ $json->{result} } ) {
|
foreach ( @{ $json->{result} } ) {
|
||||||
ok( $_->{reference} =~ /^testref/, "Reference \'$_->{reference}\' found" )
|
ok( $_->{reference} =~ /^test-?ref/, "Reference \'$_->{reference}\' found" )
|
||||||
or print STDERR Dumper($json);
|
or print STDERR Dumper($json);
|
||||||
ok( $_->{uid} =~ /^(dwho|everyone)$/, "UID \'$_->{uid}\' found" )
|
ok( $_->{uid} =~ /^(dwho|everyone)$/, "UID \'$_->{uid}\' found" )
|
||||||
or print STDERR Dumper($json);
|
or print STDERR Dumper($json);
|
||||||
|
@ -204,7 +204,7 @@ ok( $res->[2]->[0] =~ /"result"\s*:\s*/, 'Result found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( $res->[2]->[0] =~ /"reference":"testref"/, 'First notification found' )
|
ok( $res->[2]->[0] =~ /"reference":"testref"/, 'First notification found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( $res->[2]->[0] =~ /"reference":"testref2"/, 'Second notification found' )
|
ok( $res->[2]->[0] =~ /"reference":"test-ref2"/, 'Second notification found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok(
|
ok(
|
||||||
$res->[2]->[0] =~ /"reference":"testrefall"/,
|
$res->[2]->[0] =~ /"reference":"testrefall"/,
|
||||||
|
@ -236,14 +236,14 @@ count(7);
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
$res = $client->_get(
|
$res = $client->_get(
|
||||||
'/notifications/dwho/testref2',
|
'/notifications/dwho/test-ref2',
|
||||||
type => 'application/json',
|
type => 'application/json',
|
||||||
),
|
),
|
||||||
'List notification with reference "testref2"'
|
'List notification with reference "test-ref2"'
|
||||||
);
|
);
|
||||||
ok( $res->[2]->[0] =~ /"result"\s*:\s*/, 'Result found' )
|
ok( $res->[2]->[0] =~ /"result"\s*:\s*/, 'Result found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( $res->[2]->[0] =~ /"reference"\s*:\s*"testref2"/,
|
ok( $res->[2]->[0] =~ /"reference"\s*:\s*"test-ref2"/,
|
||||||
'Notification reference found' )
|
'Notification reference found' )
|
||||||
or print STDERR Dumper( $res->[2]->[0] );
|
or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( $res->[2]->[0] =~ /"title"\s*:\s*"Test2 title"/,
|
ok( $res->[2]->[0] =~ /"title"\s*:\s*"Test2 title"/,
|
||||||
|
@ -275,7 +275,7 @@ ok(
|
||||||
ok( $res->[2]->[0] =~ /"error"\s*:\s*"Bad request"/, 'Bad method is refused' );
|
ok( $res->[2]->[0] =~ /"error"\s*:\s*"Bad request"/, 'Bad method is refused' );
|
||||||
count(2);
|
count(2);
|
||||||
|
|
||||||
foreach (qw(testrefall testref2)) {
|
foreach (qw(testrefall test-ref2)) {
|
||||||
my $user = $_ eq 'testrefall' ? 'everyone' : 'dwho';
|
my $user = $_ eq 'testrefall' ? 'everyone' : 'dwho';
|
||||||
ok(
|
ok(
|
||||||
$res = $client->_delete(
|
$res = $client->_delete(
|
||||||
|
|
|
@ -9,7 +9,7 @@ BEGIN {
|
||||||
require 't/test-lib.pm';
|
require 't/test-lib.pm';
|
||||||
}
|
}
|
||||||
|
|
||||||
my $maintests = 12;
|
my $maintests = 13;
|
||||||
my $client;
|
my $client;
|
||||||
|
|
||||||
# Redefine LWP methods for tests
|
# Redefine LWP methods for tests
|
||||||
|
@ -63,7 +63,7 @@ my $combined = '<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<text>This is a test text</text>
|
<text>This is a test text</text>
|
||||||
<check>I agree</check>
|
<check>I agree</check>
|
||||||
</notification>
|
</notification>
|
||||||
<notification uid="rtyler" date="2016-05-31" reference="ABC2">
|
<notification uid="rtyler" date="2016-05-31" reference="AB_C_2">
|
||||||
<title>Test title</title>
|
<title>Test title</title>
|
||||||
<subtitle>Test subtitle</subtitle>
|
<subtitle>Test subtitle</subtitle>
|
||||||
<text>This is a test text</text>
|
<text>This is a test text</text>
|
||||||
|
@ -202,6 +202,11 @@ SKIP: {
|
||||||
expectOK($res);
|
expectOK($res);
|
||||||
$id = expectCookie($res);
|
$id = expectCookie($res);
|
||||||
expectForm( $res, undef, '/notifback', 'reference1x1' );
|
expectForm( $res, undef, '/notifback', 'reference1x1' );
|
||||||
|
ok(
|
||||||
|
$res->[2]->[0] =~
|
||||||
|
m%<input type="hidden" name="reference1x1" value="AB-C-2">%,
|
||||||
|
'Reference found'
|
||||||
|
) or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok(
|
ok(
|
||||||
$res->[2]->[0] =~
|
$res->[2]->[0] =~
|
||||||
m%<input type="checkbox" name="check1x1x1" id="check1x1x1" value="accepted">I agree</label>%,
|
m%<input type="checkbox" name="check1x1x1" id="check1x1x1" value="accepted">I agree</label>%,
|
||||||
|
|
|
@ -20,7 +20,7 @@ SKIP: {
|
||||||
totp2fTTL => 120,
|
totp2fTTL => 120,
|
||||||
sfRemovedMsgRule => '$uid eq "dwho"',
|
sfRemovedMsgRule => '$uid eq "dwho"',
|
||||||
sfRemovedUseNotif => 1,
|
sfRemovedUseNotif => 1,
|
||||||
sfRemovedNotifRef => 'RemoveTOTP',
|
sfRemovedNotifRef => 'Remov_e_TOTP',
|
||||||
portalMainLogo => 'common/logos/logo_llng_old.png',
|
portalMainLogo => 'common/logos/logo_llng_old.png',
|
||||||
notification => 1,
|
notification => 1,
|
||||||
notificationStorage => 'File',
|
notificationStorage => 'File',
|
||||||
|
@ -146,7 +146,7 @@ SKIP: {
|
||||||
expectOK($res);
|
expectOK($res);
|
||||||
ok(
|
ok(
|
||||||
$res->[2]->[0] =~
|
$res->[2]->[0] =~
|
||||||
qr%<input type="hidden" name="reference1x1" value="RemoveTOTP-(\d{10})">%,
|
qr%<input type="hidden" name="reference1x1" value="Remov-e-TOTP-(\d{10})">%,
|
||||||
'Notification reference found'
|
'Notification reference found'
|
||||||
) or print STDERR Dumper( $res->[2]->[0] );
|
) or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( time() + 300 <= $1 && $1 <= time() + 305, 'Right reference found' )
|
ok( time() + 300 <= $1 && $1 <= time() + 305, 'Right reference found' )
|
||||||
|
|
|
@ -24,7 +24,7 @@ SKIP: {
|
||||||
totp2fTTL => 120,
|
totp2fTTL => 120,
|
||||||
sfRemovedMsgRule => '$uid eq "dwho"',
|
sfRemovedMsgRule => '$uid eq "dwho"',
|
||||||
sfRemovedUseNotif => 1,
|
sfRemovedUseNotif => 1,
|
||||||
sfRemovedNotifRef => 'RemoveTOTP',
|
sfRemovedNotifRef => 'Remove_TOTP',
|
||||||
portalMainLogo => 'common/logos/logo_llng_old.png',
|
portalMainLogo => 'common/logos/logo_llng_old.png',
|
||||||
notification => 1,
|
notification => 1,
|
||||||
notificationStorage => 'File',
|
notificationStorage => 'File',
|
||||||
|
@ -150,7 +150,7 @@ SKIP: {
|
||||||
expectOK($res);
|
expectOK($res);
|
||||||
ok(
|
ok(
|
||||||
$res->[2]->[0] =~
|
$res->[2]->[0] =~
|
||||||
qr%<input type="hidden" name="reference1x1" value="RemoveTOTP-(\d{10})">%,
|
qr%<input type="hidden" name="reference1x1" value="Remove-TOTP-(\d{10})">%,
|
||||||
'Notification reference found'
|
'Notification reference found'
|
||||||
) or print STDERR Dumper( $res->[2]->[0] );
|
) or print STDERR Dumper( $res->[2]->[0] );
|
||||||
ok( time() + 300 <= $1 && $1 <= time() + 305, 'Right reference found' )
|
ok( time() + 300 <= $1 && $1 <= time() + 305, 'Right reference found' )
|
||||||
|
|
Loading…
Reference in New Issue
Block a user