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

Append 2fregisters unit test

parent eeaa6328
......@@ -4,7 +4,7 @@ use IO::String;
use Data::Dumper;
require 't/test-lib.pm';
my $maintests = 16;
my $maintests = 29;
SKIP: {
eval { require Convert::Base32 };
......@@ -130,15 +130,37 @@ SKIP: {
);
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%<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%<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)
or print STDERR "$epoch\n";
my $epoch = $1;
ok(
$res = $client->_post(
'/2fregisters/totp/delete',
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);
}
......
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