Skip to content

Commit 1bd722a

Browse files
add auth login as admin during SHE tests
1 parent faa19e7 commit 1bd722a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

examples/demo/client/wh_demo_client_all.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ int wh_DemoClient_All(whClientContext* clientContext)
1212
{
1313
int rc = 0;
1414
whUserId userId = WH_USER_ID_INVALID;
15-
whAuthPermissions permissions;
16-
1715
/* Auth demos */
1816
rc = wh_DemoClient_Auth(clientContext);
1917
if (rc != 0) {
@@ -22,7 +20,7 @@ int wh_DemoClient_All(whClientContext* clientContext)
2220

2321
/* Log in as an admin user for the rest of the tests */
2422
if (wh_Client_AuthLogin(clientContext, WH_AUTH_METHOD_PIN, "admin", "1234",
25-
4, &rc, &userId, &permissions) != 0) {
23+
4, &rc, &userId) != 0) {
2624
return -1;
2725
}
2826
if (rc != 0) {

test/wh_test_she.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ enum {
8181
#define FLASH_SECTOR_SIZE (128 * 1024) /* 128KB */
8282
#define FLASH_PAGE_SIZE (8) /* 8B */
8383

84+
#ifndef TEST_ADMIN_USERNAME
85+
#define TEST_ADMIN_USERNAME "admin"
86+
#endif
87+
#ifndef TEST_ADMIN_PIN
88+
#define TEST_ADMIN_PIN "1234"
89+
#endif
90+
8491
#ifdef WOLFHSM_CFG_ENABLE_CLIENT
8592
/* Helper function to destroy a SHE key so the unit tests don't
8693
* leak NVM objects across invocations. Necessary, as SHE doesn't expose a
@@ -164,6 +171,11 @@ int whTest_SheClientConfig(whClientConfig* config)
164171
WH_TEST_RETURN_ON_FAIL(wh_Client_Init(client, config));
165172
WH_TEST_RETURN_ON_FAIL(wh_Client_CommInit(client, &outClientId, &outServerId));
166173

174+
/* Attempt log in as an admin user for the rest of the tests */
175+
WH_TEST_RETURN_ON_FAIL(wh_Client_AuthLogin(client, WH_AUTH_METHOD_PIN,
176+
TEST_ADMIN_USERNAME, TEST_ADMIN_PIN, strlen(TEST_ADMIN_PIN),
177+
NULL, NULL));
178+
167179
#ifdef WOLFHSM_CFG_DEBUG_VERBOSE
168180
{
169181
int32_t server_rc = 0;

0 commit comments

Comments
 (0)