Add tests for cancel API and ClientRequest classes 47/308547/1
authorYonggoo Kang <ygace.kang@samsung.com>
Wed, 27 Mar 2024 08:10:08 +0000 (17:10 +0900)
committerYonggoo Kang <ygace.kang@samsung.com>
Wed, 27 Mar 2024 08:10:08 +0000 (17:10 +0900)
Change-Id: Id09b9e92a10b06662a556ade657aa2172828280c

tests/client-request-test.cpp
tests/webauthn-client-test.cpp

index 321af87797663291a06027ef43f88e9822707673..d5fe2913cfea375a27d40aaac68b131a2aa88217 100644 (file)
@@ -20,7 +20,8 @@
  */
 
 #include <gtest/gtest.h>
-#include <client-request.h>
+#include <client-request-ga.h>
+#include <client-request-mc.h>
 #include <dl-loader.h>
 #include <service.h>
 #include <socket-manager.h>
@@ -163,6 +164,17 @@ protected:
         // Do deinitialization if needed.
     }
 };
+TEST_F(ClientRequestTest, constructor_P)
+{
+    int ret = 0;
+    try{
+        std::shared_ptr<ClientRequestMC> requestMC = std::make_shared<ClientRequestMC>();
+        std::shared_ptr<ClientRequestGA> requestGA = std::make_shared<ClientRequestGA>();
+    } catch (...) {
+        ret = -1;
+    }
+    EXPECT_EQ(ret, 0);
+}
 
 TEST_F(ClientRequestTest, request_to_not_supported_server_N)
 {
index 7d188e7930ae8fff6e74c745d567ea9945bced03..723df4a7452ea83af99f650add914068badd82ac 100644 (file)
@@ -52,7 +52,7 @@ TEST_F(WebAuthnTest, invalid_client_data_N)
                                  mc_callbacks);
 
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_make_credential] failed. "
+        << "[invalid_client_data_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
 
     ret = WAUTHN_ERROR_NONE;
@@ -65,7 +65,7 @@ TEST_F(WebAuthnTest, invalid_client_data_N)
                                ga_callbacks);
 
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_get_assertion] failed. "
+        << "[invalid_client_data_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
 
     free(mc_callbacks);
@@ -85,7 +85,7 @@ TEST_F(WebAuthnTest, invalid_options_N)
                                  mc_callbacks);
 
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_make_credential] failed. "
+        << "[invalid_options_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
 
     ret = WAUTHN_ERROR_NONE;
@@ -98,7 +98,7 @@ TEST_F(WebAuthnTest, invalid_options_N)
                                ga_callbacks);
 
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_get_assertion] failed. "
+        << "[invalid_options_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
 
     free(mc_callbacks);
@@ -112,7 +112,7 @@ TEST_F(WebAuthnTest, invalid_callbacks_N)
                                  &TestCommonData::pubkeyCredCreationOptions,
                                  nullptr);
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_make_credential] failed. "
+        << "[invalid_callbacks_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
 
     ret = WAUTHN_ERROR_NONE;
@@ -124,7 +124,7 @@ TEST_F(WebAuthnTest, invalid_callbacks_N)
                                  &TestCommonData::pubkeyCredCreationOptions,
                                  mc_callbacks);
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_make_credential] failed. "
+        << "[invalid_callbacks_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
 
     ret = WAUTHN_ERROR_NONE;
@@ -132,7 +132,7 @@ TEST_F(WebAuthnTest, invalid_callbacks_N)
                                &TestCommonData::pubkeyCredRequestOptions,
                                nullptr);
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_get_assertion] failed. "
+        << "[invalid_callbacks_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
 
     ret = WAUTHN_ERROR_NONE;
@@ -144,7 +144,7 @@ TEST_F(WebAuthnTest, invalid_callbacks_N)
                                &TestCommonData::pubkeyCredRequestOptions,
                                ga_callbacks);
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_get_assertion] failed. "
+        << "[invalid_callbacks_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
     free(mc_callbacks);
     free(ga_callbacks);
@@ -161,7 +161,7 @@ TEST_F(WebAuthnTest, miss_qr_callback_without_linked_data_N)
                                  &TestCommonData::pubkeyCredCreationOptionsWithQR,
                                  mc_callbacks);
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_make_credential] failed. "
+        << "[miss_qr_callback_without_linked_data_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
 
     ret = WAUTHN_ERROR_NONE;
@@ -173,10 +173,19 @@ TEST_F(WebAuthnTest, miss_qr_callback_without_linked_data_N)
                                &TestCommonData::pubkeyCredRequestOptionsWithQR,
                                nullptr);
     EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
-        << "[wauthn_get_assertion] failed. "
+        << "[miss_qr_callback_without_linked_data_N] failed. "
         << "ret=" << wauthn_error_to_string(ret) << std::endl;
     free(mc_callbacks);
     free(ga_callbacks);
 }
 
+TEST_F(WebAuthnTest, cancel_not_allowed_N)
+{
+    int ret = WAUTHN_ERROR_NONE;
+    ret = wauthn_cancel();
+    EXPECT_EQ(ret, WAUTHN_ERROR_NOT_ALLOWED)
+        << "[cancel_not_allowed_N] failed. "
+        << "ret=" << wauthn_error_to_string(ret) << std::endl;
+}
+
 } // namespace WA