BEGIN {
require
't/test-lib.pm'
;
}
my
(
$client
,
$res
,
$id
);
$client
= LLNG::Manager::Test->new(
{
ini
=> {
logLevel
=>
'error'
,
restSessionServer
=> 0 } } );
ok(
$res
=
$client
->_post(
'/'
,
IO::String->new(
'user=dwho&password=dwho'
),
length
=> 23
),
'Auth query'
);
count(1);
expectOK(
$res
);
$id
= expectCookie(
$res
);
ok(
$res
=
$client
->_get(
'/mysession'
,
query
=>
'authorizationfor=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29t'
,
cookie
=>
"lemonldap=$id"
),
'Check for test1'
);
count(1);
expectOK(
$res
);
$res
=
eval
{ JSON::from_json(
$res
->[2]->[0] ) };
if
($@) {
fail(
"Bad JSON response: $@"
);
count(1);
}
ok(
$res
->{result} == 1,
' http//test1.example.com is ganted'
);
count(1);
ok(
$res
=
$client
->_get(
'/mysession'
,
query
=>
'authorizationfor=aHR0cDovL3Rlc3Q0LmV4YW1wbGUuY29t'
,
cookie
=>
"lemonldap=$id"
),
'Check for test1'
);
count(1);
expectOK(
$res
);
ok(
$res
=
$client
->_get(
'/myapplications'
,
cookie
=>
"lemonldap=$id"
),
'Request for my applications'
);
count(1);
expectOK(
$res
);
$res
=
eval
{ JSON::from_json(
$res
->[2]->[0] ) };
if
($@) {
fail(
"Bad JSON response: $@"
);
count(1);
}
ok(
$res
->{result} == 1,
' Result == 1'
);
count(1);
ok(
$res
->{myapplications}->[0]->{Category} eq
'Sample applications'
,
' "Sample applications" category found'
);
ok(
scalar
@{
$res
->{myapplications}->[0]->{Applications} } == 2,
' Two applications found'
);
ok(
$res
->{myapplications}->[0]->{Applications}->[0]->{
'Application Test 1'
}
->{AppDesc} eq
'A simple application displaying authenticated user'
,
' Description app1 found'
);
ok(
$res
->{myapplications}->[0]->{Applications}->[0]->{
'Application Test 1'
}
' Logo app1 found'
);
ok(
$res
->{myapplications}->[0]->{Applications}->[1]->{
'Application Test 2'
}
->{AppUri} =~ m
' URI app2 found'
);
count(5);
$client
->logout(
$id
);
clean_sessions();
done_testing( count() );