Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "custom server" macro for tests #30

Merged
merged 2 commits into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions test/wh_test_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ int whTest_CryptoClientConfig(whClientConfig* config)
WH_ERROR_PRINT("KEY CACHE/EXPORT FAILED TO MATCH\n");
goto exit;
}
#ifndef WH_CFG_TEST_NO_CUSTOM_SERVERS
/* WH_CFG_TEST_NO_CUSTOM_SERVERS protects the client test code that expects to
* interop with the custom server (also defined in this file), so that this
* test can be run against a standard server app
*
* TODO: This is a temporary bodge until we properly split tests into single
* client and multi client */

/* test cache with duplicate keyId for a different user */
WH_TEST_RETURN_ON_FAIL(wh_Client_CommClose(client));
client->comm->client_id = 2;
Expand Down Expand Up @@ -210,6 +218,7 @@ int whTest_CryptoClientConfig(whClientConfig* config)
WH_ERROR_PRINT("KEY CACHE/EXPORT FAILED TO MATCH\n");
goto exit;
}
#endif /* !WH_CFG_TEST_NO_CUSTOM_SERVERS */
/* evict for original client */
if ((ret = wh_Client_KeyEvictRequest(client, keyId)) != 0) {
WH_ERROR_PRINT("Failed to wh_Client_KeyEvictRequest %d\n", ret);
Expand Down Expand Up @@ -417,7 +426,9 @@ int whTest_CryptoServerConfig(whServerConfig* config)
whServerContext server[1] = {0};
whCommConnected am_connected = WH_COMM_CONNECTED;
int ret = 0;
#ifndef WH_CFG_TEST_NO_CUSTOM_SERVERS
int userChange = 0;
#endif

if (config == NULL) {
return WH_ERROR_BADARGS;
Expand All @@ -435,6 +446,8 @@ int whTest_CryptoServerConfig(whServerConfig* config)
break;
}
wh_Server_GetConnected(server, &am_connected);

#ifndef WH_CFG_TEST_NO_CUSTOM_SERVERS
/* keep alive for 2 user changes */
if (am_connected != WH_COMM_CONNECTED && userChange < 2) {
if (userChange == 0)
Expand All @@ -445,8 +458,10 @@ int whTest_CryptoServerConfig(whServerConfig* config)
am_connected = WH_COMM_CONNECTED;
WH_TEST_RETURN_ON_FAIL(wh_Server_SetConnected(server, am_connected));
}
#endif /* !WH_CFG_TEST_NO_CUSTOM_SERVERS */
}
if ((ret == 0) || (ret == WH_ERROR_NOTREADY)){

if ((ret == 0) || (ret == WH_ERROR_NOTREADY)) {
WH_TEST_RETURN_ON_FAIL(wh_Server_Cleanup(server));
} else {
ret = wh_Server_Cleanup(server);
Expand Down Expand Up @@ -581,7 +596,6 @@ static int wh_ClientServer_MemThreadTest(void)
}
#endif /* WH_CFG_TEST_POSIX */


int whTest_Crypto(void)
{
#if defined(WH_CFG_TEST_POSIX)
Expand Down