Add unit tests to get certificate info, status, and alias name from store 38/314738/4
authorPhan Xuan Tan <xuan.tan@samsung.com>
Thu, 18 Jul 2024 07:58:40 +0000 (14:58 +0700)
committerPhan Xuan Tan <xuan.tan@samsung.com>
Fri, 26 Jul 2024 06:04:57 +0000 (13:04 +0700)
Change-Id: Ib2b235de76e1effa5887be466e12b9a90a73ef5d

unit-tests/test_vcore_api_pkcs12.cpp

index 777f924..eda7043 100644 (file)
@@ -36,6 +36,7 @@ static const std::string WithPass = "PASS_";
 static const std::string EndUser = "END_USER_";
 static const std::string RetList = "RL_";
 static const std::string GroupNameTest = "GroupNameTest";
+static const std::string GroupNameSystem = "9c8dfbd4.0";
 
 CertSvcString wrapperCertsvcStringNew(std::string originStr, int *retVal)
 {
@@ -58,8 +59,6 @@ void importCertFromFileToStore(
 {
        int result;
 
-       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
-
        CertSvcString cStrPath = wrapperCertsvcStringNew(path, &result);
        BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
 
@@ -81,7 +80,6 @@ void importCertFromFileToStore(
        certsvc_string_free(cStrPath);
        certsvc_string_free(cStrPass);
        certsvc_string_free(cStrAlias);
-       certsvc_instance_free(instance);
 }
 
 void importCertFromFileToStoreRetList(
@@ -96,8 +94,6 @@ void importCertFromFileToStoreRetList(
        CertSvcStoreCertList *certList = NULL;
        size_t length = 0;
 
-       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
-
        CertSvcString cStrPath = wrapperCertsvcStringNew(path, &result);
        BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
 
@@ -128,7 +124,6 @@ void importCertFromFileToStoreRetList(
        certsvc_string_free(cStrPath);
        certsvc_string_free(cStrPass);
        certsvc_string_free(cStrAlias);
-       certsvc_instance_free(instance);
 }
 
 void getCertListFromStore(CertStoreType storeType, int isRootApp, CertSvcStoreCertList **certList, int expected)
@@ -136,8 +131,6 @@ void getCertListFromStore(CertStoreType storeType, int isRootApp, CertSvcStoreCe
        int result;
        size_t length = 0;
 
-       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
-
        result = certsvc_pkcs12_get_certificate_list_from_store(
                instance,
                storeType,
@@ -151,19 +144,13 @@ void getCertListFromStore(CertStoreType storeType, int isRootApp, CertSvcStoreCe
                BOOST_CHECK(certList);
                BOOST_CHECK(length > 0);
        }
-
-       certsvc_instance_free(instance);
 }
 
 void freeCertList(CertSvcStoreCertList *certList)
 {
-       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
-
        int result = certsvc_pkcs12_free_certificate_list_loaded_from_store(instance, &certList);
        BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
        BOOST_CHECK(!certList);
-
-       certsvc_instance_free(instance);
 }
 
 void getCertListFromStoreAndFree(CertStoreType storeType, int isRootApp, int expected)
@@ -183,8 +170,6 @@ void checkCertListFromStore(CertSvcStoreCertList *certList)
        int result;
        int count = 0;
 
-       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
-
        while (certList)
        {
                result = certsvc_pkcs12_get_certificate_from_store(
@@ -200,8 +185,6 @@ void checkCertListFromStore(CertSvcStoreCertList *certList)
                certList = certList->next;
                count++;
        }
-
-       certsvc_instance_free(instance);
 }
 
 void getEndUserCertListFromStores(
@@ -212,8 +195,6 @@ void getEndUserCertListFromStores(
        int result;
        size_t length = 0;
 
-       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
-
        result = certsvc_pkcs12_get_end_user_certificate_list_from_store(
                instance,
                storeType,
@@ -228,8 +209,6 @@ void getEndUserCertListFromStores(
        } else {
                BOOST_CHECK_EQUAL(length, 0);
        }
-
-       certsvc_instance_free(instance);
 }
 
 void getRootCertListFromStores(
@@ -240,8 +219,6 @@ void getRootCertListFromStores(
        int result;
        size_t length = 0;
 
-       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
-
        result = certsvc_pkcs12_get_root_certificate_list_from_store(
                instance,
                storeType,
@@ -256,8 +233,100 @@ void getRootCertListFromStores(
        } else {
                BOOST_CHECK_EQUAL(length, 0);
        }
+}
 
-       certsvc_instance_free(instance);
+void getCertificateInfoFromStore(
+       CertStoreType storeType,
+       CertSvcString gNameStr,
+       bool isBuffer,
+       int expected)
+{
+       int result;
+       size_t certLength = 0;
+       char *certBuffer = NULL;
+
+       result = certsvc_pkcs12_get_certificate_info_from_store(
+               instance,
+               storeType,
+               gNameStr,
+               isBuffer ? &certBuffer : NULL,
+               &certLength);
+
+       BOOST_CHECK_EQUAL(result, expected);
+
+       if (expected == CERTSVC_SUCCESS) {
+               BOOST_CHECK(certBuffer);
+               BOOST_CHECK(certLength > 0);
+               free(certBuffer);
+       } else {
+               BOOST_CHECK(!certBuffer);
+               BOOST_CHECK_EQUAL(certLength, 0);
+       }
+}
+
+void getAliasNameForCertificateInStore(
+       CertStoreType storeType,
+       CertSvcString gNameStr,
+       int expected)
+{
+       int result;
+       char *alias = NULL;
+
+       result = certsvc_pkcs12_get_alias_name_for_certificate_in_store(
+               instance,
+               storeType,
+               gNameStr,
+               &alias);
+
+       BOOST_CHECK_EQUAL(result, expected);
+
+       if (expected == CERTSVC_SUCCESS) {
+               BOOST_CHECK(alias);
+               BOOST_CHECK(strlen(alias) > 0);
+               free(alias);
+       } else if (expected == CERTSVC_FAIL) {
+               BOOST_CHECK(alias);
+               BOOST_CHECK(strlen(alias) == 0);
+       } else {
+               BOOST_CHECK(!alias);
+       }
+
+}
+
+void setCertStatusToStore(
+       CertStoreType storeType,
+       int isRootApp,
+       CertSvcString gNameStr,
+       CertStatus status,
+       int expected)
+{
+       int result;
+
+       result = certsvc_pkcs12_set_certificate_status_to_store(
+               instance,
+               storeType,
+               isRootApp,
+               gNameStr,
+               status);
+
+       BOOST_CHECK_EQUAL(result, expected);
+}
+
+void getCertStatusFromStore(
+       CertStoreType storeType,
+       CertSvcString gNameStr,
+       CertStatus *status,
+       int expected)
+{
+       int result;
+
+       result = certsvc_pkcs12_get_certificate_status_from_store(
+               instance,
+               storeType,
+               gNameStr,
+               status);
+
+       BOOST_CHECK_EQUAL(result, expected);
 }
 
 BOOST_AUTO_TEST_SUITE(VCORE_API_PKCS12_TEST)
@@ -267,6 +336,8 @@ POSITIVE_TEST_CASE(T_import_cert_from_to_individual_store)
        std::string path, pass, alias;
        pass = ServerCert::ServerPass;
 
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        for (auto storeType: storeTypeMap)
        {
                path = ServerCert::PemWithoutPassPath;
@@ -309,6 +380,8 @@ POSITIVE_TEST_CASE(T_import_cert_from_to_individual_store)
                alias = PfxPrefix + Chain + storeType.first;
                importCertFromFileToStore(storeType.second, path, pass, alias, CERTSVC_SUCCESS);
        }
+
+       certsvc_instance_free(instance);
 }
 
 NEGATIVE_TEST_CASE(T_import_cert_from_to_individual_store_error)
@@ -316,6 +389,8 @@ NEGATIVE_TEST_CASE(T_import_cert_from_to_individual_store_error)
        std::string path;
        std::string alias = PemPrefix + std::to_string(PEM_CRT);
 
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        path = ServerCert::PemInvalidCert;
        importCertFromFileToStore(WIFI_STORE, path, std::string(), alias, CERTSVC_FAIL);
 
@@ -372,6 +447,7 @@ NEGATIVE_TEST_CASE(T_import_cert_from_to_individual_store_error)
        path = ServerCert::P12WithoutPassPath;
        importCertFromFileToStore(WIFI_STORE, path, std::string(), alias, CERTSVC_WRONG_ARGUMENT);
 
+       certsvc_instance_free(instance);
 }
 
 POSITIVE_TEST_CASE(T_certsvc_pkcs12_import_from_file_to_store_ret_list)
@@ -379,6 +455,8 @@ POSITIVE_TEST_CASE(T_certsvc_pkcs12_import_from_file_to_store_ret_list)
        std::string alias, path, pass;
        pass = ServerCert::ServerPass;
 
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        for (auto storeType: storeTypeMap)
        {
                path = ServerCert::P12WithoutPassPath;
@@ -401,6 +479,8 @@ POSITIVE_TEST_CASE(T_certsvc_pkcs12_import_from_file_to_store_ret_list)
                        true,
                        CERTSVC_SUCCESS);
        }
+
+       certsvc_instance_free(instance);
 }
 
 NEGATIVE_TEST_CASE(T_certsvc_pkcs12_import_from_file_to_store_ret_list_error)
@@ -408,6 +488,8 @@ NEGATIVE_TEST_CASE(T_certsvc_pkcs12_import_from_file_to_store_ret_list_error)
        std::string path = ServerCert::P12WithPassPath;
        std::string alias = P12Prefix + std::to_string(P12_END_USER);
 
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        importCertFromFileToStoreRetList(
                WIFI_STORE,
                path,
@@ -458,10 +540,14 @@ NEGATIVE_TEST_CASE(T_certsvc_pkcs12_import_from_file_to_store_ret_list_error)
                alias,
                true,
                CERTSVC_FAIL);
+
+       certsvc_instance_free(instance);
 }
 
 POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_list_from_stores)
 {
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        getCertListFromStoreAndFree(ALL_STORE, DISABLED, CERTSVC_SUCCESS);
        getCertListFromStoreAndFree(ALL_STORE, ENABLED, CERTSVC_SUCCESS);
 
@@ -470,24 +556,31 @@ POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_list_from_stores)
                getCertListFromStoreAndFree(storeType.second, DISABLED, CERTSVC_SUCCESS);
                getCertListFromStoreAndFree(storeType.second, ENABLED, CERTSVC_SUCCESS);
        }
+
+       certsvc_instance_free(instance);
 }
 
 NEGATIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_list_from_none_store)
 {
        CertSvcStoreCertList *certList = NULL;
 
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        getCertListFromStore(NONE_STORE, DISABLED, &certList, CERTSVC_INVALID_STORE_TYPE);
        getCertListFromStore(NONE_STORE, ENABLED, &certList, CERTSVC_INVALID_STORE_TYPE);
 
        CertSvcStoreCertList *certList1;
        getCertListFromStore(WIFI_STORE, DISABLED, &certList1, CERTSVC_WRONG_ARGUMENT);
 
+       certsvc_instance_free(instance);
 }
 
 POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_from_store)
 {
        CertSvcStoreCertList *certList = NULL;
 
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        getCertListFromStore(WIFI_STORE, DISABLED, &certList, CERTSVC_SUCCESS);
 
        CertSvcStoreCertList *certListOrig = certList;
@@ -495,6 +588,8 @@ POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_from_store)
 
        checkCertListFromStore(certList);
        freeCertList(certListOrig);
