Improve unit test & update manifest (#2019)
This commit is contained in:
parent
3f40c70ae5
commit
37e7e0b81e
|
@ -367,6 +367,7 @@ site/htdocs/static/languages/vi.json
|
||||||
site/htdocs/static/languages/zh.json
|
site/htdocs/static/languages/zh.json
|
||||||
site/templates/bootstrap/2fchoice.tpl
|
site/templates/bootstrap/2fchoice.tpl
|
||||||
site/templates/bootstrap/2fregisters.tpl
|
site/templates/bootstrap/2fregisters.tpl
|
||||||
|
site/templates/bootstrap/captcha.tpl
|
||||||
site/templates/bootstrap/casBack2Url.tpl
|
site/templates/bootstrap/casBack2Url.tpl
|
||||||
site/templates/bootstrap/checklogins.tpl
|
site/templates/bootstrap/checklogins.tpl
|
||||||
site/templates/bootstrap/checkuser.tpl
|
site/templates/bootstrap/checkuser.tpl
|
||||||
|
|
|
@ -6,7 +6,7 @@ require 't/test-lib.pm';
|
||||||
|
|
||||||
my $res;
|
my $res;
|
||||||
|
|
||||||
my $maintests = 18;
|
my $maintests = 24;
|
||||||
SKIP: {
|
SKIP: {
|
||||||
eval 'use GD::SecurityImage;use Image::Magick;';
|
eval 'use GD::SecurityImage;use Image::Magick;';
|
||||||
if ($@) {
|
if ($@) {
|
||||||
|
@ -47,7 +47,6 @@ m%<input name="password" type="text" class="form-control key" autocomplete="off"
|
||||||
explain( $res->[2]->[0], '<img id="captcha" src="data:image/png;base64' );
|
explain( $res->[2]->[0], '<img id="captcha" src="data:image/png;base64' );
|
||||||
|
|
||||||
# Try to get captcha value
|
# Try to get captcha value
|
||||||
|
|
||||||
my ( $ts, $captcha );
|
my ( $ts, $captcha );
|
||||||
ok( $ts = getCache()->get($token), ' Found token session' );
|
ok( $ts = getCache()->get($token), ' Found token session' );
|
||||||
$ts = eval { JSON::from_json($ts) };
|
$ts = eval { JSON::from_json($ts) };
|
||||||
|
@ -113,6 +112,48 @@ m%<input name="password" type="text" class="form-control key" autocomplete="off"
|
||||||
ok( $newtoken ne $token, ' Token is refreshed' );
|
ok( $newtoken ne $token, ' Token is refreshed' );
|
||||||
ok( $res->[2]->[0] =~ m#<img id="captcha" src="data:image/png;base64#,
|
ok( $res->[2]->[0] =~ m#<img id="captcha" src="data:image/png;base64#,
|
||||||
' New captcha image inserted' );
|
' New captcha image inserted' );
|
||||||
|
|
||||||
|
# Try to renew captcha
|
||||||
|
ok( $res = $client->_get( '/renewcaptcha', accept => 'text/html' ),
|
||||||
|
'Unauth request to renew Captcha' );
|
||||||
|
my $json = eval { JSON::from_json( $res->[2]->[0] ) };
|
||||||
|
ok( ( defined $json->{newtoken} and $json->{newtoken} =~ /^\d{10}_\d+$/ ),
|
||||||
|
'New token has been received' )
|
||||||
|
or explain( $json->{newtoken}, 'NO token received' );
|
||||||
|
ok( (
|
||||||
|
defined $json->{newimage}
|
||||||
|
and $json->{newimage} =~ m%^data:image/png;base64,.+%
|
||||||
|
),
|
||||||
|
'New image has been received'
|
||||||
|
) or explain( $json->{newimage}, 'NO image received' );
|
||||||
|
|
||||||
|
# Try to submit new captcha
|
||||||
|
ok( $ts = getCache()->get( $json->{newtoken} ),
|
||||||
|
' Found new token session' );
|
||||||
|
$ts = eval { JSON::from_json($ts) };
|
||||||
|
$query =
|
||||||
|
"user=dwho&password=dwho&captcha=$ts->{captcha}&token=$json->{newtoken}";
|
||||||
|
ok(
|
||||||
|
$res = $client->_post(
|
||||||
|
'/',
|
||||||
|
IO::String->new($query),
|
||||||
|
length => length($query)
|
||||||
|
),
|
||||||
|
'Try to auth with new captcha value'
|
||||||
|
);
|
||||||
|
expectOK($res);
|
||||||
|
$id = expectCookie($res);
|
||||||
|
ok(
|
||||||
|
$res = $client->_get(
|
||||||
|
'/',
|
||||||
|
query => 'url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw==',
|
||||||
|
cookie => "lemonldap=$id",
|
||||||
|
accept => 'text/html'
|
||||||
|
),
|
||||||
|
'Auth request with redirection'
|
||||||
|
);
|
||||||
|
expectRedirection( $res, 'http://test1.example.com/' );
|
||||||
|
expectAuthenticatedAs( $res, 'dwho' );
|
||||||
}
|
}
|
||||||
count($maintests);
|
count($maintests);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user