Fix waiting conditions for update linked data 03/311803/2
authorYonggoo Kang <ygace.kang@samsung.com>
Tue, 28 May 2024 07:07:44 +0000 (16:07 +0900)
committerYonggoo Kang <ygace.kang@samsung.com>
Tue, 28 May 2024 08:28:40 +0000 (17:28 +0900)
Change-Id: I7857495d8b5c223f8f24ab8b2e9cf55dc6c87142

tests/manual/man_tests.cpp

index dba859120b9a565fa81d39658d14064a861ab242..59d36fc21906ed3710ef88fce41a02a360e752db 100644 (file)
@@ -255,7 +255,7 @@ void MCUpdateLinkedDataCallback(const wauthn_hybrid_linked_data_s *linked_data,
                               void *data)
 {
     auto *testContents = static_cast<TestContents *>(data);
-    auto lock = std::unique_lock{testContents->mutex};
+    std::lock_guard<std::mutex> ulock(testContents->mutex);
     if (result != WAUTHN_ERROR_NONE && result != WAUTHN_ERROR_NONE_AND_WAIT) {
         std::cout << __FUNCTION__ << ": failed\n"
                   << "Error code: " << result << std::endl;
@@ -351,6 +351,9 @@ bool Test(struct TestContents &testContents)
 
     std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
 
+    if (ret != WAUTHN_ERROR_NONE)
+        return false;
+
     int timeCount = 120;
     std::cout << "MC: Waiting Authenticate with mobile device for 120 seconds.." << std::endl;
     while (testContents.statusMC == 0 && timeCount != 0) // exit after called Response CB
@@ -360,6 +363,7 @@ bool Test(struct TestContents &testContents)
     }
 
     if (testContents.statusMC != 1) {
+        std::cout << "FAILED: Make Credential" << std::endl;
         return false;
     }
 
@@ -410,7 +414,7 @@ bool Test(struct TestContents &testContents)
 
     wauthn_pubkey_cred_request_options_s gaOptions;
     std::memset(&gaOptions, 0, sizeof(gaOptions)); // For future compatibility.
-    gaOptions.timeout = 60000; // 60s
+    gaOptions.timeout = 120000; // 120s
     gaOptions.rpId = rpId;
     gaOptions.user_verification = UVR_REQUIRED;
     gaOptions.allow_credentials = &pubkeyCredDescriptors;
@@ -430,7 +434,6 @@ bool Test(struct TestContents &testContents)
     ret = wauthn_get_assertion(&clientData, &gaOptions, &gaCallbacks);
     std::cout << "ret: " << wauthn_error_to_string(ret) << std::endl;
 
-
     timeCount = 120;
     std::cout << "GA: Waiting Authenticate with mobile device for 120 seconds.." << std::endl;
     while (testContents.statusGA == 0 && timeCount != 0) // exit after called Response CB
@@ -438,20 +441,21 @@ bool Test(struct TestContents &testContents)
         sleep(1);
         timeCount--;
     }
-
     if (testContents.statusGA != 1) {
+        std::cout << "FAILED: Get Assertion" << std::endl;
         testContents.succeeded = false;
     }
 
     timeCount = 120;
-    std::cout << "Waiting UpdateLinkedDataCallbacks for 120 seconds.." << std::endl;
-    while (testContents.updateGARet != WAUTHN_ERROR_NONE && timeCount != 0)
+    std::cout << "Waiting UpdateLinkedData CBs for 120 seconds.." << std::endl;
+    while (((testContents.statusMC == 1 && testContents.updateMCRet != WAUTHN_ERROR_NONE)
+            || (testContents.statusGA == 1 && testContents.updateGARet != WAUTHN_ERROR_NONE)
+           ) && timeCount != 0)
     {
         sleep(1);
         timeCount--;
     }
 
-
     std::cout << "MC: " << testContents.statusMC << ", GA: " << testContents.statusGA
         << std::endl;
     std::cout << "MCRet: " << testContents.updateMCRet << ", GARet: "