Commit 9adb875c authored by Christophe Maudoux's avatar Christophe Maudoux

Append 2fregisters unit test

parent eeaa6328
...@@ -4,7 +4,7 @@ use IO::String; ...@@ -4,7 +4,7 @@ use IO::String;
use Data::Dumper; use Data::Dumper;
require 't/test-lib.pm'; require 't/test-lib.pm';
my $maintests = 16; my $maintests = 29;
SKIP: { SKIP: {
eval { require Convert::Base32 }; eval { require Convert::Base32 };
...@@ -130,15 +130,37 @@ SKIP: { ...@@ -130,15 +130,37 @@ SKIP: {
); );
ok( $res->[2]->[0] =~ /2fregistration\.(?:min\.)?js/, 'Found 2f registration js' ); ok( $res->[2]->[0] =~ /2fregistration\.(?:min\.)?js/, 'Found 2f registration js' );
ok( $res->[2]->[0] =~ qr%<a href="/2fregisters/u" class="nodecor">%, 'Found 2fregisters/u link' ) or print STDERR Dumper($res);; ok( $res->[2]->[0] =~ qr%<img src="/static/bootstrap/totp.png" alt="totp2F" title="totp2F" />%, 'Found totp.png' ) or print STDERR Dumper($res->[2]->[0]);
ok( $res->[2]->[0] =~ qr%<a href="/2fregisters/totp" class="nodecor">%, 'Found 2fregisters/totp link' ) or print STDERR Dumper($res);; ok( $res->[2]->[0] =~ qr%<img src="/static/bootstrap/u2f.png" alt="u2F" title="u2F" />%, 'Found u2f.png' ) or print STDERR Dumper($res->[2]->[0]);
ok( $res->[2]->[0] =~ qr%<a href="/2fregisters/u" class="nodecor">%, 'Found 2fregisters/u link' ) or print STDERR Dumper($res->[2]->[0]);
ok( $res->[2]->[0] =~ qr%<a href="/2fregisters/totp" class="nodecor">%, 'Found 2fregisters/totp link' ) or print STDERR Dumper($res->[2]->[0]);
ok ($res->[2]->[0] =~ qr%<td class="align-middle" >TOTP</td><td class="align-middle">(\d{10})</td><td class="data-epoch">\d{10}</td>%, "TOTP epoch $1 found")
or print STDERR Dumper($res->[2]->[0]);
ok ($res->[2]->[0] =~ qr%<td class="align-middle" >TOTP</td><td class="align-middle">(\d{10})</td><td class="data-epoch">\d{10}</td>%, TOTP epoch found) ok(
$res = $client->_post(
or print STDERR "$epoch\n"; '/2fregisters/totp/delete',
my $epoch = $1; IO::String->new("epoch=$1"),
length => 16,
cookie => "lemonldap=$id",
),
'Delete TOTP query'
);
ok(
$res = $client->_get(
'/2fregisters',
cookie => "lemonldap=$id",
accept => 'text/html',
),
'Form 2fregisters'
);
ok( $res->[2]->[0] =~ /2fregistration\.(?:min\.)?js/, 'Found 2f registration js' );
ok( $res->[2]->[0] =~ qr%<a href="/2fregisters/u" class="nodecor">%, 'Found 2fregisters/u link' ) or print STDERR Dumper($res);
ok( $res->[2]->[0] =~ qr%<a href="/2fregisters/totp" class="nodecor">%, 'Found 2fregisters/totp link' ) or print STDERR Dumper($res);
ok ($res->[2]->[0] !~ qr%<td class="align-middle" >TOTP</td><td class="align-middle">(\d{10})</td><td class="data-epoch">\d{10}</td>%, "TOTP deleted")
or print STDERR Dumper($res->[2]->[0]);
$client->logout($id); $client->logout($id);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment