* limitations under the License.
*/
+#include <string>
+
#include "cert-svc/ccert.h"
#include "cert-svc/cerror.h"
#include "test_common.h"
free(certBlockBuffer);
}
+void installCertToStore(
+ std::string privateKeyGname,
+ std::string associatedGname,
+ std::string dataBlock,
+ CertType certType)
+{
+ int result;
+ for(auto storeType: storeTypeMap)
+ {
+ result = installCertificateToStore(
+ storeType.second,
+ gNamePrefix.c_str(),
+ commonNamePrefix.c_str(),
+ privateKeyGname.empty() ? NULL : privateKeyGname.c_str(),
+ associatedGname.empty() ? NULL : associatedGname.c_str(),
+ dataBlock.empty() ? NULL : dataBlock.c_str(),
+ certType);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+ }
+}
+
+void uninstallCertFromStore()
+{
+ int result;
+ for(auto storeType: storeTypeMap)
+ {
+ result = deleteCertificateFromStore(storeType.second, gNamePrefix.c_str());
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+ }
+}
+
BOOST_AUTO_TEST_SUITE(CERT_SERVER_LOGIC_TEST)
POSITIVE_TEST_CASE(T_install_certificate_to_store)
result = initialize_db();
BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
- for(auto storeType: storeTypeMap)
- {
- result = installCertificateToStore(
- storeType.second,
- gNamePrefix.c_str(),
- commonNamePrefix.c_str(),
- NULL,
- NULL,
- PemCertInfo::CertPEM.c_str(),
- PEM_CRT);
-
- BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
- }
+ installCertToStore(std::string(), std::string(), PemCertInfo::CertPEM, PEM_CRT);
- for(auto storeType: storeTypeMap)
- {
- result = deleteCertificateFromStore(storeType.second, gNamePrefix.c_str());
- BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
- }
+ uninstallCertFromStore();
deinitialize_db();
-
}
NEGATIVE_TEST_CASE(T_delete_certificate_from_store_error)
BOOST_CHECK_EQUAL(result, CERTSVC_FAIL);
}
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
+POSITIVE_TEST_CASE(T_update_ca_certificate_file)
+{
+ int result = update_ca_certificate_file(const_cast<char*>(PemCertInfo::CertPEM.c_str()));
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+}
+
+NEGATIVE_TEST_CASE(T_update_ca_certificate_file_with_parameter_cert_is_null)
+{
+ int result = update_ca_certificate_file(NULL);
+ BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
+
+ result = initialize_db();
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+ installCertToStore(std::string(), std::string(), PemCertInfo::CertPEM, PEM_CRT);
+
+ result = update_ca_certificate_file(NULL);
+
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+ uninstallCertFromStore();
+ deinitialize_db();
+}
+
+BOOST_AUTO_TEST_SUITE_END()