+
+       certsvc_instance_free(instance);
 }
 
 NEGATIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_from_store_wrong_argument)
@@ -527,25 +622,37 @@ POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_end_user_certificate_list_from_stores)
 {
        const CertStoreType validStoreType = (CertStoreType)(WIFI_STORE | VPN_STORE | EMAIL_STORE);
        CertSvcStoreCertList *certList = NULL;
+
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        getEndUserCertListFromStores(&certList, validStoreType, CERTSVC_SUCCESS);
        freeCertList(certList);
+
+       certsvc_instance_free(instance);
 }
 
 NEGATIVE_TEST_CASE(T_certsvc_pkcs12_get_end_user_certificate_list_from_store_invalid_argument)
 {
        CertSvcStoreCertList *certList;
+
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        getEndUserCertListFromStores(&certList, WIFI_STORE, CERTSVC_WRONG_ARGUMENT);
 
        certList = NULL;
        getEndUserCertListFromStores(&certList, NONE_STORE, CERTSVC_INVALID_STORE_TYPE);
        getEndUserCertListFromStores(&certList, SYSTEM_STORE, CERTSVC_WRONG_ARGUMENT);
        getEndUserCertListFromStores(&certList, ALL_STORE, CERTSVC_WRONG_ARGUMENT);
+
+       certsvc_instance_free(instance);
 }
 
 POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_root_certificate_list_from_stores)
 {
        const CertStoreType validStoreType = (CertStoreType)(WIFI_STORE | VPN_STORE | EMAIL_STORE);
 
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        CertSvcStoreCertList *certList = NULL;
        getRootCertListFromStores(&certList, validStoreType, CERTSVC_SUCCESS);
        freeCertList(certList);
@@ -557,15 +664,22 @@ POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_root_certificate_list_from_stores)
        certList = NULL;
        getRootCertListFromStores(&certList, ALL_STORE, CERTSVC_SUCCESS);
        freeCertList(certList);
