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tsmzg6z\n"
+ "-----END CERTIFICATE-----\n";
+
using namespace CKM;
BOOST_AUTO_TEST_SUITE(CERTIFICATE_TEST)
RawBuffer certbase64(CERT_BASE64.begin(), CERT_BASE64.end());
BOOST_REQUIRE_NO_THROW(CertificateImpl(certbase64, DataFormat::FORM_DER_BASE64));
+}
+NEGATIVE_TEST_CASE(constructors)
+{
RawBuffer dummy({0x0a, 0x0b, 0x0c, 0x0d});
BOOST_REQUIRE(!Certificate::create(dummy, DataFormat::FORM_PEM));
+
+ RawBuffer certpem(CERT_PEM.begin(), CERT_PEM.end());
+ BOOST_REQUIRE(!Certificate::create(certpem, DataFormat::FORM_DER));
}
POSITIVE_TEST_CASE(move_semantics)
BOOST_REQUIRE(cert1.getDER() == moveConstructed.getDER());
}
+NEGATIVE_TEST_CASE(get_x509)
+{
+ RawBuffer empty;
+
+ CertificateImpl cert(empty, DataFormat::FORM_PEM);
+
+ BOOST_REQUIRE(cert.empty());
+ BOOST_REQUIRE(cert.getX509() == nullptr);
+}
+
POSITIVE_TEST_CASE(get_evp_sh_ptr)
{
RawBuffer certbuf(CERT_PEM.begin(), CERT_PEM.end());
BOOST_REQUIRE(pubkeyFromCert.getDER() == pubkey.getDER());
}
+NEGATIVE_TEST_CASE(get_evp_sh_ptr)
+{
+ RawBuffer empty;
+
+ CertificateImpl cert(empty, DataFormat::FORM_PEM);
+
+ BOOST_REQUIRE(cert.empty());
+ BOOST_REQUIRE(!cert.getEvpShPtr());
+}
+
+NEGATIVE_TEST_CASE(get_der)
+{
+ RawBuffer empty;
+
+ CertificateImpl cert(empty, DataFormat::FORM_PEM);
+
+ BOOST_REQUIRE(cert.empty());
+ BOOST_REQUIRE(cert.getDER().empty());
+}
+
POSITIVE_TEST_CASE(get_ocsp_url)
{
- RawBuffer certbuf(CERT_PEM.begin(), CERT_PEM.end());
+ RawBuffer certbuf(CERT_OCSP_PEM.begin(), CERT_OCSP_PEM.end());
CertificateImpl cert(certbuf, DataFormat::FORM_PEM);
+ BOOST_REQUIRE(!cert.getOCSPURL().empty());
+}
+
+NEGATIVE_TEST_CASE(get_ocsp_url)
+{
+ RawBuffer empty;
+ CertificateImpl cert(empty, DataFormat::FORM_PEM);
+
+ BOOST_REQUIRE(cert.empty());
BOOST_REQUIRE(cert.getOCSPURL().empty());
+
+ RawBuffer certbuf(CERT_PEM.begin(), CERT_PEM.end());
+ CertificateImpl cert2(certbuf, DataFormat::FORM_PEM);
+
+ BOOST_REQUIRE(!cert2.empty());
+ BOOST_REQUIRE(cert2.getOCSPURL().empty());
}
BOOST_AUTO_TEST_SUITE_END()