summaryrefslogtreecommitdiffstats
path: root/bindings/perl/t/Lasso.t
blob: 0c323822e9dc3248a56422a64e8162a9dd078907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lasso.pm.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More tests => 11;
use Lasso;
use Data::Dumper;
use Error qw(:try);

#########################
my $SRCDIR = $ENV{'TOP_SRCDIR'};

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

# Test arrays
$request = new Lasso::SamlpRequest();
ok (! defined($request->RespondWith));
Lasso::SamlpRequestAbstract::RespondWith($request, "x", "y", "z");
@l = $request->RespondWith;
ok(@l == 3);
ok($l[0] eq 'x');
ok($l[1] eq 'y');
ok($l[2] eq 'z');

$server = new Lasso::Server($SRCDIR . "/tests/data/sp5-saml2/metadata.xml", $SRCDIR . "/tests/data/sp5-saml2/private-key.pem");
ok($server);
$server->add_provider(Lasso::Constants::PROVIDER_ROLE_SP, $SRCDIR . "/tests/data/idp5-saml2/metadata.xml");
$login = new Lasso::Login $server;

# Test error reporting
eval { $login->init_authn_request; };
ok($@->{code} == -409);

$server = new Lasso::Server($SRCDIR . "/tests/data/sp5-saml2/metadata.xml", $SRCDIR . "/tests/data/sp5-saml2/private-key.pem");
ok($server);
$server->add_provider(Lasso::Constants::PROVIDER_ROLE_IDP, $SRCDIR . "/tests/data/idp5-saml2/metadata.xml");
ok(Lasso::check_version(2,2,90, Lasso::Constants::CHECK_VERSION_NUMERIC) == 1);
ok(Lasso::check_version(2,2,90, Lasso::Constants::CHECK_VERSION_EXACT) == 0);

$@ = undef;

eval { Lasso::Server::dump(undef); };
ok($@->{code} == Lasso::Constants::PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);