+
+       certsvc_instance_free(instance);
 }
 
 NEGATIVE_TEST_CASE(T_certsvc_pkcs12_get_root_certificate_list_from_store_wrong_argument)
 {
        CertSvcStoreCertList *certList;
+
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
        getRootCertListFromStores(&certList, WIFI_STORE, CERTSVC_WRONG_ARGUMENT);
 
        certList = NULL;
        getRootCertListFromStores(&certList, NONE_STORE, CERTSVC_INVALID_STORE_TYPE);
+
+       certsvc_instance_free(instance);
 }
 
 NEGATIVE_TEST_CASE(T_certsvc_pkcs12_free_certificate_list_loaded_from_store_wrong_argument)
@@ -581,6 +695,179 @@ NEGATIVE_TEST_CASE(T_certsvc_pkcs12_free_certificate_list_loaded_from_store_wron
        certsvc_instance_free(instance);
 }
 
+POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_info_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);
+
+       getCertificateInfoFromStore(WIFI_STORE, gNameStr, true, CERTSVC_SUCCESS);
+
+       certsvc_string_free(gNameStr);
+       freeCertList(certList);
+       certsvc_instance_free(instance);
+}
+
+NEGATIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_info_from_store)
+{
+       int result;
+
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+       CertSvcString gNameStr = wrapperCertsvcStringNew(GroupNameTest, &result);
+       BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+       getCertificateInfoFromStore(WIFI_STORE, gNameStr, false, CERTSVC_WRONG_ARGUMENT);
+       getCertificateInfoFromStore(NONE_STORE, gNameStr, true, CERTSVC_INVALID_STORE_TYPE);
+       getCertificateInfoFromStore(WIFI_STORE, gNameStr, true, CERTSVC_FAIL);
+
+       certsvc_string_free(gNameStr);
+       certsvc_instance_free(instance);
+}
+
+POSITIVE_TEST_CASE(T_certsvc_pkcs12_get_alias_name_for_certificate_in_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);
+
+       getAliasNameForCertificateInStore(WIFI_STORE, gNameStr, CERTSVC_SUCCESS);
+
+       certsvc_string_free(gNameStr);
+       freeCertList(certList);
+       certsvc_instance_free(instance);
+}
+
+NEGATIVE_TEST_CASE(T_certsvc_pkcs12_get_alias_name_for_certificate_in_store)
+{
+       int result;
+
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+       CertSvcString gNameStr = wrapperCertsvcStringNew(GroupNameTest, &result);
+       BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+       getAliasNameForCertificateInStore(NONE_STORE, gNameStr, CERTSVC_INVALID_STORE_TYPE);
+       getAliasNameForCertificateInStore(WIFI_STORE, gNameStr, CERTSVC_FAIL);
+
+       certsvc_string_free(gNameStr);
+
+       gNameStr.privateHandler = NULL;
+
+       getAliasNameForCertificateInStore(WIFI_STORE, gNameStr, CERTSVC_WRONG_ARGUMENT);
+
+       certsvc_instance_free(instance);
+}
+
+POSITIVE_TEST_CASE(T_certsvc_pkcs12_set_and_get_certificate_status_to_store)
+{
+       int result;
+       CertSvcStoreCertList *certList = NULL;
+       CertStatus status = ENABLED;
+
+       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);
+
+       setCertStatusToStore(WIFI_STORE, ENABLED, gNameStr, DISABLED, CERTSVC_SUCCESS);
+
+       getCertStatusFromStore(WIFI_STORE, gNameStr, &status, CERTSVC_SUCCESS);
+       BOOST_CHECK_EQUAL(status, DISABLED);
+
+       setCertStatusToStore(WIFI_STORE, ENABLED, gNameStr, ENABLED, CERTSVC_SUCCESS);
+
+       getCertStatusFromStore(WIFI_STORE, gNameStr, &status, CERTSVC_SUCCESS);
+       BOOST_CHECK_EQUAL(status, ENABLED);
+
+       CertSvcString gNameSystemStr = wrapperCertsvcStringNew(GroupNameSystem, &result);
+       BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+       setCertStatusToStore(SYSTEM_STORE, ENABLED, gNameSystemStr, DISABLED, CERTSVC_SUCCESS);
+
+       getCertStatusFromStore(SYSTEM_STORE, gNameSystemStr, &status, CERTSVC_SUCCESS);
+       BOOST_CHECK_EQUAL(status, DISABLED);
+
+       setCertStatusToStore(SYSTEM_STORE, ENABLED, gNameSystemStr, ENABLED, CERTSVC_SUCCESS);
+
+       getCertStatusFromStore(SYSTEM_STORE, gNameSystemStr, &status, CERTSVC_SUCCESS);
+       BOOST_CHECK_EQUAL(status, ENABLED);
+
+       certsvc_string_free(gNameStr);
+       certsvc_string_free(gNameSystemStr);
+       freeCertList(certList);
+       certsvc_instance_free(instance);
+}
+
+NEGATIVE_TEST_CASE(T_certsvc_pkcs12_set_certificate_status_to_store)
+{
+       int result;
+       CertStatus invalidStatus = (CertStatus) -1;
+
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+       CertSvcString gNameStr = wrapperCertsvcStringNew(GroupNameTest, &result);
+       BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+       CertSvcString invalidNameStr = wrapperCertsvcStringNew(std::string(), &result);
+       BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+       setCertStatusToStore(NONE_STORE, ENABLED, gNameStr, DISABLED, CERTSVC_INVALID_STORE_TYPE);
+       setCertStatusToStore(WIFI_STORE, ENABLED, gNameStr, invalidStatus, CERTSVC_INVALID_STATUS);
+       setCertStatusToStore(WIFI_STORE, ENABLED, gNameStr, DISABLED, CERTSVC_FAIL);
+       setCertStatusToStore(WIFI_STORE, ENABLED, invalidNameStr, DISABLED, CERTSVC_WRONG_ARGUMENT);
+       setCertStatusToStore(SYSTEM_STORE, ENABLED, gNameStr, DISABLED, CERTSVC_FAIL);
+
+       certsvc_string_free(gNameStr);
+       certsvc_instance_free(instance);
+}
+
+NEGATIVE_TEST_CASE(T_certsvc_pkcs12_get_certificate_status_to_store)
+{
+       int result;
+       CertStatus status = DISABLED;
+
+       BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
+
+       CertSvcString gNameStr = wrapperCertsvcStringNew(GroupNameTest, &result);
+       BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+       CertSvcString invalidNameStr = wrapperCertsvcStringNew(std::string(), &result);
+       BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
+
+       getCertStatusFromStore(NONE_STORE, gNameStr, &status, CERTSVC_INVALID_STORE_TYPE);
+       BOOST_CHECK_EQUAL(status, DISABLED);
+
+       getCertStatusFromStore(WIFI_STORE, invalidNameStr, &status, CERTSVC_WRONG_ARGUMENT);
+       BOOST_CHECK_EQUAL(status, DISABLED);
+
+       getCertStatusFromStore(WIFI_STORE, gNameStr, &status, CERTSVC_FAIL);
+       BOOST_CHECK_EQUAL(status, DISABLED);
+
+       certsvc_string_free(gNameStr);
+       certsvc_instance_free(instance);
+}
+
 POSITIVE_TEST_CASE(T_certsvc_pkcs12_delete_certificate_from_store)
 {
        int result;
@@ -629,7 +916,7 @@ NEGATIVE_TEST_CASE(T_certsvc_pkcs12_delete_certificate_from_invalid_store)
 
        BOOST_REQUIRE_EQUAL(certsvc_instance_new(&instance), CERTSVC_SUCCESS);
 
-       CertSvcString gNameStr = wrapperCertsvcStringNew(GroupNameTest.c_str(), &result);
+       CertSvcString gNameStr = wrapperCertsvcStringNew(GroupNameTest, &result);
        BOOST_CHECK_EQUAL(result, CERTSVC_SUCCESS);
 
        result = certsvc_pkcs12_delete_certificate_from_store(instance, NONE_STORE, gNameStr);
@@ -654,7 +941,7 @@ NEGATIVE_TEST_CASE(T_certsvc_pkcs12_delete_certificate_from_store_wrong_argument
        result = certsvc_pkcs12_delete_certificate_from_store(instance, VPN_STORE, gNameStr);
        BOOST_CHECK_EQUAL(result, CERTSVC_WRONG_ARGUMENT);
 
-       gNameStr = wrapperCertsvcStringNew(GroupNameTest.c_str(), &result);
+       gNameStr = wrapperCertsvcStringNew(GroupNameTest, &result);
 
        result = certsvc_pkcs12_delete_certificate_from_store(instance, VPN_STORE, gNameStr);
        BOOST_CHECK_EQUAL(result, CERTSVC_FAIL);