App-CamelPKI
view release on metacpan or search on metacpan
t/acceptance-permissions.t view on Meta::CPAN
#!perl -w
use strict;
=head1 NAME
acceptance-permissions.t - Try to access Camel-PKI using the wrong
credentials, and fail (hopefully)
=cut
use Test::More;
use Test::Group;
use App::CamelPKI;
use App::CamelPKI::Test qw(jsonreq_remote);
use File::Slurp;
my $webserver = App::CamelPKI->model("WebServer")->apache;
if ($webserver->is_installed_and_has_perl_support && $webserver->is_operational) {
plan tests => 2;
} else {
plan skip_all => "Apache is not insalled or Key Ceremnoy has not been done !";
}
$webserver->start(); END { $webserver->stop(); }
$webserver->tail_error_logfile();
my $port = $webserver->https_port();
=pod
We try to perform the same access as C<acceptance-issue-certifcates.t>
in the same directory, with the same request structure (although it
doesn't matter all that much since the request will fail anyway)
=cut
my $url = "https://localhost:$port/ca/template/vpn/certifyJSON";
my $req = {
requests => [
{ template => "VPN1",
dns => "bar.example.com",
},
{ template => "VPN1",
dns => "bar.example.com",
},
{ template => "VPN1",
dns => "bar.example.com",
},
{ template => "VPN1",
dns => "bar.example.com",
}
],
};
test "try to operate CA without a certificate" => sub {
my $response = jsonreq_remote($url, $req);
is($response->code, 403, "permission denied");
unlike($response->code, qr|<html|, "error message is in plain text");
};
test "try to operate CA with a wrong certificate" => sub {
my $keypem = "-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAs5y3jQ8tg2z/E7E+URZLyvS3tASALqGVt8rPd4U8J5/Wv+ee
ZAbnUcGZChzk70bywc/jn34vxbqHX5THDEgVodGI8hKgQgVHfnydsE0Q0GmAkyKV
DiM6Ve9I8F+TnoZmZGkIQD737BnmDMXOBdleE5c/XBkIDch2k75A9j32zhfh3yQy
Q9oVGPKVR5chmCSNLoni6O9VXxcBKxQAYxfxgA9mx6XHLi1iaYy9Q8Xrl7jMR4H7
7+7+eXJwXLqPxLVPahXhN10dsTmIajmKhL5uHwxeRjlNeZm4nFfhTQo46d7ZGGsX
pW6xHFeXqNJhLBHCMn1AkJqN03NnXwJmpjbuCwIDAQABAoIBABKuzYT1vDU8hDfn
( run in 1.064 second using v1.01-cache-2.11-cpan-d8267643d1d )