certsvc_instance_free(instance);
}
+POSITIVE_TEST_CASE(T_certsvc_certificate_is_signed_by)
+{
+ CertSvcCertificate child, parent;
+ int status, result;
+
+ BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+ makeCertificateFromFile(
+ instance,
+ CertChain::Signer::Path,
+ child,
+ CertChain::Signer::SubjectCommonName);
+
+ makeCertificateFromFile(
+ instance,
+ CertChain::Intermediate::Path,
+ parent,
+ CertChain::Intermediate::SubjectCommonName);
+
+ result = certsvc_certificate_is_signed_by(child, parent, &status);
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+ BOOST_CHECK_EQUAL(status, CERTSVC_TRUE);
+
+ certsvc_certificate_free(child);
+ certsvc_certificate_free(parent);
+ certsvc_instance_free(instance);
+}
+
+NEGATIVE_TEST_CASE(T_certsvc_certificate_is_signed_by)
+{
+ CertSvcCertificate child, parent;
+ int status, result;
+ CertSvcInstance vinstance;
+
+ BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+ BOOST_REQUIRE_EQUAL(certsvc_instance_new(&vinstance), CERTSVC_SUCCESS);
+
+ child.privateInstance = instance;
+ child.privateHandler = 10;
+ parent.privateInstance = vinstance;
+ parent.privateHandler = 10;
+
+ result = certsvc_certificate_is_signed_by(child, parent, &status);
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ parent.privateInstance = instance;
+
+ result = certsvc_certificate_is_signed_by(child, parent, &status);
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ makeCertificateFromFile(
+ instance,
+ CertChain::Signer::Path,
+ child,
+ CertChain::Signer::SubjectCommonName);
+
+ result = certsvc_certificate_is_signed_by(child, parent, &status);
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ makeCertificateFromFile(
+ instance,
+ CertChain::Intermediate::Path,
+ parent,
+ CertChain::Intermediate::SubjectCommonName);
+
+ result = certsvc_certificate_is_signed_by(parent, child, &status);
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+ BOOST_CHECK_EQUAL(status, CERTSVC_FALSE);
+
+ certsvc_certificate_free(child);
+ certsvc_certificate_free(parent);
+ certsvc_instance_free(instance);
+ certsvc_instance_free(vinstance);
+}
+
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
}
}
+void loadCertListFromStore(CertSvcCertificateList &certificateList)
+{
+ int result;
+ CertSvcStoreCertList *certList = NULL;
+
+ getCertListFromStore(WIFI_STORE, ENABLED, &certList, CERTSVC_SUCCESS);
+ BOOST_CHECK(certList);
+ BOOST_CHECK_EQUAL(strlen(certList->gname), 40);
+
+ CertSvcString gNameStr = wrapperCertsvcStringNew(certList->gname, &result);
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+ result = certsvc_pkcs12_load_certificate_list_from_store(
+ instance,
+ WIFI_STORE,
+ gNameStr,
+ &certificateList);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+ BOOST_CHECK_EQUAL(certificateList.privateHandler, 0);
+
+ certsvc_string_free(gNameStr);
+ freeCertList(certList);
+}
+
BOOST_AUTO_TEST_SUITE(VCORE_API_PKCS12_TEST)
POSITIVE_TEST_CASE(T_import_cert_from_to_individual_store)
POSITIVE_TEST_CASE(T_certsvc_pkcs12_load_certificate_list_from_store)
{
int result;
- CertSvcStoreCertList *certList = NULL;
-
- BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
-
- getCertListFromStore(WIFI_STORE, ENABLED, &certList, CERTSVC_SUCCESS);
- BOOST_CHECK(certList);
- BOOST_CHECK_EQUAL(strlen(certList->gname), 40);
-
- CertSvcString gNameStr = wrapperCertsvcStringNew(certList->gname, &result);
- BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
CertSvcCertificateList certificateList;
certificateList.privateHandler = -1;
- result = certsvc_pkcs12_load_certificate_list_from_store(
- instance,
- WIFI_STORE,
- gNameStr,
- &certificateList);
+ BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
- BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
- BOOST_CHECK_EQUAL(certificateList.privateHandler, 0);
+ loadCertListFromStore(certificateList);
size_t certCount = 0;
result = certsvc_certificate_list_get_length(certificateList, &certCount);
BOOST_CHECK(certCount > 0);
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
certsvc_certificate_list_free(certificateList);
- certsvc_string_free(gNameStr);
- freeCertList(certList);
certsvc_instance_free(instance);
}
certsvc_instance_free(instance);
}
+POSITIVE_TEST_CASE(T_certsvc_certificate_list_get_one)
+{
+ int result;
+
+ CertSvcCertificateList certificateList;
+ certificateList.privateHandler = -1;
+
+ BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+ loadCertListFromStore(certificateList);
+
+ CertSvcCertificate cert;
+ cert.privateHandler = -1;
+ result = certsvc_certificate_list_get_one(certificateList, 0, &cert);
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+ BOOST_CHECK_EQUAL(cert.privateHandler, 0);
+
+ certsvc_certificate_free(cert);
+ certsvc_certificate_list_all_free(certificateList);
+ certsvc_instance_free(instance);
+}
+
+NEGATIVE_TEST_CASE(T_certsvc_certificate_list_get_one)
+{
+ int result;
+
+ BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+ CertSvcCertificateList certificateList;
+ certificateList.privateHandler = -1;
+ certificateList.privateInstance = instance;
+
+ CertSvcCertificate cert;
+ cert.privateHandler = -1;
+
+ result = certsvc_certificate_list_get_one(certificateList, 0, &cert);
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ loadCertListFromStore(certificateList);
+
+ result = certsvc_certificate_list_get_one(certificateList, 100, &cert);
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ certsvc_certificate_list_all_free(certificateList);
+ certsvc_instance_free(instance);
+}
+
POSITIVE_TEST_CASE(T_certsvc_pkcs12_delete_certificate_from_store)
{
int result;