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

simplification

parent 61866cf4
Branches
Tags
No related merge requests found
......@@ -15,19 +15,9 @@ sub new {
die "non-existing file $args{file}" unless -f $args{file};
die "non-readable file $args{file}" unless -r $args{file};
open(my $handle, '<', $args{file})
or die "failed to open file $args{file}: $ERRNO";
my $parser = XML::LibXML->new();
die "Failed to initialize XML parser" unless $parser;
my $doc;
eval { $doc = $parser->parse_fh($handle) };
die "Failed to parse file $args{file}: $EVAL_ERROR"
if $EVAL_ERROR;
die "Failed to parse file $args{file}: $EVAL_ERROR"
unless $doc;
eval { $doc = XML::LibXML->load_xml(location => $args{file}); };
die "Failed to parse file: $EVAL_ERROR" if $EVAL_ERROR;
my $root = $doc->documentElement();
my $type = $root->nodeName();
......
......@@ -43,7 +43,7 @@ throws_ok {
$metadata = IdPAccountManager::SAMLMetadata->new(
file => $file1->filename()
);
} qr/^Failed to parse file \S+: Empty Stream/,
} qr/^Failed to parse file: \S+ parser error : Document is empty/,
'instanciation: empty file';
my $file2 = File::Temp->new(UNLINK => $ENV{TEST_DEBUG} ? 0 : 1);
......@@ -57,7 +57,7 @@ throws_ok {
$metadata = IdPAccountManager::SAMLMetadata->new(
file => $file2->filename()
);
} qr/^Failed to parse file \S+: Entity: line 1: parser error/,
} qr/^Failed to parse file: \S+ parser error : Start tag expected/,
'instanciation: non-xml file';
my $file3 = File::Temp->new(UNLINK => $ENV{TEST_DEBUG} ? 0 : 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment