From ee9c7855ca0d0b653d60c5332cea6dffd5a5c7cc Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Mon, 26 Jul 2021 12:39:44 +0200 Subject: [PATCH] Use max token id in api test at least once. so that we also test bitfield limits. --- tests/api-test-2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/api-test-2.c b/tests/api-test-2.c index a56a10ab..3dd2e295 100644 --- a/tests/api-test-2.c +++ b/tests/api-test-2.c @@ -1900,7 +1900,7 @@ static void Tokens(void) "\"key_description\":" y ", \"some_field\":\"some_value\"}" - int ks; + int ks, token_max; const char *dummy; const char *cipher = "aes"; const char *cipher_mode = "xts-plain64"; @@ -2085,8 +2085,11 @@ static void Tokens(void) // expected unusable (-ENOENT) EQ_(crypt_token_json_set(cd, 11, TEST_TOKEN_JSON("")), 11); + token_max = crypt_token_max(CRYPT_LUKS2) - 1; + GE_(token_max, 0); + // expected to be used first with CRYPT_ANY_TOKEN (unlocks with high priority ks 12) - EQ_(crypt_token_json_set(cd, 20, TEST_TOKEN_JSON("\"12\", \"0\", \"3\"")), 20); + EQ_(crypt_token_json_set(cd, token_max, TEST_TOKEN_JSON("\"12\", \"0\", \"3\"")), token_max); // expected usable with CRYPT_ANY_TOKEN EQ_(crypt_token_json_set(cd, 8, TEST_TOKEN_JSON("\"5\", \"0\", \"3\"")), 8); @@ -2101,7 +2104,7 @@ static void Tokens(void) EQ_(crypt_activate_by_token_pin(cd, CDEVICE_1, "test_token", 1, NULL, 0, passptr, 0), 0); OK_(crypt_deactivate(cd, CDEVICE_1)); - EQ_(crypt_token_json_set(cd, 20, NULL), 20); + EQ_(crypt_token_json_set(cd, token_max, NULL), token_max); EQ_(crypt_activate_by_token_pin(cd, NULL, "test_token", CRYPT_ANY_TOKEN, NULL, 0, passptr, 0), 5);