Skip to content
Snippets Groups Projects
Commit 61866cf4 authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

initial import

parent 22715220
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/perl
use strict;
use warnings;
use English qw(-no_match_vars);
use File::Temp;
use Test::More;
use Test::Exception;
use IdPAccountManager::SAMLMetadata;
plan tests => 6;
my $metadata;
throws_ok {
$metadata = IdPAccountManager::SAMLMetadata->new();
} qr/^missing argument 'file'/,
'instanciation: no file argument';
throws_ok {
$metadata = IdPAccountManager::SAMLMetadata->new(
file => '/no/such/file',
);
} qr/^non-existing file/,
'instanciation: non-existing file argument';
my $file1 = File::Temp->new(UNLINK => $ENV{TEST_DEBUG} ? 0 : 1);
chmod 0000, $file1;
throws_ok {
$metadata = IdPAccountManager::SAMLMetadata->new(
file => $file1->filename()
);
} qr/^non-readable file/,
'instanciation: non-readable file';
chmod 0644, $file1;
throws_ok {
$metadata = IdPAccountManager::SAMLMetadata->new(
file => $file1->filename()
);
} qr/^Failed to parse file \S+: Empty Stream/,
'instanciation: empty file';
my $file2 = File::Temp->new(UNLINK => $ENV{TEST_DEBUG} ? 0 : 1);
print $file2 <<EOF;
foo
EOF
close($file2);
throws_ok {
$metadata = IdPAccountManager::SAMLMetadata->new(
file => $file2->filename()
);
} qr/^Failed to parse file \S+: Entity: line 1: parser error/,
'instanciation: non-xml file';
my $file3 = File::Temp->new(UNLINK => $ENV{TEST_DEBUG} ? 0 : 1);
print $file3 <<EOF;
<?xml version="1.0" encoding="UTF-8" ?>
<root/>
EOF
close($file3);
throws_ok {
$metadata = IdPAccountManager::SAMLMetadata->new(
file => $file3->filename()
);
} qr/^incorrect root element type 'root'/,
'instanciation: incorrect xml file';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment