App-CamelPKI
view release on metacpan or search on metacpan
lib/App/CamelPKI/CA.pm view on Meta::CPAN
name => "Frida", uid => 555);
pass("the template did not catched the trickery...");
try {
$ca->commit();
fail("the coherence check should been triggered now");
} catch App::CamelPKI::Error::User with {
pass("two certificates for Frida, that's a bad thing");
};
};
test "->facet_certtemplate" => sub {
my $ca = load_ca->facet_certtemplate("No::Such::CertTemplate");
my @no_certs = $ca->database->search(-revoked => 0);
is(scalar(@no_certs), 0, "no certificate in the dummy template");
};
test "facets intersection" => sub {
my $ca = load_ca->facet_certtemplate("No::Such::CertTemplate")
->facet_readonly;
my @no_certs = $ca->database->search(-revoked => 0);
is(scalar(@no_certs), 0, "no certificate in the dummy template");
try {
$ca->issue_crl();
fail("this method is not in the facet");
} catch App::CamelPKI::Error::Privilege with {
pass;
};
};
test "capability discipline "
. "sur le CertTemplate->test_certificate_conflict" => sub {
my $pubkey = App::CamelPKI::PublicKey->parse($test_public_keys{"rsa1024"});
our $ca = load_ca;
our ($cert_in_other_template) = $ca->database->search();
ok($cert_in_other_template->isa("App::CamelPKI::Certificate"));
{
package Bogus::CertTemplate;
our @ISA = qw(App::CamelPKI::CertTemplate::Foo); # The same as
# hereafter
sub test_certificate_conflict {
my ($class, $db, @keyvals) = @_;
use Test::More;
is($db->search(-revoked => undef,
-certificate => $cert_in_other_template)
->count(), 0, <<"MESSAGE");
test_certificate_conflict must not see other templates's certificates.
MESSAGE
foreach my $cert (map {$_->{cert}} @{$ca->{signed}}) {
is($db->search(-revoked => undef,
-certificate => $cert)->count(), 0,
<<"MESSAGE");
test_certificate_conflict must not see certificates of the current
transaction.
MESSAGE
}
return $class->SUPER::test_certificate_conflict($db, @keyvals);
}
}
#
$ca->issue("Bogus::CertTemplate", $pubkey,
name => "Harry", uid => 1001);
$ca->issue("Bogus::CertTemplate", $pubkey,
name => "Sally", uid => 1002);
$ca->commit();
};
test "Evil CertTemplate" => sub {
my $ca = load_ca;
our ($oups_evil_certificat) = $ca->database->search();
ok($oups_evil_certificat->isa("App::CamelPKI::Certificate"));
{
package Evil::CertTemplate;
our @ISA = qw(App::CamelPKI::CertTemplate::Foo); # The one of L</SYNOPSIS>
sub normalize_args {
fail("GOTCHA!");
}
sub test_certificate_conflict {
return $oups_evil_certificat;
}
}
#
my $pubkey = App::CamelPKI::PublicKey->parse($test_public_keys{"rsa1024"});
try {
$ca->issue("Evil::CertTemplate", $pubkey,
name => "zoinx", uid => 2000);
fail("He sank my certificate!!!");
} catch App::CamelPKI::Error::Privilege with {
pass("Well tried, but boo, you failed!");
};
};
=end internals
=cut
( run in 0.956 second using v1.01-cache-2.11-cpan-5735350b133 )