binmode
STDOUT,
':encoding(UTF-8)'
;
binmode
STDERR,
':encoding(UTF-8)'
;
use
lib
"$FindBin::Bin/../"
;
use
feature
'signatures'
;
no
warnings
"experimental::signatures"
;
subtest
"Load credentials from a file"
, \
&credentialsFromFile
;
sub
credentialsFromFile {
my
(
$fh
,
$filename
,
$papi
);
eval
{
(
$fh
,
$filename
) = File::Temp::tempfile();
print
$fh
"username:password"
;
close
$fh
;
"Given a Pootle::Client connection, with credentials from a file"
);
(
$fh
,
$filename
) = File::Temp::tempfile();
print
$fh
<<TEXT;
#This is a credentials file, Pootle::Client gets its credentials from here
username:password
#Thanks!
TEXT
close
$fh
;
"Given a Pootle::Client connection, with credentials from a bloated file"
);
};
if
($@) {
ok(0, $@);
}
};
subtest
"Load bad credentials from a file"
, \
&badCredentialsFromFile
;
sub
badCredentialsFromFile {
my
(
$fh
,
$filename
,
$papi
);
eval
{
(
$fh
,
$filename
) = File::Temp::tempfile();
print
$fh
"username-password"
;
close
$fh
;
throws_ok(
sub
{
},
'Pootle::Exception::Credentials'
,
"Received proper Credentials-exception"
);
like($@,
qr/$filename/
,
"Faulting filename mentioned in exception"
);
};
if
($@) {
ok(0, $@);
}
};
done_testing();