#include "test_macros.h"
#include "test_common.h"
+#include "test_constant.h"
#include "cert-svc/cprimitives.h"
#include "cert-svc/cinstance.h"
#include "cert-svc/cstring.h"
certsvc_instance_free(instance);
}
+POSITIVE_TEST_CASE(T_certsvc_pkcs12_has_password)
+{
+ int result;
+ int hasPassword;
+
+ BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+ CertSvcString certPath = wrapperCertsvcStringNew(instance, ServerCert::P12WithPassPath.c_str(), &result);
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+ result = certsvc_pkcs12_has_password(instance, certPath, &hasPassword);
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+ BOOST_CHECK_EQUAL(hasPassword, CERTSVC_TRUE);
+
+ certsvc_string_free(certPath);
+ certsvc_instance_free(instance);
+}
+
+NEGATIVE_TEST_CASE(T_certsvc_pkcs12_has_password_with_invalid_param)
+{
+ int result;
+ int hasPassword;
+
+ BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+ CertSvcString certPath = wrapperCertsvcStringNew(instance, ServerCert::P12WithoutPassPath.c_str(), &result);
+ result = certsvc_pkcs12_has_password(instance, certPath, &hasPassword);
+ BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+ BOOST_CHECK_EQUAL(hasPassword, CERTSVC_FALSE);
+
+ CertSvcString certPathEmpty;
+ result = certsvc_pkcs12_has_password(instance, certPathEmpty, &hasPassword);
+ BOOST_CHECK_EQUAL(result, CERTSVC_IO_ERROR);
+ BOOST_CHECK_EQUAL(hasPassword, CERTSVC_FALSE);
+
+ certsvc_string_free(certPath);
+ certsvc_instance_free(instance);
+}
+
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file