${CMAKE_CURRENT_SOURCE_DIR}/serialization-test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dl-loader-test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/socket-manager-test.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/test-common.cpp
${PRJ_SRC_SERVER_PATH}/dl-loader.cpp
${PRJ_SRC_SERVER_PATH}/service.cpp
* @brief unit tests for socket-manager
*/
-#include "test-common.h"
-
+#include <gtest/gtest.h>
#include <client-request.h>
#include <dl-loader.h>
-#include <socket-manager.h>
-#include <gtest/gtest.h>
-#include <iostream>
#include <service.h>
+#include <socket-manager.h>
+#include "test-common.h"
namespace WA {
-typedef enum __client_request_test_case {
- TC_MC_without_QR_callback_P = 0,
- TC_MC_with_QR_callback_P = 1,
- TC_GA_without_QR_callback_P = 2,
- TC_GA_with_QR_callback_P = 3,
- TC_not_allowed_N = 4,
- TC_cancel_P = 5
-} client_request_test_case_e;
-
-namespace ClientRequestTestData {
- unsigned char clientDataJsonRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char attestationObjectRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorDataRaw[26] = {0x21, 0x22, 0x23, 0x24, };
- unsigned char subjectPubkeyInfoRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_const_buffer_s clientDataJson = {clientDataJsonRaw, sizeof(clientDataJsonRaw)};
- wauthn_const_buffer_s attestationObject = {attestationObjectRaw, sizeof(attestationObjectRaw)};
- unsigned int transports = 3;
- wauthn_const_buffer_s authenticatorData = {authenticatorDataRaw, sizeof(authenticatorDataRaw)};
- wauthn_const_buffer_s subjectPubkeyInfo = {subjectPubkeyInfoRaw, sizeof(subjectPubkeyInfoRaw)};
- wauthn_cose_algorithm_e pubkey_alg = WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256;
- wauthn_authenticator_attestation_response_s authenticatorAttestationResponse
- = {&clientDataJson, &attestationObject, transports, &authenticatorData, &subjectPubkeyInfo, pubkey_alg};
- wauthn_authenticator_attestation_response_s emptyAuthenticatorAttestationResponse
- = {nullptr, nullptr, 0x00, nullptr, nullptr, pubkey_alg};
-
- unsigned char signatureRaw[26] = {0x21, 0x22, 0x23, 0x24, };
- unsigned char userHandleRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_const_buffer_s signature = {signatureRaw, sizeof(signatureRaw)};
- wauthn_const_buffer_s userHandle = {userHandleRaw, sizeof(userHandleRaw)};
- wauthn_authenticator_assertion_response_s authenticatorAssertionResponse
- = {&clientDataJson, &authenticatorData, &signature, &userHandle, &attestationObject};
- wauthn_authenticator_assertion_response_s emptyAuthenticatorAssertionResponse
- = {nullptr, nullptr, nullptr, nullptr, nullptr};
-
- const char *name = "test name";
- const char *id = "test id";
- wauthn_rp_entity_s rpEntity = {name, id};
- wauthn_rp_entity_s emptyRpEntiy = {nullptr, nullptr};
-
- unsigned char idRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_const_buffer_s bufferId = {idRaw, sizeof(idRaw)};
- const char *displayName = "test displayName";
- wauthn_user_entity_s userEntity = {const_cast<char*>(name), &bufferId, const_cast<char*>(displayName)};
- wauthn_user_entity_s emptyUserEntity = {nullptr, nullptr, nullptr};
-
- wauthn_pubkey_cred_type_e pubkeyCredType = PCT_PUBLIC_KEY;
- wauthn_pubkey_cred_param_s credParam0 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
- wauthn_pubkey_cred_param_s credParam1 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512};
- wauthn_pubkey_cred_param_s pubkeyCredParam2[2] = {credParam0, credParam1};
- wauthn_pubkey_cred_params_s pubkeyCredParams2 = {sizeof(pubkeyCredParam2)/sizeof(pubkeyCredParam2[0]), pubkeyCredParam2};
- wauthn_pubkey_cred_param_s pubkeyCredParam1[1] = {credParam0};
- wauthn_pubkey_cred_params_s pubkeyCredParams1 = {sizeof(pubkeyCredParam1)/sizeof(pubkeyCredParam1[0]), pubkeyCredParam1};
- wauthn_pubkey_cred_params_s emptyPubkeyCredParams = {0, nullptr};
-
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor = {pubkeyCredType, &bufferId, 3};
- wauthn_pubkey_cred_descriptor_s emptyPubkeyCredDescriptor = {pubkeyCredType, nullptr, 0};
-
- unsigned char idRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char idRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s bufferId0 = {idRaw0, sizeof(idRaw0)};
- wauthn_const_buffer_s bufferId1 = {idRaw1, sizeof(idRaw1)};
- wauthn_pubkey_cred_descriptor_s credDescriptor0 = {pubkeyCredType, &bufferId0, 3};
- wauthn_pubkey_cred_descriptor_s credDescriptor1 = {pubkeyCredType, &bufferId1, 13};
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor2[2] = {credDescriptor0, credDescriptor1};
- wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors2 = {sizeof(pubkeyCredDescriptor2)/sizeof(pubkeyCredDescriptor2[0]),
- pubkeyCredDescriptor2};
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor1[1] = {credDescriptor0};
- wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors1 = {sizeof(pubkeyCredDescriptor1)/sizeof(pubkeyCredDescriptor1[0]),
- pubkeyCredDescriptor1};
- wauthn_pubkey_cred_descriptors_s emptyPubkeyCredDescriptors = {0, nullptr};
-
- unsigned char extensionIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char extensionValueRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s extensionId = {extensionIdRaw, sizeof(extensionIdRaw)};
- wauthn_const_buffer_s extensionValue = {extensionValueRaw, sizeof(extensionValueRaw)};
- wauthn_authentication_ext_s authenticationExt = {&extensionId, &extensionValue};
- wauthn_authentication_ext_s emptyAuthenticationExt = {nullptr, nullptr};
-
- unsigned char extensionIdRaw1[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char extensionValueRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s extensionId1 = {extensionIdRaw1, sizeof(extensionIdRaw1)};
- wauthn_const_buffer_s extensionValue1 = {extensionValueRaw1, sizeof(extensionValueRaw1)};
- wauthn_authentication_ext_s authenticationExt1 = {&extensionId1, &extensionValue1};
- wauthn_authentication_ext_s authenticationExtArr1[1] = {authenticationExt};
- wauthn_authentication_ext_s authenticationExtArr2[2] = {authenticationExt, authenticationExt1};
- wauthn_authentication_exts_s authenticationExts1 = {sizeof(authenticationExtArr1)/sizeof(authenticationExtArr1[0]),
- authenticationExtArr1};
- wauthn_authentication_exts_s authenticationExts2 = {sizeof(authenticationExtArr2)/sizeof(authenticationExtArr2[0]),
- authenticationExtArr2};
- wauthn_authentication_exts_s emptyAuthenticationExts = {0, nullptr};
-
- wauthn_authenticator_attachment_e attachment = AA_PLATFORM;
- wauthn_resident_key_requirement_e resident_key = RKR_PREFERRED;
- bool require_resident_key = false;
- wauthn_user_verification_requirement_e user_verification = UVR_DISCOURAGED;
- wauthn_authenticator_sel_cri_s authenticatorSelCri = {attachment, resident_key,
- require_resident_key, user_verification};
-
- wauthn_pubkey_cred_hint_e hint0 = PCH_SECURITY_KEY;
- wauthn_pubkey_cred_hint_e hint1 = PCH_CLIENT_DEVICE;
- wauthn_pubkey_cred_hint_e pubkeyCredHint1[1] = {hint0};
- wauthn_pubkey_cred_hint_e pubkeyCredHint2[2] = {hint0, hint1};
- wauthn_pubkey_cred_hints_s pubkeyCredHints1 = {sizeof(pubkeyCredHint1)/sizeof(pubkeyCredHint1[0]), pubkeyCredHint1};
- wauthn_pubkey_cred_hints_s pubkeyCredHints2 = {sizeof(pubkeyCredHint2)/sizeof(pubkeyCredHint2[0]), pubkeyCredHint2};
- wauthn_pubkey_cred_hints_s emptyPubkeyCredHints = {0, nullptr};
-
- unsigned char contactIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char linkIdRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char linkSecretRaw[26] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorPubkeyRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorNameRaw[26] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authPubkeyRaw[36] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char tunnelServerDomainRaw[36] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s contactId = {contactIdRaw, sizeof(contactIdRaw)};
- wauthn_const_buffer_s linkId = {linkIdRaw, sizeof(linkIdRaw)};
- wauthn_const_buffer_s linkSecret = {linkSecretRaw, sizeof(linkSecretRaw)};
- wauthn_const_buffer_s authenticatorPubkey = {authenticatorPubkeyRaw, sizeof(authenticatorPubkeyRaw)};
- wauthn_const_buffer_s authenticatorName = {authenticatorNameRaw, sizeof(authenticatorNameRaw)};
- wauthn_const_buffer_s authPubkey = {authPubkeyRaw, sizeof(authPubkeyRaw)};
- wauthn_const_buffer_s tunnelServerDomain = {tunnelServerDomainRaw, sizeof(tunnelServerDomainRaw)};
- wauthn_hybrid_linked_data_s hybirdLinkedData = {&contactId, &linkId, &linkSecret, &authenticatorPubkey,
- &authenticatorName, &signature, &authPubkey, &tunnelServerDomain};
- wauthn_hybrid_linked_data_s emptyHybirdLinkedData = {nullptr, nullptr, nullptr, nullptr,
- nullptr, nullptr, nullptr, nullptr};
-
- unsigned char bufferRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char bufferRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s buffer0 = {bufferRaw0, sizeof(bufferRaw0)};
- wauthn_const_buffer_s buffer1 = {bufferRaw1, sizeof(bufferRaw1)};
- wauthn_const_buffer_s attestationFormat1[1] = {buffer0};
- wauthn_const_buffer_s attestationFormat2[2] = {buffer0, buffer1};
- wauthn_attestation_formats_s attestationFormats1 = {sizeof(attestationFormat1)/sizeof(attestationFormat1[0]),
- attestationFormat1};
- wauthn_attestation_formats_s attestationFormats2 = {sizeof(attestationFormat2)/sizeof(attestationFormat2[0]),
- attestationFormat2};
- wauthn_attestation_formats_s emptyAttestationFormats = {0, nullptr};
-
- unsigned long timeout = 1000;
- wauthn_attestation_pref_e attestation = AP_DIRECT;
- wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions = {&rpEntity, &userEntity,
- &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
- attestation, &attestationFormats1, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptionsWithQR = {&rpEntity, &userEntity,
- &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
- attestation, &attestationFormats1, &authenticationExts2, nullptr};
- wauthn_pubkey_cred_creation_options_s emptyPubkeyCredCreationOptions = {nullptr, nullptr,
- nullptr, 0, nullptr, nullptr, nullptr, AP_NONE, nullptr, nullptr, nullptr};
-
- const char *rpId = "test RP ID";
- wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptions = {timeout, const_cast<char *>(rpId),
- &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
- &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptionsWithQR = {timeout, const_cast<char *>(rpId),
- &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
- &authenticationExts2, nullptr};
- wauthn_pubkey_cred_request_options_s emptyPubkeyCredRequestOptions = {0, nullptr,
- nullptr, UVR_NONE, nullptr, AP_NONE, nullptr, nullptr, nullptr};
-
- wauthn_pubkey_credential_attestaion_s pubkeyCredentialAttestation = {&bufferId, pubkeyCredType, &bufferId0,
- &authenticatorAttestationResponse, attachment, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_credential_attestaion_s emptyPubkeyCredentialAttestation = {nullptr, pubkeyCredType, nullptr,
- nullptr, attachment, nullptr, nullptr};
-
- wauthn_pubkey_credential_assertion_s pubkeyCredentialAssertion = {&bufferId, pubkeyCredType, &bufferId0,
- &authenticatorAssertionResponse, attachment, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_credential_assertion_s emptyPubkeyCredentialAssertion = {nullptr, pubkeyCredType, nullptr,
- nullptr, attachment, nullptr, nullptr};
-
- wauthn_hash_algorithm_e hashAlg = WAUTHN_HASH_ALGORITHM_SHA_256;
- wauthn_client_data_s clientData = {&bufferId, hashAlg};
- wauthn_client_data_s emptyClientData = {nullptr, hashAlg};
-}
-
class TestClientRequest : public GenericClientRequest {
public:
explicit TestClientRequest(WebAuthnCall action) :
const wauthn_pubkey_cred_creation_options_s *options,
wauthn_mc_callbacks_s *callbacks)
{
- std::cout << "IN wah_make_credential by TestDLLoader" << std::endl;
- if (client_data == NULL)
- std::cout << "client_data is null" << std::endl;
- else
- std::cout << "client_data->hash_alg: " << client_data->hash_alg << std::endl;
-
- if (options == NULL)
- std::cout << "options is null" << std::endl;
- else
- std::cout << "options->timeout,attestation: " << options->timeout <<
- ", " << options->attestation << std::endl;
+ if (client_data == nullptr || options == nullptr)
+ std::cout << "client_data or options is null" << std::endl;
sleep(1);
- if (callbacks->qrcode_callback != nullptr)
- callbacks->qrcode_callback(std::string("FIDO:/TestDLLoader-wah_make_credential").c_str(),
+ if (callbacks != nullptr && callbacks->qrcode_callback != nullptr)
+ callbacks->qrcode_callback(std::string("FIDO:/test_wah_make_credential").c_str(),
callbacks->user_data);
- else
- std::cout << "callbacks->qrcode_callback is null" << std::endl;
sleep(1);
- callbacks->response_callback(nullptr, WAUTHN_ERROR_NONE, callbacks->user_data);
+ if (callbacks != nullptr && callbacks->response_callback != nullptr)
+ callbacks->response_callback(nullptr, WAUTHN_ERROR_NONE, callbacks->user_data);
}
void wah_get_assertion(const wauthn_client_data_s *client_data,
const wauthn_pubkey_cred_request_options_s *options,
wauthn_ga_callbacks_s *callbacks)
{
- std::cout << "IN wah_get_assertion by TestDLLoader" << std::endl;
- if (client_data == NULL)
- std::cout << "client_data is null" << std::endl;
- else
- std::cout << "client_data->hash_alg: " << client_data->hash_alg << std::endl;
-
- if (options == NULL)
- std::cout << "options is null" << std::endl;
- else
- std::cout << "options->timeout,attestation: " << options->timeout <<
- ", " << options->attestation << std::endl;
+ if (client_data == nullptr || options == nullptr)
+ std::cout << "client_data or options is null" << std::endl;
sleep(1);
- if (callbacks->qrcode_callback != nullptr)
- callbacks->qrcode_callback(std::string("FIDO:/TestDLLoader-wah_get_assertion").c_str(),
+ if (callbacks != nullptr && callbacks->qrcode_callback != nullptr)
+ callbacks->qrcode_callback(std::string("FIDO:/test_wah_get_assertion").c_str(),
callbacks->user_data);
sleep(1);
- callbacks->response_callback(nullptr, WAUTHN_ERROR_NONE, callbacks->user_data);
+ if (callbacks != nullptr && callbacks->response_callback != nullptr)
+ callbacks->response_callback(nullptr, WAUTHN_ERROR_NONE, callbacks->user_data);
}
int wah_cancel()
{
- std::cout << "IN wah_cancel by TestDLLoader" << std::endl;
return WAUTHN_ERROR_NONE;
}
std::thread m_thread;
};
-typedef struct _test_user_data_s {
- char *test_data;
- int test_int;
- client_request_test_case_e tc_num;
-} test_user_data_s;
-
-void _client_test_print_user_data(void *user_data)
-{
- std::cout << "user_data is not null, data=" <<
- (static_cast<test_user_data_s*>(user_data))->test_data <<
- ", int=" << (static_cast<test_user_data_s*>(user_data))->test_int <<
- ", tc_num=" << (static_cast<test_user_data_s*>(user_data))->tc_num << std::endl;
-}
-
-void client_request_test_cb_display_qrcode(const char *qr_contents, void *user_data)
-{
- std::cout << "QR Code: " << std::string(qr_contents) << std::endl;
- if (user_data == nullptr)
- std::cout << "user_data is null" << std::endl;
- else
- _client_test_print_user_data(user_data);
-
-}
-void client_request_test_cb_mc_on_response(
- const wauthn_pubkey_credential_attestaion_s *pubkey_cred,
- wauthn_error_e result,
- void *user_data)
-{
- std::cout << "mc response, result: " << wauthn_error_to_string(result) << std::endl;
- if (pubkey_cred == nullptr)
- std::cout << "pubkey_cred is null" << std::endl;
- else
- std::cout << "pubkey_cred is not null: " <<
- pubkey_cred->type << ", " <<
- pubkey_cred->authenticator_attachment << std::endl;
- if (user_data == nullptr)
- std::cout << "user_data is null" << std::endl;
- else
- _client_test_print_user_data(user_data);
-
-}
-
-void client_request_test_cb_ga_on_response(
- const wauthn_pubkey_credential_assertion_s *pubkey_cred,
- wauthn_error_e result,
- void *user_data)
-{
- std::cout << "ga response, result: " << wauthn_error_to_string(result) << std::endl;
- if (pubkey_cred == nullptr)
- std::cout << "pubkey_cred is null" << std::endl;
- else
- std::cout << "pubkey_cred is not null" << std::endl;
- if (user_data == nullptr)
- std::cout << "user_data is null" << std::endl;
- else
- _client_test_print_user_data(user_data);
-}
-
class ClientRequestTest : public ::testing::Test {
protected:
void SetUp() override {
int retVal = WAUTHN_ERROR_NONE;
wauthn_mc_callbacks_s *callbacks = nullptr;
callbacks = (wauthn_mc_callbacks_s*) calloc(1, sizeof(wauthn_mc_callbacks_s));
- callbacks->qrcode_callback = client_request_test_cb_display_qrcode;
- callbacks->response_callback = client_request_test_cb_mc_on_response;
+ callbacks->qrcode_callback = test_cb_display_qrcode;
+ callbacks->response_callback = test_cb_mc_response;
test_user_data_s *userdata = (test_user_data_s*) calloc(1, sizeof(test_user_data_s));
userdata->test_data = (char*)("user data");
userdata->test_int = 999;
- userdata->tc_num = TC_MC_without_QR_callback_P;
callbacks->user_data = userdata;
- retVal = wauthn_process<TestClientRequestMC>(&ClientRequestTestData::clientData,
- &ClientRequestTestData::pubkeyCredCreationOptions, callbacks);
+ retVal = wauthn_process<TestClientRequestMC>(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredCreationOptions, callbacks);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestMC>] failed. "
int retVal = WAUTHN_ERROR_NONE;
wauthn_mc_callbacks_s *callbacks = nullptr;
callbacks = (wauthn_mc_callbacks_s*) calloc(1, sizeof(wauthn_mc_callbacks_s));
- callbacks->qrcode_callback = client_request_test_cb_display_qrcode;
- callbacks->response_callback = client_request_test_cb_mc_on_response;
+ callbacks->qrcode_callback = test_cb_display_qrcode;
+ callbacks->response_callback = test_cb_mc_response;
test_user_data_s *userdata = (test_user_data_s*) calloc(1, sizeof(test_user_data_s));
userdata->test_data = (char*)("user data");
userdata->test_int = 999;
- userdata->tc_num = TC_MC_with_QR_callback_P;
callbacks->user_data = userdata;
- retVal = wauthn_process<TestClientRequestMC>(&ClientRequestTestData::clientData,
- &ClientRequestTestData::pubkeyCredCreationOptionsWithQR, callbacks);
+ retVal = wauthn_process<TestClientRequestMC>(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredCreationOptionsWithQR, callbacks);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestMC>] failed. "
int retVal = WAUTHN_ERROR_NONE;
wauthn_ga_callbacks_s *callbacks = nullptr;
callbacks = (wauthn_ga_callbacks_s*) calloc(1, sizeof(wauthn_ga_callbacks_s));
- callbacks->qrcode_callback = client_request_test_cb_display_qrcode;
- callbacks->response_callback = client_request_test_cb_ga_on_response;
+ callbacks->qrcode_callback = test_cb_display_qrcode;
+ callbacks->response_callback = test_cb_ga_response;
test_user_data_s *userdata = (test_user_data_s*) calloc(1, sizeof(test_user_data_s));
userdata->test_data = (char*)("user data");
userdata->test_int = 999;
- userdata->tc_num = TC_GA_without_QR_callback_P;
callbacks->user_data = userdata;
- retVal = wauthn_process<TestClientRequestGA>(&ClientRequestTestData::clientData,
- &ClientRequestTestData::pubkeyCredRequestOptions, callbacks);
+ retVal = wauthn_process<TestClientRequestGA>(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredRequestOptions, callbacks);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestGA>] failed. "
int retVal = WAUTHN_ERROR_NONE;
wauthn_ga_callbacks_s *callbacks = nullptr;
callbacks = (wauthn_ga_callbacks_s*) calloc(1, sizeof(wauthn_ga_callbacks_s));
- callbacks->qrcode_callback = client_request_test_cb_display_qrcode;
- callbacks->response_callback = client_request_test_cb_ga_on_response;
+ callbacks->qrcode_callback = test_cb_display_qrcode;
+ callbacks->response_callback = test_cb_ga_response;
test_user_data_s *userdata = (test_user_data_s*) calloc(1, sizeof(test_user_data_s));
userdata->test_data = (char*)("user data");
userdata->test_int = 999;
- userdata->tc_num = TC_GA_with_QR_callback_P;
callbacks->user_data = userdata;
- retVal = wauthn_process<TestClientRequestGA>(&ClientRequestTestData::clientData,
- &ClientRequestTestData::pubkeyCredRequestOptionsWithQR, callbacks);
+ retVal = wauthn_process<TestClientRequestGA>(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredRequestOptionsWithQR, callbacks);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestGA>] failed. "
int retVal = WAUTHN_ERROR_NONE;
wauthn_mc_callbacks_s *mc_callbacks = nullptr;
mc_callbacks = (wauthn_mc_callbacks_s*) calloc(1, sizeof(wauthn_mc_callbacks_s));
- mc_callbacks->qrcode_callback = client_request_test_cb_display_qrcode;
- mc_callbacks->response_callback = client_request_test_cb_mc_on_response;
+ mc_callbacks->qrcode_callback = test_cb_display_qrcode;
+ mc_callbacks->response_callback = test_cb_mc_response;
test_user_data_s *mc_userdata = (test_user_data_s*) calloc(1, sizeof(test_user_data_s));
mc_userdata->test_data = (char*)("user data");
mc_userdata->test_int = 999;
- mc_userdata->tc_num = TC_not_allowed_N;
mc_callbacks->user_data = mc_userdata;
- retVal = wauthn_process<TestClientRequestMC>(&ClientRequestTestData::clientData,
- &ClientRequestTestData::pubkeyCredCreationOptions, mc_callbacks);
+ retVal = wauthn_process<TestClientRequestMC>(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredCreationOptions, mc_callbacks);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestMC>] failed. "
wauthn_ga_callbacks_s *ga_callbacks = nullptr;
ga_callbacks = (wauthn_ga_callbacks_s*) calloc(1, sizeof(wauthn_ga_callbacks_s));
- ga_callbacks->qrcode_callback = client_request_test_cb_display_qrcode;
- ga_callbacks->response_callback = client_request_test_cb_ga_on_response;
+ ga_callbacks->qrcode_callback = test_cb_display_qrcode;
+ ga_callbacks->response_callback = test_cb_ga_response;
test_user_data_s *ga_userdata = (test_user_data_s*) calloc(1, sizeof(test_user_data_s));
ga_userdata->test_data = (char*)("user data");
ga_userdata->test_int = 999;
- ga_userdata->tc_num = TC_not_allowed_N;
ga_callbacks->user_data = ga_userdata;
- retVal = wauthn_process<TestClientRequestGA>(&ClientRequestTestData::clientData,
- &ClientRequestTestData::pubkeyCredRequestOptions, ga_callbacks);
+ retVal = wauthn_process<TestClientRequestGA>(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredRequestOptions, ga_callbacks);
EXPECT_EQ(retVal, WAUTHN_ERROR_NOT_ALLOWED)
<< "[wauthn_process<TestClientRequestGA>] failed. "
int retVal = WAUTHN_ERROR_NONE;
wauthn_mc_callbacks_s *mc_callbacks = nullptr;
mc_callbacks = (wauthn_mc_callbacks_s*) calloc(1, sizeof(wauthn_mc_callbacks_s));
- mc_callbacks->qrcode_callback = client_request_test_cb_display_qrcode;
- mc_callbacks->response_callback = client_request_test_cb_mc_on_response;
+ mc_callbacks->qrcode_callback = test_cb_display_qrcode;
+ mc_callbacks->response_callback = test_cb_mc_response;
test_user_data_s *mc_userdata = (test_user_data_s*) calloc(1, sizeof(test_user_data_s));
mc_userdata->test_data = (char*)("user data");
mc_userdata->test_int = 999;
- mc_userdata->tc_num = TC_cancel_P;
mc_callbacks->user_data = mc_userdata;
- retVal = wauthn_process<TestClientRequestMC>(&ClientRequestTestData::clientData,
- &ClientRequestTestData::pubkeyCredCreationOptions, mc_callbacks);
+ retVal = wauthn_process<TestClientRequestMC>(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredCreationOptions, mc_callbacks);
EXPECT_EQ(retVal, WAUTHN_ERROR_NONE)
<< "[wauthn_process<TestClientRequestMC>] failed. "
auto dlLoader = std::make_unique<DLLoader>(WAH_PLUGIN_SO_PATH_HYBRID);
} catch (...)
{
- std::cout << "Error in make_unique DLLoader" << std::endl;
ret = -1;
}
auto dlLoader = std::make_unique<DLLoader>("invalid_so_path");
} catch (...)
{
- std::cout << "Error in make_unique DLLoader" << std::endl;
ret = -1;
}
dlLoader->Invoke<int>(WAH_API_CANCEL);
} catch (...)
{
- std::cout << "Error in make_unique DLLoader" << std::endl;
ret = -1;
}
dlLoader->Invoke<int>("invalid_api_name");
} catch (...)
{
- std::cout << "Error in make_unique DLLoader" << std::endl;
ret = -1;
}
EXPECT_EQ(ret, 1);
}
-TEST_F(FileLockerTest, lock_to_locked_path_N)
+TEST_F(FileLockerTest, lock_to_locked_path_nonblock_P)
{
int ret = 0;
try{
*/
-#include <string>
#include <cstring>
-#include <iostream>
#include <gtest/gtest.h>
+#include <iostream>
+#include <string>
#include <unistd.h>
-#include <webauthn-types.h>
#include <message-buffer.h>
#include <serialization.h>
-
+#include <webauthn-types.h>
+#include "test-common.h"
namespace WA {
-
-namespace SerializationTestData {
- unsigned char clientDataJsonRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char attestationObjectRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorDataRaw[26] = {0x21, 0x22, 0x23, 0x24, };
- unsigned char subjectPubkeyInfoRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_const_buffer_s clientDataJson = {clientDataJsonRaw, sizeof(clientDataJsonRaw)};
- wauthn_const_buffer_s attestationObject = {attestationObjectRaw, sizeof(attestationObjectRaw)};
- unsigned int transports = 3;
- wauthn_const_buffer_s authenticatorData = {authenticatorDataRaw, sizeof(authenticatorDataRaw)};
- wauthn_const_buffer_s subjectPubkeyInfo = {subjectPubkeyInfoRaw, sizeof(subjectPubkeyInfoRaw)};
- wauthn_cose_algorithm_e pubkey_alg = WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256;
- wauthn_authenticator_attestation_response_s authenticatorAttestationResponse
- = {&clientDataJson, &attestationObject, transports, &authenticatorData, &subjectPubkeyInfo, pubkey_alg};
- wauthn_authenticator_attestation_response_s emptyAuthenticatorAttestationResponse
- = {nullptr, nullptr, 0x00, nullptr, nullptr, pubkey_alg};
-
- unsigned char signatureRaw[26] = {0x21, 0x22, 0x23, 0x24, };
- unsigned char userHandleRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_const_buffer_s signature = {signatureRaw, sizeof(signatureRaw)};
- wauthn_const_buffer_s userHandle = {userHandleRaw, sizeof(userHandleRaw)};
- wauthn_authenticator_assertion_response_s authenticatorAssertionResponse
- = {&clientDataJson, &authenticatorData, &signature, &userHandle, &attestationObject};
- wauthn_authenticator_assertion_response_s emptyAuthenticatorAssertionResponse
- = {nullptr, nullptr, nullptr, nullptr, nullptr};
-
- const char *name = "test name";
- const char *id = "test id";
- wauthn_rp_entity_s rpEntity = {name, id};
- wauthn_rp_entity_s emptyRpEntiy = {nullptr, nullptr};
-
- unsigned char idRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_const_buffer_s bufferId = {idRaw, sizeof(idRaw)};
- const char *displayName = "test displayName";
- wauthn_user_entity_s userEntity = {const_cast<char*>(name), &bufferId, const_cast<char*>(displayName)};
- wauthn_user_entity_s emptyUserEntity = {nullptr, nullptr, nullptr};
-
- wauthn_pubkey_cred_type_e pubkeyCredType = PCT_PUBLIC_KEY;
- wauthn_pubkey_cred_param_s credParam0 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
- wauthn_pubkey_cred_param_s credParam1 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512};
- wauthn_pubkey_cred_param_s pubkeyCredParam2[2] = {credParam0, credParam1};
- wauthn_pubkey_cred_params_s pubkeyCredParams2 = {sizeof(pubkeyCredParam2)/sizeof(pubkeyCredParam2[0]), pubkeyCredParam2};
- wauthn_pubkey_cred_param_s pubkeyCredParam1[1] = {credParam0};
- wauthn_pubkey_cred_params_s pubkeyCredParams1 = {sizeof(pubkeyCredParam1)/sizeof(pubkeyCredParam1[0]), pubkeyCredParam1};
- wauthn_pubkey_cred_params_s emptyPubkeyCredParams = {0, nullptr};
-
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor = {pubkeyCredType, &bufferId, 3};
- wauthn_pubkey_cred_descriptor_s emptyPubkeyCredDescriptor = {pubkeyCredType, nullptr, 0};
-
- unsigned char idRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char idRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s bufferId0 = {idRaw0, sizeof(idRaw0)};
- wauthn_const_buffer_s bufferId1 = {idRaw1, sizeof(idRaw1)};
- wauthn_pubkey_cred_descriptor_s credDescriptor0 = {pubkeyCredType, &bufferId0, 3};
- wauthn_pubkey_cred_descriptor_s credDescriptor1 = {pubkeyCredType, &bufferId1, 13};
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor2[2] = {credDescriptor0, credDescriptor1};
- wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors2 = {sizeof(pubkeyCredDescriptor2)/sizeof(pubkeyCredDescriptor2[0]),
- pubkeyCredDescriptor2};
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor1[1] = {credDescriptor0};
- wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors1 = {sizeof(pubkeyCredDescriptor1)/sizeof(pubkeyCredDescriptor1[0]),
- pubkeyCredDescriptor1};
- wauthn_pubkey_cred_descriptors_s emptyPubkeyCredDescriptors = {0, nullptr};
-
- unsigned char extensionIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char extensionValueRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s extensionId = {extensionIdRaw, sizeof(extensionIdRaw)};
- wauthn_const_buffer_s extensionValue = {extensionValueRaw, sizeof(extensionValueRaw)};
- wauthn_authentication_ext_s authenticationExt = {&extensionId, &extensionValue};
- wauthn_authentication_ext_s emptyAuthenticationExt = {nullptr, nullptr};
-
- unsigned char extensionIdRaw1[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char extensionValueRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s extensionId1 = {extensionIdRaw1, sizeof(extensionIdRaw1)};
- wauthn_const_buffer_s extensionValue1 = {extensionValueRaw1, sizeof(extensionValueRaw1)};
- wauthn_authentication_ext_s authenticationExt1 = {&extensionId1, &extensionValue1};
- wauthn_authentication_ext_s authenticationExtArr1[1] = {authenticationExt};
- wauthn_authentication_ext_s authenticationExtArr2[2] = {authenticationExt, authenticationExt1};
- wauthn_authentication_exts_s authenticationExts1 = {sizeof(authenticationExtArr1)/sizeof(authenticationExtArr1[0]),
- authenticationExtArr1};
- wauthn_authentication_exts_s authenticationExts2 = {sizeof(authenticationExtArr2)/sizeof(authenticationExtArr2[0]),
- authenticationExtArr2};
- wauthn_authentication_exts_s emptyAuthenticationExts = {0, nullptr};
-
- wauthn_authenticator_attachment_e attachment = AA_PLATFORM;
- wauthn_resident_key_requirement_e resident_key = RKR_PREFERRED;
- bool require_resident_key = false;
- wauthn_user_verification_requirement_e user_verification = UVR_DISCOURAGED;
- wauthn_authenticator_sel_cri_s authenticatorSelCri = {attachment, resident_key,
- require_resident_key, user_verification};
-
- wauthn_pubkey_cred_hint_e hint0 = PCH_SECURITY_KEY;
- wauthn_pubkey_cred_hint_e hint1 = PCH_CLIENT_DEVICE;
- wauthn_pubkey_cred_hint_e pubkeyCredHint1[1] = {hint0};
- wauthn_pubkey_cred_hint_e pubkeyCredHint2[2] = {hint0, hint1};
- wauthn_pubkey_cred_hints_s pubkeyCredHints1 = {sizeof(pubkeyCredHint1)/sizeof(pubkeyCredHint1[0]), pubkeyCredHint1};
- wauthn_pubkey_cred_hints_s pubkeyCredHints2 = {sizeof(pubkeyCredHint2)/sizeof(pubkeyCredHint2[0]), pubkeyCredHint2};
- wauthn_pubkey_cred_hints_s emptyPubkeyCredHints = {0, nullptr};
-
- unsigned char contactIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char linkIdRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char linkSecretRaw[26] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorPubkeyRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorNameRaw[26] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authPubkeyRaw[36] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char tunnelServerDomainRaw[36] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s contactId = {contactIdRaw, sizeof(contactIdRaw)};
- wauthn_const_buffer_s linkId = {linkIdRaw, sizeof(linkIdRaw)};
- wauthn_const_buffer_s linkSecret = {linkSecretRaw, sizeof(linkSecretRaw)};
- wauthn_const_buffer_s authenticatorPubkey = {authenticatorPubkeyRaw, sizeof(authenticatorPubkeyRaw)};
- wauthn_const_buffer_s authenticatorName = {authenticatorNameRaw, sizeof(authenticatorNameRaw)};
- wauthn_const_buffer_s authPubkey = {authPubkeyRaw, sizeof(authPubkeyRaw)};
- wauthn_const_buffer_s tunnelServerDomain = {tunnelServerDomainRaw, sizeof(tunnelServerDomainRaw)};
- wauthn_hybrid_linked_data_s hybirdLinkedData = {&contactId, &linkId, &linkSecret, &authenticatorPubkey,
- &authenticatorName, &signature, &authPubkey, &tunnelServerDomain};
- wauthn_hybrid_linked_data_s emptyHybirdLinkedData = {nullptr, nullptr, nullptr, nullptr,
- nullptr, nullptr, nullptr, nullptr};
-
- unsigned char bufferRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char bufferRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s buffer0 = {bufferRaw0, sizeof(bufferRaw0)};
- wauthn_const_buffer_s buffer1 = {bufferRaw1, sizeof(bufferRaw1)};
- wauthn_const_buffer_s attestationFormat1[1] = {buffer0};
- wauthn_const_buffer_s attestationFormat2[2] = {buffer0, buffer1};
- wauthn_attestation_formats_s attestationFormats1 = {sizeof(attestationFormat1)/sizeof(attestationFormat1[0]),
- attestationFormat1};
- wauthn_attestation_formats_s attestationFormats2 = {sizeof(attestationFormat2)/sizeof(attestationFormat2[0]),
- attestationFormat2};
- wauthn_attestation_formats_s emptyAttestationFormats = {0, nullptr};
-
- unsigned long timeout = 1000;
- wauthn_attestation_pref_e attestation = AP_DIRECT;
- wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions = {&rpEntity, &userEntity,
- &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
- attestation, &attestationFormats1, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_cred_creation_options_s emptyPubkeyCredCreationOptions = {nullptr, nullptr,
- nullptr, 0, nullptr, nullptr, nullptr, AP_NONE, nullptr, nullptr, nullptr};
-
- const char *rpId = "test RP ID";
- wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptions = {timeout, const_cast<char *>(rpId),
- &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
- &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_cred_request_options_s emptyPubkeyCredRequestOptions = {0, nullptr,
- nullptr, UVR_NONE, nullptr, AP_NONE, nullptr, nullptr, nullptr};
-
- wauthn_pubkey_credential_attestaion_s pubkeyCredentialAttestation = {&bufferId, pubkeyCredType, &bufferId0,
- &authenticatorAttestationResponse, attachment, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_credential_attestaion_s emptyPubkeyCredentialAttestation = {nullptr, pubkeyCredType, nullptr,
- nullptr, attachment, nullptr, nullptr};
-
- wauthn_pubkey_credential_assertion_s pubkeyCredentialAssertion = {&bufferId, pubkeyCredType, &bufferId0,
- &authenticatorAssertionResponse, attachment, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_credential_assertion_s emptyPubkeyCredentialAssertion = {nullptr, pubkeyCredType, nullptr,
- nullptr, attachment, nullptr, nullptr};
-
- wauthn_hash_algorithm_e hashAlg = WAUTHN_HASH_ALGORITHM_SHA_256;
- wauthn_client_data_s clientData = {&bufferId, hashAlg};
- wauthn_client_data_s emptyClientData = {nullptr, hashAlg};
-}
-
class WAuthnSerializationTest : public ::testing::Test {
protected:
void SetUp() override {
EXPECT_EQ(cmpfunction(data, deserialized1), true);
}
-void __fillBufferWithTestData(MessageBuffer& buffer,
+void __fillBufferWithTestCommonData(MessageBuffer& buffer,
size_t struct_size, unsigned char *data, size_t data_size)
{
buffer.InitForStreaming();
unsigned char data[32] = {0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, };
MessageBuffer buffer;
- __fillBufferWithTestData(buffer, MAX_BUFFER_SIZE + 1, data, sizeof(data));
+ __fillBufferWithTestCommonData(buffer, MAX_BUFFER_SIZE + 1, data, sizeof(data));
try {
WAuthnCtypeSerializer::deserialize(buffer, &deserialized);
{
MessageBuffer buffer;
T *deserialized = nullptr;
- __fillBufferWithTestData(buffer, sizeof(T),
+ __fillBufferWithTestCommonData(buffer, sizeof(T),
reinterpret_cast<unsigned char*>(&data), sizeof(T));
try {
const unsigned char *deserialized = nullptr;
size_t deserialized_len = 0;
- __fillBufferWithTestData(buffer, MAX_BUFFER_SIZE + 1, data, sizeof(data));
+ __fillBufferWithTestCommonData(buffer, MAX_BUFFER_SIZE + 1, data, sizeof(data));
try {
WAuthnCtypeSerializer::deserialize(buffer, &deserialized, &deserialized_len);
EXPECT_TRUE(false);
unsigned char data[8] = {0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00};
MessageBuffer buffer;
const char *deserialized = nullptr;
- __fillBufferWithTestData(buffer, sizeof(data), data, sizeof(data));
+ __fillBufferWithTestCommonData(buffer, sizeof(data), data, sizeof(data));
try {
WAuthnCtypeSerializer::deserialize(buffer, &deserialized);
EXPECT_TRUE(false);
{// deserialize: invalid wauthn_error_e
MessageBuffer buffer;
wauthn_error_e deserialized;
- __fillBufferWithTestData(buffer, WAUTHN_ERROR_NONE + 1, nullptr, 0);
+ __fillBufferWithTestCommonData(buffer, WAUTHN_ERROR_NONE + 1, nullptr, 0);
try {
WAuthnCtypeSerializer::deserialize(buffer, &deserialized);
EXPECT_TRUE(false);
}
MessageBuffer buffer1;
- __fillBufferWithTestData(buffer1, WAUTHN_ERROR_CANCELLED - 1, nullptr, 0);
+ __fillBufferWithTestCommonData(buffer1, WAUTHN_ERROR_CANCELLED - 1, nullptr, 0);
try {
WAuthnCtypeSerializer::deserialize(buffer1, &deserialized);
EXPECT_TRUE(false);
TEST_F(WAuthnSerializationTest, wauthn_const_buffer_s_P)
{
- unsigned char testdata[26] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_const_buffer_s buffer = {testdata, sizeof(testdata)};
+ unsigned char TestCommonData[26] = {0x01, 0x02, 0x03, 0x04, };
+ wauthn_const_buffer_s buffer = {TestCommonData, sizeof(TestCommonData)};
__testSerialization(&buffer, __compareWAuthnBuffers);
wauthn_const_buffer_s emptyBuffer = {nullptr, 0x00};
}
TEST_F(WAuthnSerializationTest, wauthn_const_buffer_s_N1)
{// serialize: for too large length
- unsigned char testdata[26] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_const_buffer_s data = {testdata, MAX_BUFFER_SIZE + 1};
+ unsigned char TestCommonData[26] = {0x01, 0x02, 0x03, 0x04, };
+ wauthn_const_buffer_s data = {TestCommonData, MAX_BUFFER_SIZE + 1};
MessageBuffer buffer;
buffer.InitForStreaming();
try {
}
TEST_F(WAuthnSerializationTest, wauthn_const_buffer_s_N2)
{// serialize: for inconsistent pointer & length
- unsigned char testdata[26] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_const_buffer_s data = {nullptr, sizeof(testdata)};
+ unsigned char TestCommonData[26] = {0x01, 0x02, 0x03, 0x04, };
+ wauthn_const_buffer_s data = {nullptr, sizeof(TestCommonData)};
MessageBuffer buffer;
buffer.InitForStreaming();
try {
}
TEST_F(WAuthnSerializationTest, wauthn_authenticator_attestation_response_s_P)
{
- __testSerialization(&SerializationTestData::authenticatorAttestationResponse,
+ __testSerialization(&TestCommonData::authenticatorAttestationResponse,
__compareWAuthnAuthenticatorAttestationResponseS);
- __testSerialization(&SerializationTestData::emptyAuthenticatorAttestationResponse,
+ __testSerialization(&TestCommonData::emptyAuthenticatorAttestationResponse,
__compareWAuthnAuthenticatorAttestationResponseS);
__testSerialization(static_cast<wauthn_authenticator_attestation_response_s *>(nullptr),
__compareWAuthnAuthenticatorAttestationResponseS);
}
TEST_F(WAuthnSerializationTest, wauthn_authenticator_assertion_response_s_P)
{
- __testSerialization(&SerializationTestData::authenticatorAssertionResponse,
+ __testSerialization(&TestCommonData::authenticatorAssertionResponse,
__compareWAuthnAuthenticatorAssertionResponseS);
- __testSerialization(&SerializationTestData::emptyAuthenticatorAssertionResponse,
+ __testSerialization(&TestCommonData::emptyAuthenticatorAssertionResponse,
__compareWAuthnAuthenticatorAssertionResponseS);
__testSerialization(static_cast<wauthn_authenticator_assertion_response_s *>(nullptr),
__compareWAuthnAuthenticatorAssertionResponseS);
}
TEST_F(WAuthnSerializationTest, wauthn_rp_entity_s_P)
{
- __testSerialization(&SerializationTestData::rpEntity, __compareWAuthnRpEntityS);
- __testSerialization(&SerializationTestData::emptyRpEntiy, __compareWAuthnRpEntityS);
+ __testSerialization(&TestCommonData::rpEntity, __compareWAuthnRpEntityS);
+ __testSerialization(&TestCommonData::emptyRpEntiy, __compareWAuthnRpEntityS);
__testSerialization(static_cast<wauthn_rp_entity_s *>(nullptr), __compareWAuthnRpEntityS);
}
TEST_F(WAuthnSerializationTest, wauthn_rp_entity_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_user_entity_s_P)
{
- __testSerialization(&SerializationTestData::userEntity, __compareWAuthnUserEntityS);
- __testSerialization(&SerializationTestData::emptyUserEntity, __compareWAuthnUserEntityS);
+ __testSerialization(&TestCommonData::userEntity, __compareWAuthnUserEntityS);
+ __testSerialization(&TestCommonData::emptyUserEntity, __compareWAuthnUserEntityS);
__testSerialization(static_cast<wauthn_user_entity_s *>(nullptr), __compareWAuthnUserEntityS);
}
TEST_F(WAuthnSerializationTest, wauthn_user_entity_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_params_s_P)
{
- __testSerialization(&SerializationTestData::pubkeyCredParams2, __compareWAuthnPubkeyCredParamsS);
- __testSerialization(&SerializationTestData::pubkeyCredParams1, __compareWAuthnPubkeyCredParamsS);
- __testSerialization(&SerializationTestData::emptyPubkeyCredParams, __compareWAuthnPubkeyCredParamsS);
+ __testSerialization(&TestCommonData::pubkeyCredParams2, __compareWAuthnPubkeyCredParamsS);
+ __testSerialization(&TestCommonData::pubkeyCredParams1, __compareWAuthnPubkeyCredParamsS);
+ __testSerialization(&TestCommonData::emptyPubkeyCredParams, __compareWAuthnPubkeyCredParamsS);
__testSerialization(static_cast<wauthn_pubkey_cred_params_s *>(nullptr), __compareWAuthnPubkeyCredParamsS);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_params_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_params_s_N2)
{// deserialize: for too large array count
- wauthn_pubkey_cred_params_s data = {MAX_ARRAY_COUNT + 1, SerializationTestData::pubkeyCredParam2};
+ wauthn_pubkey_cred_params_s data = {MAX_ARRAY_COUNT + 1, TestCommonData::pubkeyCredParam2};
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_params_s_N3)
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_descriptor_s_P)
{
- __testSerialization(&SerializationTestData::pubkeyCredDescriptor, __compareWAuthnPubkeyCredDescriptorS);
- __testSerialization(&SerializationTestData::emptyPubkeyCredDescriptor, __compareWAuthnPubkeyCredDescriptorS);
+ __testSerialization(&TestCommonData::pubkeyCredDescriptor, __compareWAuthnPubkeyCredDescriptorS);
+ __testSerialization(&TestCommonData::emptyPubkeyCredDescriptor, __compareWAuthnPubkeyCredDescriptorS);
__testSerialization(static_cast<wauthn_pubkey_cred_descriptor_s *>(nullptr), __compareWAuthnPubkeyCredDescriptorS);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_descriptor_s_N1)
{// serialize: invalid member
- wauthn_pubkey_cred_descriptor_s data = SerializationTestData::pubkeyCredDescriptor;
+ wauthn_pubkey_cred_descriptor_s data = TestCommonData::pubkeyCredDescriptor;
data.type = static_cast<wauthn_pubkey_cred_type_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_descriptors_s_P)
{
- __testSerialization(&SerializationTestData::pubkeyCredDescriptors2, __compareWAuthnPubkeyCredDescriptorsS);
- __testSerialization(&SerializationTestData::pubkeyCredDescriptors1, __compareWAuthnPubkeyCredDescriptorsS);
- __testSerialization(&SerializationTestData::emptyPubkeyCredDescriptors, __compareWAuthnPubkeyCredDescriptorsS);
+ __testSerialization(&TestCommonData::pubkeyCredDescriptors2, __compareWAuthnPubkeyCredDescriptorsS);
+ __testSerialization(&TestCommonData::pubkeyCredDescriptors1, __compareWAuthnPubkeyCredDescriptorsS);
+ __testSerialization(&TestCommonData::emptyPubkeyCredDescriptors, __compareWAuthnPubkeyCredDescriptorsS);
__testSerialization(static_cast<wauthn_pubkey_cred_descriptors_s *>(nullptr), __compareWAuthnPubkeyCredDescriptorsS);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_descriptors_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_descriptors_s_N2)
{// deserialize: for too large array count
- wauthn_pubkey_cred_descriptors_s data = {MAX_ARRAY_COUNT + 1, SerializationTestData::pubkeyCredDescriptor2};
+ wauthn_pubkey_cred_descriptors_s data = {MAX_ARRAY_COUNT + 1, TestCommonData::pubkeyCredDescriptor2};
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_descriptors_s_N3)
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_descriptors_s_N4)
{// deserialize: for invalid type
wauthn_pubkey_cred_descriptor_s data = {static_cast<wauthn_pubkey_cred_type_e>(0x00FFFFFF),
- &SerializationTestData::clientDataJson, 3};
+ &TestCommonData::clientDataJson, 3};
__testDeserializeInvalidMember(data);
}
}
TEST_F(WAuthnSerializationTest, wauthn_authentication_ext_s_P)
{
- __testSerialization(&SerializationTestData::authenticationExt, __compareWAuthnAuthenticationExtS);
- __testSerialization(&SerializationTestData::emptyAuthenticationExt, __compareWAuthnAuthenticationExtS);
+ __testSerialization(&TestCommonData::authenticationExt, __compareWAuthnAuthenticationExtS);
+ __testSerialization(&TestCommonData::emptyAuthenticationExt, __compareWAuthnAuthenticationExtS);
__testSerialization(static_cast<wauthn_authentication_ext_s *>(nullptr), __compareWAuthnAuthenticationExtS);
}
TEST_F(WAuthnSerializationTest, wauthn_authentication_ext_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_authentication_exts_s_P)
{
- __testSerialization(&SerializationTestData::authenticationExts1, __compareWAuthnAuthenticationExtsS);
- __testSerialization(&SerializationTestData::authenticationExts2, __compareWAuthnAuthenticationExtsS);
- __testSerialization(&SerializationTestData::emptyAuthenticationExts, __compareWAuthnAuthenticationExtsS);
+ __testSerialization(&TestCommonData::authenticationExts1, __compareWAuthnAuthenticationExtsS);
+ __testSerialization(&TestCommonData::authenticationExts2, __compareWAuthnAuthenticationExtsS);
+ __testSerialization(&TestCommonData::emptyAuthenticationExts, __compareWAuthnAuthenticationExtsS);
__testSerialization(static_cast<wauthn_authentication_exts_s *>(nullptr), __compareWAuthnAuthenticationExtsS);
}
TEST_F(WAuthnSerializationTest, wauthn_authentication_exts_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_authentication_exts_s_N2)
{// deserialize: for too large array count
- wauthn_authentication_exts_s data = {MAX_ARRAY_COUNT + 1, SerializationTestData::authenticationExtArr2};
+ wauthn_authentication_exts_s data = {MAX_ARRAY_COUNT + 1, TestCommonData::authenticationExtArr2};
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, wauthn_authentication_exts_s_N3)
}
TEST_F(WAuthnSerializationTest, wauthn_authenticator_sel_cri_s_P)
{
- __testSerialization(&SerializationTestData::authenticatorSelCri, __compareWAuthnAuthenticatorSelCriS);
+ __testSerialization(&TestCommonData::authenticatorSelCri, __compareWAuthnAuthenticatorSelCriS);
__testSerialization(static_cast<wauthn_authenticator_sel_cri_s *>(nullptr), __compareWAuthnAuthenticatorSelCriS);
}
TEST_F(WAuthnSerializationTest, wauthn_authenticator_sel_cri_s_N1)
{// serialize: invalid member
- wauthn_authenticator_sel_cri_s data1 = SerializationTestData::authenticatorSelCri;
+ wauthn_authenticator_sel_cri_s data1 = TestCommonData::authenticatorSelCri;
data1.attachment = static_cast<wauthn_authenticator_attachment_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data1);
- wauthn_authenticator_sel_cri_s data2 = SerializationTestData::authenticatorSelCri;
+ wauthn_authenticator_sel_cri_s data2 = TestCommonData::authenticatorSelCri;
data2.resident_key = static_cast<wauthn_resident_key_requirement_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data2);
- wauthn_authenticator_sel_cri_s data3 = SerializationTestData::authenticatorSelCri;
+ wauthn_authenticator_sel_cri_s data3 = TestCommonData::authenticatorSelCri;
data3.user_verification = static_cast<wauthn_user_verification_requirement_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data3);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_hints_s_P)
{
- __testSerialization(&SerializationTestData::pubkeyCredHints1, __compareWAuthnPubkeyCredHintsE);
- __testSerialization(&SerializationTestData::pubkeyCredHints2, __compareWAuthnPubkeyCredHintsE);
- __testSerialization(&SerializationTestData::emptyPubkeyCredHints, __compareWAuthnPubkeyCredHintsE);
+ __testSerialization(&TestCommonData::pubkeyCredHints1, __compareWAuthnPubkeyCredHintsE);
+ __testSerialization(&TestCommonData::pubkeyCredHints2, __compareWAuthnPubkeyCredHintsE);
+ __testSerialization(&TestCommonData::emptyPubkeyCredHints, __compareWAuthnPubkeyCredHintsE);
__testSerialization(static_cast<wauthn_pubkey_cred_hints_s *>(nullptr), __compareWAuthnPubkeyCredHintsE);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_hints_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_hints_s_N2)
{// deserialize: for too large array count
- wauthn_pubkey_cred_hints_s data = {MAX_ARRAY_COUNT + 1, SerializationTestData::pubkeyCredHint2};
+ wauthn_pubkey_cred_hints_s data = {MAX_ARRAY_COUNT + 1, TestCommonData::pubkeyCredHint2};
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_hints_s_N3)
}
TEST_F(WAuthnSerializationTest, wauthn_hybrid_linked_data_s_P)
{
- __testSerialization(&SerializationTestData::hybirdLinkedData, __compareWAuthnHybridLinkedDataS);
- __testSerialization(&SerializationTestData::emptyHybirdLinkedData, __compareWAuthnHybridLinkedDataS);
+ __testSerialization(&TestCommonData::hybirdLinkedData, __compareWAuthnHybridLinkedDataS);
+ __testSerialization(&TestCommonData::emptyHybirdLinkedData, __compareWAuthnHybridLinkedDataS);
__testSerialization(static_cast<wauthn_hybrid_linked_data_s *>(nullptr), __compareWAuthnHybridLinkedDataS);
}
TEST_F(WAuthnSerializationTest, wauthn_hybrid_linked_data_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_attestation_formats_s_P)
{
- __testSerialization(&SerializationTestData::attestationFormats1, __compareWAuthnAttestationFormatsS);
- __testSerialization(&SerializationTestData::attestationFormats2, __compareWAuthnAttestationFormatsS);
- __testSerialization(&SerializationTestData::emptyAttestationFormats, __compareWAuthnAttestationFormatsS);
+ __testSerialization(&TestCommonData::attestationFormats1, __compareWAuthnAttestationFormatsS);
+ __testSerialization(&TestCommonData::attestationFormats2, __compareWAuthnAttestationFormatsS);
+ __testSerialization(&TestCommonData::emptyAttestationFormats, __compareWAuthnAttestationFormatsS);
__testSerialization(static_cast<wauthn_attestation_formats_s *>(nullptr), __compareWAuthnAttestationFormatsS);
}
TEST_F(WAuthnSerializationTest, wauthn_attestation_formats_s_N1)
}
TEST_F(WAuthnSerializationTest, wauthn_attestation_formats_s_N2)
{// deserialize: for too large array count
- wauthn_attestation_formats_s data = {MAX_ARRAY_COUNT + 1, SerializationTestData::attestationFormat2};
+ wauthn_attestation_formats_s data = {MAX_ARRAY_COUNT + 1, TestCommonData::attestationFormat2};
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, wauthn_attestation_formats_s_N3)
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_creation_options_s_P)
{
- __testSerialization(&SerializationTestData::pubkeyCredCreationOptions,
+ __testSerialization(&TestCommonData::pubkeyCredCreationOptions,
__compareWAuthnPubkeyCredCreationOptionsS);
- __testSerialization(&SerializationTestData::emptyPubkeyCredCreationOptions,
+ __testSerialization(&TestCommonData::emptyPubkeyCredCreationOptions,
__compareWAuthnPubkeyCredCreationOptionsS);
__testSerialization(static_cast<wauthn_pubkey_cred_creation_options_s *>(nullptr),
__compareWAuthnPubkeyCredCreationOptionsS);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_creation_options_s_N1)
{// serialize: invalid member
- wauthn_pubkey_cred_creation_options_s data = SerializationTestData::pubkeyCredCreationOptions;
+ wauthn_pubkey_cred_creation_options_s data = TestCommonData::pubkeyCredCreationOptions;
data.attestation = static_cast<wauthn_attestation_pref_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_creation_options_s_N3)
{// deserialize: for invalid attestation
- wauthn_pubkey_cred_creation_options_s data = SerializationTestData::pubkeyCredCreationOptions;
+ wauthn_pubkey_cred_creation_options_s data = TestCommonData::pubkeyCredCreationOptions;
data.attestation = static_cast<wauthn_attestation_pref_e>(0x00FFFFFF);
__testDeserializeInvalidMember(data);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_request_options_s_P)
{
- __testSerialization(&SerializationTestData::pubkeyCredRequestOptions,
+ __testSerialization(&TestCommonData::pubkeyCredRequestOptions,
__compareWAuthnPubkeyCredRequestOptionsS);
- __testSerialization(&SerializationTestData::emptyPubkeyCredRequestOptions,
+ __testSerialization(&TestCommonData::emptyPubkeyCredRequestOptions,
__compareWAuthnPubkeyCredRequestOptionsS);
__testSerialization(static_cast<wauthn_pubkey_cred_request_options_s *>(nullptr),
__compareWAuthnPubkeyCredRequestOptionsS);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_request_options_s_N1)
{// serialize: invalid member
- wauthn_pubkey_cred_request_options_s data1 = SerializationTestData::pubkeyCredRequestOptions;
+ wauthn_pubkey_cred_request_options_s data1 = TestCommonData::pubkeyCredRequestOptions;
data1.user_verification = static_cast<wauthn_user_verification_requirement_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data1);
- wauthn_pubkey_cred_request_options_s data2 = SerializationTestData::pubkeyCredRequestOptions;
+ wauthn_pubkey_cred_request_options_s data2 = TestCommonData::pubkeyCredRequestOptions;
data2.attestation = static_cast<wauthn_attestation_pref_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data2);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_request_options_s_N3)
{// deserialize: for invalid attestation
- wauthn_pubkey_cred_request_options_s data = SerializationTestData::pubkeyCredRequestOptions;
+ wauthn_pubkey_cred_request_options_s data = TestCommonData::pubkeyCredRequestOptions;
data.user_verification = static_cast<wauthn_user_verification_requirement_e>(0x00FFFFFF);
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_cred_request_options_s_N4)
{// deserialize: for invalid attestation
- wauthn_pubkey_cred_request_options_s data = SerializationTestData::pubkeyCredRequestOptions;
+ wauthn_pubkey_cred_request_options_s data = TestCommonData::pubkeyCredRequestOptions;
data.attestation = static_cast<wauthn_attestation_pref_e>(0x00FFFFFF);
__testDeserializeInvalidMember(data);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_credential_attestaion_s_P)
{
- __testSerialization(&SerializationTestData::pubkeyCredentialAttestation,
+ __testSerialization(&TestCommonData::pubkeyCredentialAttestation,
__compareWAuthnPubkeyCredentialAttestionS);
- __testSerialization(&SerializationTestData::emptyPubkeyCredentialAttestation,
+ __testSerialization(&TestCommonData::emptyPubkeyCredentialAttestation,
__compareWAuthnPubkeyCredentialAttestionS);
__testSerialization(static_cast<wauthn_pubkey_credential_attestaion_s *>(nullptr),
__compareWAuthnPubkeyCredentialAttestionS);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_credential_attestaion_s_N1)
{// serialize: invalid member
- wauthn_pubkey_credential_attestaion_s data1 = SerializationTestData::pubkeyCredentialAttestation;
+ wauthn_pubkey_credential_attestaion_s data1 = TestCommonData::pubkeyCredentialAttestation;
data1.type = static_cast<wauthn_pubkey_cred_type_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data1);
- wauthn_pubkey_credential_attestaion_s data2 = SerializationTestData::pubkeyCredentialAttestation;
+ wauthn_pubkey_credential_attestaion_s data2 = TestCommonData::pubkeyCredentialAttestation;
data2.authenticator_attachment = static_cast<wauthn_authenticator_attachment_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data2);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_credential_attestaion_s_N3)
{// deserialize: for invalid type
- wauthn_pubkey_credential_attestaion_s data = SerializationTestData::pubkeyCredentialAttestation;
+ wauthn_pubkey_credential_attestaion_s data = TestCommonData::pubkeyCredentialAttestation;
data.type = static_cast<wauthn_pubkey_cred_type_e>(0x00FFFFFF);
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_credential_attestaion_s_N4)
{// deserialize: for invalid authenticator_attachment
- wauthn_pubkey_credential_attestaion_s data = SerializationTestData::pubkeyCredentialAttestation;
+ wauthn_pubkey_credential_attestaion_s data = TestCommonData::pubkeyCredentialAttestation;
data.authenticator_attachment = static_cast<wauthn_authenticator_attachment_e>(0x00FFFFFF);
__testDeserializeInvalidMember(data);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_credential_assertion_s_P)
{
- __testSerialization(&SerializationTestData::pubkeyCredentialAssertion,
+ __testSerialization(&TestCommonData::pubkeyCredentialAssertion,
__compareWAuthnPubkeyCredentialAssertionS);
- __testSerialization(&SerializationTestData::emptyPubkeyCredentialAssertion,
+ __testSerialization(&TestCommonData::emptyPubkeyCredentialAssertion,
__compareWAuthnPubkeyCredentialAssertionS);
__testSerialization(static_cast<wauthn_pubkey_credential_assertion_s *>(nullptr),
__compareWAuthnPubkeyCredentialAssertionS);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_credential_assertion_s_N1)
{// serialize: invalid member
- wauthn_pubkey_credential_assertion_s data1 = SerializationTestData::pubkeyCredentialAssertion;
+ wauthn_pubkey_credential_assertion_s data1 = TestCommonData::pubkeyCredentialAssertion;
data1.type = static_cast<wauthn_pubkey_cred_type_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data1);
- wauthn_pubkey_credential_assertion_s data2 = SerializationTestData::pubkeyCredentialAssertion;
+ wauthn_pubkey_credential_assertion_s data2 = TestCommonData::pubkeyCredentialAssertion;
data2.authenticator_attachment = static_cast<wauthn_authenticator_attachment_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data2);
}
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_credential_assertion_s_N3)
{// deserialize: for invalid type
- wauthn_pubkey_credential_assertion_s data = SerializationTestData::pubkeyCredentialAssertion;
+ wauthn_pubkey_credential_assertion_s data = TestCommonData::pubkeyCredentialAssertion;
data.type = static_cast<wauthn_pubkey_cred_type_e>(0x00FFFFFF);
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, wauthn_pubkey_credential_assertion_s_N4)
{// deserialize: for invalid authenticator_attachment
- wauthn_pubkey_credential_assertion_s data = SerializationTestData::pubkeyCredentialAssertion;
+ wauthn_pubkey_credential_assertion_s data = TestCommonData::pubkeyCredentialAssertion;
data.authenticator_attachment = static_cast<wauthn_authenticator_attachment_e>(0x00FFFFFF);
__testDeserializeInvalidMember(data);
}
}
TEST_F(WAuthnSerializationTest, wauthn_client_data_s_P)
{
- __testSerialization(&SerializationTestData::clientData, __compareWAuthnClientDataS);
- __testSerialization(&SerializationTestData::emptyClientData, __compareWAuthnClientDataS);
+ __testSerialization(&TestCommonData::clientData, __compareWAuthnClientDataS);
+ __testSerialization(&TestCommonData::emptyClientData, __compareWAuthnClientDataS);
__testSerialization(static_cast<wauthn_client_data_s *>(nullptr), __compareWAuthnClientDataS);
}
TEST_F(WAuthnSerializationTest, wauthn_client_data_s_N1)
{// serialize: invalid member
- wauthn_client_data_s data = SerializationTestData::clientData;
+ wauthn_client_data_s data = TestCommonData::clientData;
data.hash_alg = static_cast<wauthn_hash_algorithm_e>(0x00FFFFFF);
__testSerializeForInvalidMember(&data);
}
}
TEST_F(WAuthnSerializationTest, wauthn_client_data_s_N3)
{// deserialize: for invalid authenticator_attachment
- wauthn_client_data_s data = SerializationTestData::clientData;
+ wauthn_client_data_s data = TestCommonData::clientData;
data.hash_alg = static_cast<wauthn_hash_algorithm_e>(0x00FFFFFF);
__testDeserializeInvalidMember(data);
}
TEST_F(WAuthnSerializationTest, multiple_serialization_mcreq_P)
{
- wauthn_client_data_s *client_data = &SerializationTestData::clientData;
- wauthn_pubkey_cred_creation_options_s *options = &SerializationTestData::pubkeyCredCreationOptions;
+ wauthn_client_data_s *client_data = &TestCommonData::clientData;
+ wauthn_pubkey_cred_creation_options_s *options = &TestCommonData::pubkeyCredCreationOptions;
__testMultipleSerialization(client_data, options,
__compareWAuthnClientDataS, __compareWAuthnPubkeyCredCreationOptionsS);
TEST_F(WAuthnSerializationTest, multiple_serialization_gareq_P)
{
- wauthn_client_data_s *client_data = &SerializationTestData::clientData;
- wauthn_pubkey_cred_request_options_s *options = &SerializationTestData::pubkeyCredRequestOptions;
+ wauthn_client_data_s *client_data = &TestCommonData::clientData;
+ wauthn_pubkey_cred_request_options_s *options = &TestCommonData::pubkeyCredRequestOptions;
__testMultipleSerialization(client_data, options,
__compareWAuthnClientDataS, __compareWAuthnPubkeyCredRequestOptionsS);
TEST_F(WAuthnSerializationTest, multiple_serialization_mcres_P)
{
- wauthn_pubkey_credential_attestaion_s *pubkeyCred = &SerializationTestData::pubkeyCredentialAttestation;
+ wauthn_pubkey_credential_attestaion_s *pubkeyCred = &TestCommonData::pubkeyCredentialAttestation;
wauthn_error_e result = WAUTHN_ERROR_PERMISSION_DENIED;
__testMultipleSerializationWAuthErrorE(pubkeyCred, result,
TEST_F(WAuthnSerializationTest, multiple_serialization_gares_P)
{
- wauthn_pubkey_credential_assertion_s *pubkeyCred = &SerializationTestData::pubkeyCredentialAssertion;
+ wauthn_pubkey_credential_assertion_s *pubkeyCred = &TestCommonData::pubkeyCredentialAssertion;
wauthn_error_e result = WAUTHN_ERROR_CANCELLED;
__testMultipleSerializationWAuthErrorE(pubkeyCred, result,
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ *
+ *
+ * @file test-common.h
+ * @version 1.0
+ * @brief common header for test
+ */
+
+#include "test-common.h"
+
+namespace WA {
+
+namespace TestCommonData {
+ unsigned char clientDataJsonRaw[06] = {0x01, 0x02, 0x03, 0x04, };
+ unsigned char attestationObjectRaw[16] = {0x11, 0x12, 0x13, 0x14, };
+ unsigned char authenticatorDataRaw[26] = {0x21, 0x22, 0x23, 0x24, };
+ unsigned char subjectPubkeyInfoRaw[36] = {0x31, 0x32, 0x33, 0x34, };
+ wauthn_const_buffer_s clientDataJson = {clientDataJsonRaw, sizeof(clientDataJsonRaw)};
+ wauthn_const_buffer_s attestationObject = {attestationObjectRaw, sizeof(attestationObjectRaw)};
+ unsigned int transports = 3;
+ wauthn_const_buffer_s authenticatorData = {authenticatorDataRaw, sizeof(authenticatorDataRaw)};
+ wauthn_const_buffer_s subjectPubkeyInfo = {subjectPubkeyInfoRaw, sizeof(subjectPubkeyInfoRaw)};
+ wauthn_cose_algorithm_e pubkey_alg = WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256;
+ wauthn_authenticator_attestation_response_s authenticatorAttestationResponse
+ = {&clientDataJson, &attestationObject, transports, &authenticatorData, &subjectPubkeyInfo, pubkey_alg};
+ wauthn_authenticator_attestation_response_s emptyAuthenticatorAttestationResponse
+ = {nullptr, nullptr, 0x00, nullptr, nullptr, pubkey_alg};
+
+ unsigned char signatureRaw[26] = {0x21, 0x22, 0x23, 0x24, };
+ unsigned char userHandleRaw[36] = {0x31, 0x32, 0x33, 0x34, };
+ wauthn_const_buffer_s signature = {signatureRaw, sizeof(signatureRaw)};
+ wauthn_const_buffer_s userHandle = {userHandleRaw, sizeof(userHandleRaw)};
+ wauthn_authenticator_assertion_response_s authenticatorAssertionResponse
+ = {&clientDataJson, &authenticatorData, &signature, &userHandle, &attestationObject};
+ wauthn_authenticator_assertion_response_s emptyAuthenticatorAssertionResponse
+ = {nullptr, nullptr, nullptr, nullptr, nullptr};
+
+ const char *name = "test name";
+ const char *id = "test id";
+ wauthn_rp_entity_s rpEntity = {name, id};
+ wauthn_rp_entity_s emptyRpEntiy = {nullptr, nullptr};
+
+ unsigned char idRaw[06] = {0x01, 0x02, 0x03, 0x04, };
+ wauthn_const_buffer_s bufferId = {idRaw, sizeof(idRaw)};
+ const char *displayName = "test displayName";
+ wauthn_user_entity_s userEntity = {const_cast<char*>(name), &bufferId, const_cast<char*>(displayName)};
+ wauthn_user_entity_s emptyUserEntity = {nullptr, nullptr, nullptr};
+
+ wauthn_pubkey_cred_type_e pubkeyCredType = PCT_PUBLIC_KEY;
+ wauthn_pubkey_cred_param_s credParam0 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
+ wauthn_pubkey_cred_param_s credParam1 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512};
+ wauthn_pubkey_cred_param_s pubkeyCredParam2[2] = {credParam0, credParam1};
+ wauthn_pubkey_cred_params_s pubkeyCredParams2 = {sizeof(pubkeyCredParam2)/sizeof(pubkeyCredParam2[0]), pubkeyCredParam2};
+ wauthn_pubkey_cred_param_s pubkeyCredParam1[1] = {credParam0};
+ wauthn_pubkey_cred_params_s pubkeyCredParams1 = {sizeof(pubkeyCredParam1)/sizeof(pubkeyCredParam1[0]), pubkeyCredParam1};
+ wauthn_pubkey_cred_params_s emptyPubkeyCredParams = {0, nullptr};
+
+ wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor = {pubkeyCredType, &bufferId, 3};
+ wauthn_pubkey_cred_descriptor_s emptyPubkeyCredDescriptor = {pubkeyCredType, nullptr, 0};
+
+ unsigned char idRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
+ unsigned char idRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
+ wauthn_const_buffer_s bufferId0 = {idRaw0, sizeof(idRaw0)};
+ wauthn_const_buffer_s bufferId1 = {idRaw1, sizeof(idRaw1)};
+ wauthn_pubkey_cred_descriptor_s credDescriptor0 = {pubkeyCredType, &bufferId0, 3};
+ wauthn_pubkey_cred_descriptor_s credDescriptor1 = {pubkeyCredType, &bufferId1, 13};
+ wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor2[2] = {credDescriptor0, credDescriptor1};
+ wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors2 = {sizeof(pubkeyCredDescriptor2)/sizeof(pubkeyCredDescriptor2[0]),
+ pubkeyCredDescriptor2};
+ wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor1[1] = {credDescriptor0};
+ wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors1 = {sizeof(pubkeyCredDescriptor1)/sizeof(pubkeyCredDescriptor1[0]),
+ pubkeyCredDescriptor1};
+ wauthn_pubkey_cred_descriptors_s emptyPubkeyCredDescriptors = {0, nullptr};
+
+ unsigned char extensionIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
+ unsigned char extensionValueRaw[16] = {0x11, 0x12, 0x13, 0x14, };
+ wauthn_const_buffer_s extensionId = {extensionIdRaw, sizeof(extensionIdRaw)};
+ wauthn_const_buffer_s extensionValue = {extensionValueRaw, sizeof(extensionValueRaw)};
+ wauthn_authentication_ext_s authenticationExt = {&extensionId, &extensionValue};
+ wauthn_authentication_ext_s emptyAuthenticationExt = {nullptr, nullptr};
+
+ unsigned char extensionIdRaw1[06] = {0x01, 0x02, 0x03, 0x04, };
+ unsigned char extensionValueRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
+ wauthn_const_buffer_s extensionId1 = {extensionIdRaw1, sizeof(extensionIdRaw1)};
+ wauthn_const_buffer_s extensionValue1 = {extensionValueRaw1, sizeof(extensionValueRaw1)};
+ wauthn_authentication_ext_s authenticationExt1 = {&extensionId1, &extensionValue1};
+ wauthn_authentication_ext_s authenticationExtArr1[1] = {authenticationExt};
+ wauthn_authentication_ext_s authenticationExtArr2[2] = {authenticationExt, authenticationExt1};
+ wauthn_authentication_exts_s authenticationExts1 = {sizeof(authenticationExtArr1)/sizeof(authenticationExtArr1[0]),
+ authenticationExtArr1};
+ wauthn_authentication_exts_s authenticationExts2 = {sizeof(authenticationExtArr2)/sizeof(authenticationExtArr2[0]),
+ authenticationExtArr2};
+ wauthn_authentication_exts_s emptyAuthenticationExts = {0, nullptr};
+
+ wauthn_authenticator_attachment_e attachment = AA_PLATFORM;
+ wauthn_resident_key_requirement_e resident_key = RKR_PREFERRED;
+ bool require_resident_key = false;
+ wauthn_user_verification_requirement_e user_verification = UVR_DISCOURAGED;
+ wauthn_authenticator_sel_cri_s authenticatorSelCri = {attachment, resident_key,
+ require_resident_key, user_verification};
+
+ wauthn_pubkey_cred_hint_e hint0 = PCH_SECURITY_KEY;
+ wauthn_pubkey_cred_hint_e hint1 = PCH_CLIENT_DEVICE;
+ wauthn_pubkey_cred_hint_e pubkeyCredHint1[1] = {hint0};
+ wauthn_pubkey_cred_hint_e pubkeyCredHint2[2] = {hint0, hint1};
+ wauthn_pubkey_cred_hints_s pubkeyCredHints1 = {sizeof(pubkeyCredHint1)/sizeof(pubkeyCredHint1[0]), pubkeyCredHint1};
+ wauthn_pubkey_cred_hints_s pubkeyCredHints2 = {sizeof(pubkeyCredHint2)/sizeof(pubkeyCredHint2[0]), pubkeyCredHint2};
+ wauthn_pubkey_cred_hints_s emptyPubkeyCredHints = {0, nullptr};
+
+ unsigned char contactIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
+ unsigned char linkIdRaw[16] = {0x11, 0x12, 0x13, 0x14, };
+ unsigned char linkSecretRaw[26] = {0x11, 0x12, 0x13, 0x14, };
+ unsigned char authenticatorPubkeyRaw[16] = {0x11, 0x12, 0x13, 0x14, };
+ unsigned char authenticatorNameRaw[26] = {0x11, 0x12, 0x13, 0x14, };
+ unsigned char authPubkeyRaw[36] = {0x11, 0x12, 0x13, 0x14, };
+ unsigned char tunnelServerDomainRaw[36] = {0x11, 0x12, 0x13, 0x14, };
+ wauthn_const_buffer_s contactId = {contactIdRaw, sizeof(contactIdRaw)};
+ wauthn_const_buffer_s linkId = {linkIdRaw, sizeof(linkIdRaw)};
+ wauthn_const_buffer_s linkSecret = {linkSecretRaw, sizeof(linkSecretRaw)};
+ wauthn_const_buffer_s authenticatorPubkey = {authenticatorPubkeyRaw, sizeof(authenticatorPubkeyRaw)};
+ wauthn_const_buffer_s authenticatorName = {authenticatorNameRaw, sizeof(authenticatorNameRaw)};
+ wauthn_const_buffer_s authPubkey = {authPubkeyRaw, sizeof(authPubkeyRaw)};
+ wauthn_const_buffer_s tunnelServerDomain = {tunnelServerDomainRaw, sizeof(tunnelServerDomainRaw)};
+ wauthn_hybrid_linked_data_s hybirdLinkedData = {&contactId, &linkId, &linkSecret, &authenticatorPubkey,
+ &authenticatorName, &signature, &authPubkey, &tunnelServerDomain};
+ wauthn_hybrid_linked_data_s emptyHybirdLinkedData = {nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr};
+
+ unsigned char bufferRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
+ unsigned char bufferRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
+ wauthn_const_buffer_s buffer0 = {bufferRaw0, sizeof(bufferRaw0)};
+ wauthn_const_buffer_s buffer1 = {bufferRaw1, sizeof(bufferRaw1)};
+ wauthn_const_buffer_s attestationFormat1[1] = {buffer0};
+ wauthn_const_buffer_s attestationFormat2[2] = {buffer0, buffer1};
+ wauthn_attestation_formats_s attestationFormats1 = {sizeof(attestationFormat1)/sizeof(attestationFormat1[0]),
+ attestationFormat1};
+ wauthn_attestation_formats_s attestationFormats2 = {sizeof(attestationFormat2)/sizeof(attestationFormat2[0]),
+ attestationFormat2};
+ wauthn_attestation_formats_s emptyAttestationFormats = {0, nullptr};
+
+ unsigned long timeout = 1000;
+ wauthn_attestation_pref_e attestation = AP_DIRECT;
+ wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions = {&rpEntity, &userEntity,
+ &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
+ attestation, &attestationFormats1, &authenticationExts2, &hybirdLinkedData};
+ wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptionsWithQR = {&rpEntity, &userEntity,
+ &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
+ attestation, &attestationFormats1, &authenticationExts2, nullptr};
+ wauthn_pubkey_cred_creation_options_s emptyPubkeyCredCreationOptions = {nullptr, nullptr,
+ nullptr, 0, nullptr, nullptr, nullptr, AP_NONE, nullptr, nullptr, nullptr};
+
+ const char *rpId = "test RP ID";
+ wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptions = {timeout, const_cast<char *>(rpId),
+ &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
+ &authenticationExts2, &hybirdLinkedData};
+ wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptionsWithQR = {timeout, const_cast<char *>(rpId),
+ &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
+ &authenticationExts2, nullptr};
+ wauthn_pubkey_cred_request_options_s emptyPubkeyCredRequestOptions = {0, nullptr,
+ nullptr, UVR_NONE, nullptr, AP_NONE, nullptr, nullptr, nullptr};
+
+ wauthn_pubkey_credential_attestaion_s pubkeyCredentialAttestation = {&bufferId, pubkeyCredType, &bufferId0,
+ &authenticatorAttestationResponse, attachment, &authenticationExts2, &hybirdLinkedData};
+ wauthn_pubkey_credential_attestaion_s emptyPubkeyCredentialAttestation = {nullptr, pubkeyCredType, nullptr,
+ nullptr, attachment, nullptr, nullptr};
+
+ wauthn_pubkey_credential_assertion_s pubkeyCredentialAssertion = {&bufferId, pubkeyCredType, &bufferId0,
+ &authenticatorAssertionResponse, attachment, &authenticationExts2, &hybirdLinkedData};
+ wauthn_pubkey_credential_assertion_s emptyPubkeyCredentialAssertion = {nullptr, pubkeyCredType, nullptr,
+ nullptr, attachment, nullptr, nullptr};
+
+ wauthn_hash_algorithm_e hashAlg = WAUTHN_HASH_ALGORITHM_SHA_256;
+ wauthn_client_data_s clientData = {&bufferId, hashAlg};
+ wauthn_client_data_s emptyClientData = {nullptr, hashAlg};
+} // namespace TestCommonData
+
+} // namespace WebAuthn
\ No newline at end of file
#pragma once
+#include <iostream>
#include <webauthn-types.h>
namespace WA {
inline constexpr auto WAH_API_GA = "wah_get_assertion";
inline constexpr auto WAH_API_CANCEL = "wah_cancel";
+typedef struct _test_user_data_s {
+ char *test_data;
+ int test_int;
+ bool called_qr;
+ bool called_response;
+} test_user_data_s;
+
+inline void _print_user_data(void *user_data)
+{
+ std::cout << "user_data is not null, data=" <<
+ (static_cast<test_user_data_s*>(user_data))->test_data <<
+ ", int=" << (static_cast<test_user_data_s*>(user_data))->test_int << std::endl;
+}
+
+inline void test_cb_display_qrcode(const char *qr_contents, void *user_data)
+{
+ std::cout << "QR Code: " << std::string(qr_contents) << std::endl;
+ if (user_data == nullptr)
+ std::cout << "user_data is null" << std::endl;
+ else
+ {
+ _print_user_data(user_data);
+ (static_cast<test_user_data_s*>(user_data))->called_qr = true;
+ }
+}
+
+inline void test_cb_mc_response(
+ const wauthn_pubkey_credential_attestaion_s *pubkey_cred,
+ wauthn_error_e result,
+ void *user_data)
+{
+ std::cout << "mc response, result: " << wauthn_error_to_string(result) << std::endl;
+ if (pubkey_cred == nullptr)
+ std::cout << "pubkey_cred is null" << std::endl;
+ else
+ std::cout << "pubkey_cred is not null: " <<
+ pubkey_cred->type << ", " <<
+ pubkey_cred->authenticator_attachment << std::endl;
+ if (user_data == nullptr)
+ std::cout << "user_data is null" << std::endl;
+ else
+ {
+ _print_user_data(user_data);
+ (static_cast<test_user_data_s*>(user_data))->called_response = true;
+ }
+}
+
+inline void test_cb_ga_response(
+ const wauthn_pubkey_credential_assertion_s *pubkey_cred,
+ wauthn_error_e result,
+ void *user_data)
+{
+ std::cout << "ga response, result: " << wauthn_error_to_string(result) << std::endl;
+ if (pubkey_cred == nullptr)
+ std::cout << "pubkey_cred is null" << std::endl;
+ else
+ std::cout << "pubkey_cred is not null" << std::endl;
+ if (user_data == nullptr)
+ std::cout << "user_data is null" << std::endl;
+ else
+ {
+ _print_user_data(user_data);
+ (static_cast<test_user_data_s*>(user_data))->called_response = true;
+ }
+}
+
+namespace TestCommonData {
+ extern unsigned char clientDataJsonRaw[06];
+ extern unsigned char attestationObjectRaw[16];
+ extern unsigned char authenticatorDataRaw[26];
+ extern unsigned char subjectPubkeyInfoRaw[36];
+ extern wauthn_const_buffer_s clientDataJson;
+ extern wauthn_const_buffer_s attestationObject;
+ extern unsigned int transports;
+ extern wauthn_const_buffer_s authenticatorData;
+ extern wauthn_const_buffer_s subjectPubkeyInfo;
+ extern wauthn_cose_algorithm_e pubkey_alg;
+ extern wauthn_authenticator_attestation_response_s authenticatorAttestationResponse;
+ extern wauthn_authenticator_attestation_response_s emptyAuthenticatorAttestationResponse;
+
+ extern unsigned char signatureRaw[26];
+ extern unsigned char userHandleRaw[36];
+ extern wauthn_const_buffer_s signature;
+ extern wauthn_const_buffer_s userHandle;
+ extern wauthn_authenticator_assertion_response_s authenticatorAssertionResponse;
+ extern wauthn_authenticator_assertion_response_s emptyAuthenticatorAssertionResponse;
+
+ extern const char *name;
+ extern const char *id;
+ extern wauthn_rp_entity_s rpEntity;
+ extern wauthn_rp_entity_s emptyRpEntiy;
+
+ extern unsigned char idRaw[06];
+ extern wauthn_const_buffer_s bufferId;
+ extern const char *displayName;
+ extern wauthn_user_entity_s userEntity;
+ extern wauthn_user_entity_s emptyUserEntity;
+
+ extern wauthn_pubkey_cred_type_e pubkeyCredType;
+ extern wauthn_pubkey_cred_param_s credParam0;
+ extern wauthn_pubkey_cred_param_s credParam1;
+ extern wauthn_pubkey_cred_param_s pubkeyCredParam2[2];
+ extern wauthn_pubkey_cred_params_s pubkeyCredParams2;
+ extern wauthn_pubkey_cred_param_s pubkeyCredParam1[1];
+ extern wauthn_pubkey_cred_params_s pubkeyCredParams1;
+ extern wauthn_pubkey_cred_params_s emptyPubkeyCredParams;
+
+ extern wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor;
+ extern wauthn_pubkey_cred_descriptor_s emptyPubkeyCredDescriptor;
+
+ extern unsigned char idRaw0[06];
+ extern unsigned char idRaw1[16];
+ extern wauthn_const_buffer_s bufferId0;
+ extern wauthn_const_buffer_s bufferId1;
+ extern wauthn_pubkey_cred_descriptor_s credDescriptor0;
+ extern wauthn_pubkey_cred_descriptor_s credDescriptor1;
+ extern wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor2[2];
+ extern wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors2;
+ extern wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor1[1];
+ extern wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors1;
+ extern wauthn_pubkey_cred_descriptors_s emptyPubkeyCredDescriptors;
+
+ extern unsigned char extensionIdRaw[06];
+ extern unsigned char extensionValueRaw[16];
+ extern wauthn_const_buffer_s extensionId;
+ extern wauthn_const_buffer_s extensionValue;
+ extern wauthn_authentication_ext_s authenticationExt;
+ extern wauthn_authentication_ext_s emptyAuthenticationExt;
+
+ extern unsigned char extensionIdRaw1[06];
+ extern unsigned char extensionValueRaw1[16];
+ extern wauthn_const_buffer_s extensionId1;
+ extern wauthn_const_buffer_s extensionValue1;
+ extern wauthn_authentication_ext_s authenticationExt1;
+ extern wauthn_authentication_ext_s authenticationExtArr1[1];
+ extern wauthn_authentication_ext_s authenticationExtArr2[2];
+ extern wauthn_authentication_exts_s authenticationExts1;
+ extern wauthn_authentication_exts_s authenticationExts2;
+ extern wauthn_authentication_exts_s emptyAuthenticationExts;
+
+ extern wauthn_authenticator_attachment_e attachment;
+ extern wauthn_resident_key_requirement_e resident_key;
+ extern bool require_resident_key;
+ extern wauthn_user_verification_requirement_e user_verification;
+ extern wauthn_authenticator_sel_cri_s authenticatorSelCri;
+
+ extern wauthn_pubkey_cred_hint_e hint0;
+ extern wauthn_pubkey_cred_hint_e hint1;
+ extern wauthn_pubkey_cred_hint_e pubkeyCredHint1[1];
+ extern wauthn_pubkey_cred_hint_e pubkeyCredHint2[2];
+ extern wauthn_pubkey_cred_hints_s pubkeyCredHints1;
+ extern wauthn_pubkey_cred_hints_s pubkeyCredHints2;
+ extern wauthn_pubkey_cred_hints_s emptyPubkeyCredHints;
+
+ extern unsigned char contactIdRaw[06];
+ extern unsigned char linkIdRaw[16];
+ extern unsigned char linkSecretRaw[26];
+ extern unsigned char authenticatorPubkeyRaw[16];
+ extern unsigned char authenticatorNameRaw[26];
+ extern unsigned char authPubkeyRaw[36];
+ extern unsigned char tunnelServerDomainRaw[36];
+ extern wauthn_const_buffer_s contactId;
+ extern wauthn_const_buffer_s linkId;
+ extern wauthn_const_buffer_s linkSecret;
+ extern wauthn_const_buffer_s authenticatorPubkey;
+ extern wauthn_const_buffer_s authenticatorName;
+ extern wauthn_const_buffer_s authPubkey;
+ extern wauthn_const_buffer_s tunnelServerDomain;
+ extern wauthn_hybrid_linked_data_s hybirdLinkedData;
+ extern wauthn_hybrid_linked_data_s emptyHybirdLinkedData;
+
+ extern unsigned char bufferRaw0[06];
+ extern unsigned char bufferRaw1[16];
+ extern wauthn_const_buffer_s buffer0;
+ extern wauthn_const_buffer_s buffer1;
+ extern wauthn_const_buffer_s attestationFormat1[1];
+ extern wauthn_const_buffer_s attestationFormat2[2];
+ extern wauthn_attestation_formats_s attestationFormats1;
+ extern wauthn_attestation_formats_s attestationFormats2;
+ extern wauthn_attestation_formats_s emptyAttestationFormats;
+
+ extern unsigned long timeout;
+ extern wauthn_attestation_pref_e attestation;
+ extern wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions;
+ extern wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptionsWithQR;
+ extern wauthn_pubkey_cred_creation_options_s emptyPubkeyCredCreationOptions;
+
+ extern const char *rpId;
+ extern wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptions;
+ extern wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptionsWithQR;
+ extern wauthn_pubkey_cred_request_options_s emptyPubkeyCredRequestOptions;
+
+ extern wauthn_pubkey_credential_attestaion_s pubkeyCredentialAttestation;
+ extern wauthn_pubkey_credential_attestaion_s emptyPubkeyCredentialAttestation;
+
+ extern wauthn_pubkey_credential_assertion_s pubkeyCredentialAssertion;
+ extern wauthn_pubkey_credential_assertion_s emptyPubkeyCredentialAssertion;
+
+ extern wauthn_hash_algorithm_e hashAlg;
+ extern wauthn_client_data_s clientData;
+ extern wauthn_client_data_s emptyClientData;
+} // namespace TestCommonData
+
} // namespace WebAuthn
\ No newline at end of file
* @brief unit tests for webauthn client api
*/
-#include <string>
-#include <iostream>
#include <gtest/gtest.h>
+#include <iostream>
+#include <string>
#include <unistd.h>
#include <webauthn.h>
+#include "test-common.h"
namespace WA {
-namespace CommonTestData {
- unsigned char clientDataJsonRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char attestationObjectRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorDataRaw[26] = {0x21, 0x22, 0x23, 0x24, };
- unsigned char subjectPubkeyInfoRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_const_buffer_s clientDataJson = {clientDataJsonRaw, sizeof(clientDataJsonRaw)};
- wauthn_const_buffer_s attestationObject = {attestationObjectRaw, sizeof(attestationObjectRaw)};
- unsigned int transports = 3;
- wauthn_const_buffer_s authenticatorData = {authenticatorDataRaw, sizeof(authenticatorDataRaw)};
- wauthn_const_buffer_s subjectPubkeyInfo = {subjectPubkeyInfoRaw, sizeof(subjectPubkeyInfoRaw)};
- wauthn_cose_algorithm_e pubkey_alg = WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256;
- wauthn_authenticator_attestation_response_s authenticatorAttestationResponse
- = {&clientDataJson, &attestationObject, transports, &authenticatorData, &subjectPubkeyInfo, pubkey_alg};
- wauthn_authenticator_attestation_response_s emptyAuthenticatorAttestationResponse
- = {nullptr, nullptr, 0x00, nullptr, nullptr, pubkey_alg};
-
- unsigned char signatureRaw[26] = {0x21, 0x22, 0x23, 0x24, };
- unsigned char userHandleRaw[36] = {0x31, 0x32, 0x33, 0x34, };
- wauthn_const_buffer_s signature = {signatureRaw, sizeof(signatureRaw)};
- wauthn_const_buffer_s userHandle = {userHandleRaw, sizeof(userHandleRaw)};
- wauthn_authenticator_assertion_response_s authenticatorAssertionResponse
- = {&clientDataJson, &authenticatorData, &signature, &userHandle, &attestationObject};
- wauthn_authenticator_assertion_response_s emptyAuthenticatorAssertionResponse
- = {nullptr, nullptr, nullptr, nullptr, nullptr};
-
- const char *name = "test name";
- const char *id = "test id";
- wauthn_rp_entity_s rpEntity = {name, id};
- wauthn_rp_entity_s emptyRpEntiy = {nullptr, nullptr};
-
- unsigned char idRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- wauthn_const_buffer_s bufferId = {idRaw, sizeof(idRaw)};
- const char *displayName = "test displayName";
- wauthn_user_entity_s userEntity = {const_cast<char*>(name), &bufferId, const_cast<char*>(displayName)};
- wauthn_user_entity_s emptyUserEntity = {nullptr, nullptr, nullptr};
-
- wauthn_pubkey_cred_type_e pubkeyCredType = PCT_PUBLIC_KEY;
- wauthn_pubkey_cred_param_s credParam0 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P256_WITH_SHA256};
- wauthn_pubkey_cred_param_s credParam1 = {pubkeyCredType, WAUTHN_COSE_ALGORITHM_ECDSA_P521_WITH_SHA512};
- wauthn_pubkey_cred_param_s pubkeyCredParam2[2] = {credParam0, credParam1};
- wauthn_pubkey_cred_params_s pubkeyCredParams2 = {sizeof(pubkeyCredParam2)/sizeof(pubkeyCredParam2[0]), pubkeyCredParam2};
- wauthn_pubkey_cred_param_s pubkeyCredParam1[1] = {credParam0};
- wauthn_pubkey_cred_params_s pubkeyCredParams1 = {sizeof(pubkeyCredParam1)/sizeof(pubkeyCredParam1[0]), pubkeyCredParam1};
- wauthn_pubkey_cred_params_s emptyPubkeyCredParams = {0, nullptr};
-
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor = {pubkeyCredType, &bufferId, 3};
- wauthn_pubkey_cred_descriptor_s emptyPubkeyCredDescriptor = {pubkeyCredType, nullptr, 0};
-
- unsigned char idRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char idRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s bufferId0 = {idRaw0, sizeof(idRaw0)};
- wauthn_const_buffer_s bufferId1 = {idRaw1, sizeof(idRaw1)};
- wauthn_pubkey_cred_descriptor_s credDescriptor0 = {pubkeyCredType, &bufferId0, 3};
- wauthn_pubkey_cred_descriptor_s credDescriptor1 = {pubkeyCredType, &bufferId1, 13};
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor2[2] = {credDescriptor0, credDescriptor1};
- wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors2 = {sizeof(pubkeyCredDescriptor2)/sizeof(pubkeyCredDescriptor2[0]),
- pubkeyCredDescriptor2};
- wauthn_pubkey_cred_descriptor_s pubkeyCredDescriptor1[1] = {credDescriptor0};
- wauthn_pubkey_cred_descriptors_s pubkeyCredDescriptors1 = {sizeof(pubkeyCredDescriptor1)/sizeof(pubkeyCredDescriptor1[0]),
- pubkeyCredDescriptor1};
- wauthn_pubkey_cred_descriptors_s emptyPubkeyCredDescriptors = {0, nullptr};
-
- unsigned char extensionIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char extensionValueRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s extensionId = {extensionIdRaw, sizeof(extensionIdRaw)};
- wauthn_const_buffer_s extensionValue = {extensionValueRaw, sizeof(extensionValueRaw)};
- wauthn_authentication_ext_s authenticationExt = {&extensionId, &extensionValue};
- wauthn_authentication_ext_s emptyAuthenticationExt = {nullptr, nullptr};
-
- unsigned char extensionIdRaw1[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char extensionValueRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s extensionId1 = {extensionIdRaw1, sizeof(extensionIdRaw1)};
- wauthn_const_buffer_s extensionValue1 = {extensionValueRaw1, sizeof(extensionValueRaw1)};
- wauthn_authentication_ext_s authenticationExt1 = {&extensionId1, &extensionValue1};
- wauthn_authentication_ext_s authenticationExtArr1[1] = {authenticationExt};
- wauthn_authentication_ext_s authenticationExtArr2[2] = {authenticationExt, authenticationExt1};
- wauthn_authentication_exts_s authenticationExts1 = {sizeof(authenticationExtArr1)/sizeof(authenticationExtArr1[0]),
- authenticationExtArr1};
- wauthn_authentication_exts_s authenticationExts2 = {sizeof(authenticationExtArr2)/sizeof(authenticationExtArr2[0]),
- authenticationExtArr2};
- wauthn_authentication_exts_s emptyAuthenticationExts = {0, nullptr};
-
- wauthn_authenticator_attachment_e attachment = AA_PLATFORM;
- wauthn_resident_key_requirement_e resident_key = RKR_PREFERRED;
- bool require_resident_key = false;
- wauthn_user_verification_requirement_e user_verification = UVR_DISCOURAGED;
- wauthn_authenticator_sel_cri_s authenticatorSelCri = {attachment, resident_key,
- require_resident_key, user_verification};
-
- wauthn_pubkey_cred_hint_e hint0 = PCH_SECURITY_KEY;
- wauthn_pubkey_cred_hint_e hint1 = PCH_CLIENT_DEVICE;
- wauthn_pubkey_cred_hint_e pubkeyCredHint1[1] = {hint0};
- wauthn_pubkey_cred_hint_e pubkeyCredHint2[2] = {hint0, hint1};
- wauthn_pubkey_cred_hints_s pubkeyCredHints1 = {sizeof(pubkeyCredHint1)/sizeof(pubkeyCredHint1[0]), pubkeyCredHint1};
- wauthn_pubkey_cred_hints_s pubkeyCredHints2 = {sizeof(pubkeyCredHint2)/sizeof(pubkeyCredHint2[0]), pubkeyCredHint2};
- wauthn_pubkey_cred_hints_s emptyPubkeyCredHints = {0, nullptr};
-
- unsigned char contactIdRaw[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char linkIdRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char linkSecretRaw[26] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorPubkeyRaw[16] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authenticatorNameRaw[26] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char authPubkeyRaw[36] = {0x11, 0x12, 0x13, 0x14, };
- unsigned char tunnelServerDomainRaw[36] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s contactId = {contactIdRaw, sizeof(contactIdRaw)};
- wauthn_const_buffer_s linkId = {linkIdRaw, sizeof(linkIdRaw)};
- wauthn_const_buffer_s linkSecret = {linkSecretRaw, sizeof(linkSecretRaw)};
- wauthn_const_buffer_s authenticatorPubkey = {authenticatorPubkeyRaw, sizeof(authenticatorPubkeyRaw)};
- wauthn_const_buffer_s authenticatorName = {authenticatorNameRaw, sizeof(authenticatorNameRaw)};
- wauthn_const_buffer_s authPubkey = {authPubkeyRaw, sizeof(authPubkeyRaw)};
- wauthn_const_buffer_s tunnelServerDomain = {tunnelServerDomainRaw, sizeof(tunnelServerDomainRaw)};
- wauthn_hybrid_linked_data_s hybirdLinkedData = {&contactId, &linkId, &linkSecret, &authenticatorPubkey,
- &authenticatorName, &signature, &authPubkey, &tunnelServerDomain};
- wauthn_hybrid_linked_data_s emptyHybirdLinkedData = {nullptr, nullptr, nullptr, nullptr,
- nullptr, nullptr, nullptr, nullptr};
-
- unsigned char bufferRaw0[06] = {0x01, 0x02, 0x03, 0x04, };
- unsigned char bufferRaw1[16] = {0x11, 0x12, 0x13, 0x14, };
- wauthn_const_buffer_s buffer0 = {bufferRaw0, sizeof(bufferRaw0)};
- wauthn_const_buffer_s buffer1 = {bufferRaw1, sizeof(bufferRaw1)};
- wauthn_const_buffer_s attestationFormat1[1] = {buffer0};
- wauthn_const_buffer_s attestationFormat2[2] = {buffer0, buffer1};
- wauthn_attestation_formats_s attestationFormats1 = {sizeof(attestationFormat1)/sizeof(attestationFormat1[0]),
- attestationFormat1};
- wauthn_attestation_formats_s attestationFormats2 = {sizeof(attestationFormat2)/sizeof(attestationFormat2[0]),
- attestationFormat2};
- wauthn_attestation_formats_s emptyAttestationFormats = {0, nullptr};
-
- unsigned long timeout = 1000;
- wauthn_attestation_pref_e attestation = AP_DIRECT;
- wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptions = {&rpEntity, &userEntity,
- &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
- attestation, &attestationFormats1, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_cred_creation_options_s pubkeyCredCreationOptionsWithQR = {&rpEntity, &userEntity,
- &pubkeyCredParams2, timeout, &pubkeyCredDescriptors2, &authenticatorSelCri, &pubkeyCredHints2,
- attestation, &attestationFormats1, &authenticationExts2, nullptr};
- wauthn_pubkey_cred_creation_options_s emptyPubkeyCredCreationOptions = {nullptr, nullptr,
- nullptr, 0, nullptr, nullptr, nullptr, AP_NONE, nullptr, nullptr, nullptr};
-
- const char *rpId = "test RP ID";
- wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptions = {timeout, const_cast<char *>(rpId),
- &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
- &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_cred_request_options_s pubkeyCredRequestOptionsWithQR = {timeout, const_cast<char *>(rpId),
- &pubkeyCredDescriptors2, user_verification, &pubkeyCredHints2, attestation, &attestationFormats1,
- &authenticationExts2, nullptr};
- wauthn_pubkey_cred_request_options_s emptyPubkeyCredRequestOptions = {0, nullptr,
- nullptr, UVR_NONE, nullptr, AP_NONE, nullptr, nullptr, nullptr};
-
- wauthn_pubkey_credential_attestaion_s pubkeyCredentialAttestation = {&bufferId, pubkeyCredType, &bufferId0,
- &authenticatorAttestationResponse, attachment, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_credential_attestaion_s emptyPubkeyCredentialAttestation = {nullptr, pubkeyCredType, nullptr,
- nullptr, attachment, nullptr, nullptr};
-
- wauthn_pubkey_credential_assertion_s pubkeyCredentialAssertion = {&bufferId, pubkeyCredType, &bufferId0,
- &authenticatorAssertionResponse, attachment, &authenticationExts2, &hybirdLinkedData};
- wauthn_pubkey_credential_assertion_s emptyPubkeyCredentialAssertion = {nullptr, pubkeyCredType, nullptr,
- nullptr, attachment, nullptr, nullptr};
-
- wauthn_hash_algorithm_e hashAlg = WAUTHN_HASH_ALGORITHM_SHA_256;
- wauthn_client_data_s clientData = {&bufferId, hashAlg};
- wauthn_client_data_s emptyClientData = {nullptr, hashAlg};
-}
-
class WebAuthnTest : public ::testing::Test {
protected:
void SetUp() override {
}
};
-void test_cb_display_qrcode(const char *qr_contents, void *user_data)
-{
- std::cout << "QR Code: " << std::string(qr_contents) << std::endl;
- if (user_data == nullptr)
- std::cout << "user_data is null" << std::endl;
-
-}
-void test_cb_mc_on_response(const wauthn_pubkey_credential_attestaion_s *pubkey_cred,
- wauthn_error_e result,
- void *user_data)
-{
- std::cout << "mc response, result: " << wauthn_error_to_string(result) << std::endl;
- if (pubkey_cred == nullptr)
- std::cout << "pubkey_cred is null" << std::endl;
- else
- std::cout << "pubkey_cred is not null: " <<
- pubkey_cred->type << ", " <<
- pubkey_cred->authenticator_attachment << std::endl;
- if (user_data == nullptr)
- std::cout << "user_data is null" << std::endl;
-}
-
-void test_cb_ga_on_response(const wauthn_pubkey_credential_assertion_s *pubkey_cred,
- wauthn_error_e result,
- void *user_data)
-{
- std::cout << "ga response, result: " << wauthn_error_to_string(result) << std::endl;
- if (pubkey_cred == nullptr)
- std::cout << "pubkey_cred is null" << std::endl;
- else
- std::cout << "pubkey_cred is not null" << std::endl;
- if (user_data == nullptr)
- std::cout << "user_data is null" << std::endl;
-}
-
TEST_F(WebAuthnTest, invalid_client_data_N)
{
int ret = WAUTHN_ERROR_NONE;
wauthn_mc_callbacks_s *mc_callbacks = nullptr;
mc_callbacks = (wauthn_mc_callbacks_s*) calloc(1, sizeof(wauthn_mc_callbacks_s));
mc_callbacks->qrcode_callback = test_cb_display_qrcode;
- mc_callbacks->response_callback = test_cb_mc_on_response;
+ mc_callbacks->response_callback = test_cb_mc_response;
ret = wauthn_make_credential(nullptr,
- &CommonTestData::pubkeyCredCreationOptions,
+ &TestCommonData::pubkeyCredCreationOptions,
mc_callbacks);
EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
wauthn_ga_callbacks_s *ga_callbacks = nullptr;
ga_callbacks = (wauthn_ga_callbacks_s*) calloc(1, sizeof(wauthn_ga_callbacks_s));
ga_callbacks->qrcode_callback = test_cb_display_qrcode;
- ga_callbacks->response_callback = test_cb_ga_on_response;
+ ga_callbacks->response_callback = test_cb_ga_response;
ret = wauthn_get_assertion(nullptr,
- &CommonTestData::pubkeyCredRequestOptions,
+ &TestCommonData::pubkeyCredRequestOptions,
ga_callbacks);
EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
wauthn_mc_callbacks_s *mc_callbacks = nullptr;
mc_callbacks = (wauthn_mc_callbacks_s*) calloc(1, sizeof(wauthn_mc_callbacks_s));
mc_callbacks->qrcode_callback = test_cb_display_qrcode;
- mc_callbacks->response_callback = test_cb_mc_on_response;
- ret = wauthn_make_credential(&CommonTestData::clientData,
+ mc_callbacks->response_callback = test_cb_mc_response;
+ ret = wauthn_make_credential(&TestCommonData::clientData,
nullptr,
mc_callbacks);
wauthn_ga_callbacks_s *ga_callbacks = nullptr;
ga_callbacks = (wauthn_ga_callbacks_s*) calloc(1, sizeof(wauthn_ga_callbacks_s));
ga_callbacks->qrcode_callback = test_cb_display_qrcode;
- ga_callbacks->response_callback = test_cb_ga_on_response;
- ret = wauthn_get_assertion(&CommonTestData::clientData,
+ ga_callbacks->response_callback = test_cb_ga_response;
+ ret = wauthn_get_assertion(&TestCommonData::clientData,
nullptr,
ga_callbacks);
TEST_F(WebAuthnTest, invalid_callbacks_N)
{
int ret = WAUTHN_ERROR_NONE;
- ret = wauthn_make_credential(&CommonTestData::clientData,
- &CommonTestData::pubkeyCredCreationOptions,
+ ret = wauthn_make_credential(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredCreationOptions,
nullptr);
EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
<< "[wauthn_make_credential] failed. "
mc_callbacks = (wauthn_mc_callbacks_s*) calloc(1, sizeof(wauthn_mc_callbacks_s));
mc_callbacks->qrcode_callback = test_cb_display_qrcode;
mc_callbacks->response_callback = nullptr;
- ret = wauthn_make_credential(&CommonTestData::clientData,
- &CommonTestData::pubkeyCredCreationOptions,
+ ret = wauthn_make_credential(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredCreationOptions,
mc_callbacks);
EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
<< "[wauthn_make_credential] failed. "
<< "ret=" << wauthn_error_to_string(ret) << std::endl;
ret = WAUTHN_ERROR_NONE;
- ret = wauthn_get_assertion(&CommonTestData::clientData,
- &CommonTestData::pubkeyCredRequestOptions,
+ ret = wauthn_get_assertion(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredRequestOptions,
nullptr);
EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
<< "[wauthn_get_assertion] failed. "
ga_callbacks = (wauthn_ga_callbacks_s*) calloc(1, sizeof(wauthn_ga_callbacks_s));
ga_callbacks->qrcode_callback = test_cb_display_qrcode;
ga_callbacks->response_callback = nullptr;
- ret = wauthn_get_assertion(&CommonTestData::clientData,
- &CommonTestData::pubkeyCredRequestOptions,
+ ret = wauthn_get_assertion(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredRequestOptions,
ga_callbacks);
EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
<< "[wauthn_get_assertion] failed. "
wauthn_mc_callbacks_s *mc_callbacks = nullptr;
mc_callbacks = (wauthn_mc_callbacks_s*) calloc(1, sizeof(wauthn_mc_callbacks_s));
mc_callbacks->qrcode_callback = nullptr;
- mc_callbacks->response_callback = test_cb_mc_on_response;
- ret = wauthn_make_credential(&CommonTestData::clientData,
- &CommonTestData::pubkeyCredCreationOptionsWithQR,
+ mc_callbacks->response_callback = test_cb_mc_response;
+ ret = wauthn_make_credential(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredCreationOptionsWithQR,
mc_callbacks);
EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
<< "[wauthn_make_credential] failed. "
wauthn_ga_callbacks_s *ga_callbacks = nullptr;
ga_callbacks = (wauthn_ga_callbacks_s*) calloc(1, sizeof(wauthn_ga_callbacks_s));
ga_callbacks->qrcode_callback = nullptr;
- ga_callbacks->response_callback = test_cb_ga_on_response;
- ret = wauthn_get_assertion(&CommonTestData::clientData,
- &CommonTestData::pubkeyCredRequestOptionsWithQR,
+ ga_callbacks->response_callback = test_cb_ga_response;
+ ret = wauthn_get_assertion(&TestCommonData::clientData,
+ &TestCommonData::pubkeyCredRequestOptionsWithQR,
nullptr);
EXPECT_EQ(ret, WAUTHN_ERROR_INVALID_PARAMETER)
<< "[wauthn_get_assertion] failed. "