Skip to content

Commit

Permalink
Merge pull request #840 from cisco/bugfix/uts
Browse files Browse the repository at this point in the history
Fixes for some UTs
  • Loading branch information
abkarcher authored Jul 19, 2024
2 parents e7800bf + 6156268 commit ce3c46f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
20 changes: 10 additions & 10 deletions test/test_acvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,10 @@ Test(PROCESS_TESTS, mark_as_get_only, .init = setup_full_ctx, .fini = teardown)
rv = acvp_mark_as_get_only(ctx, "", NULL);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_mark_as_get_only(ctx, "testFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLong", NULL);
rv = acvp_mark_as_get_only(ctx, ACVP_TEST_STRING_TOO_LONG, NULL);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_mark_as_get_only(ctx, "test", "testFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLong");
rv = acvp_mark_as_get_only(ctx, "test", ACVP_TEST_STRING_TOO_LONG);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_mark_as_get_only(ctx, "test", "");
Expand All @@ -797,7 +797,7 @@ Test(PROCESS_TESTS, mark_as_delete_only, .init = setup_full_ctx, .fini = teardow
rv = acvp_mark_as_delete_only(ctx, "test");
cr_assert(rv == ACVP_SUCCESS);

rv = acvp_mark_as_delete_only(ctx, "testFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLong");
rv = acvp_mark_as_delete_only(ctx, ACVP_TEST_STRING_TOO_LONG);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_mark_as_delete_only(ctx, "");
Expand Down Expand Up @@ -844,8 +844,8 @@ Test(PROCESS_TESTS, acvp_get_results_from_server, .init = setup_full_ctx, .fini
rv = acvp_get_results_from_server(ctx, NULL);
cr_assert(rv == ACVP_MISSING_ARG);

rv = acvp_get_results_from_server(ctx, "testFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLong");
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_get_results_from_server(ctx, ACVP_TEST_STRING_TOO_LONG);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_get_results_from_server(ctx, "json/getResults.json");
cr_assert(rv = ACVP_MALFORMED_JSON);
Expand All @@ -862,7 +862,7 @@ Test(PROCESS_TESTS, acvp_resume_test_session, .init = setup_full_ctx, .fini = te
rv = acvp_resume_test_session(ctx, NULL, 0);
cr_assert(rv == ACVP_MISSING_ARG);

rv = acvp_resume_test_session(ctx, "testFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLong", 0);
rv = acvp_resume_test_session(ctx, ACVP_TEST_STRING_TOO_LONG, 0);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_resume_test_session(ctx, "json/getResults.json", 1);
Expand All @@ -880,10 +880,10 @@ Test(PROCESS_TESTS, acvp_cancel_test_session, .init = setup_full_ctx, .fini = te
rv = acvp_cancel_test_session(ctx, NULL, "test");
cr_assert(rv == ACVP_MISSING_ARG);

rv = acvp_cancel_test_session(ctx, "testRequestUrlTooLongtestRequestUrlTooLongtestRequestUrlTooLongtestRequestUrlTooLongtestRequestUrlTooLongtestRequestUrlTooLongtestRequestUrlTooLongtestRequestUrlTooLongtestRequestUrlTooLong", NULL);
rv = acvp_cancel_test_session(ctx, ACVP_TEST_STRING_TOO_LONG, NULL);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_cancel_test_session(ctx, "test", "testFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLong");
rv = acvp_cancel_test_session(ctx, "test", ACVP_TEST_STRING_TOO_LONG);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_cancel_test_session(ctx, "", "test");
Expand Down Expand Up @@ -912,10 +912,10 @@ Test(PROCESS_TESTS, acvp_get_expected_results, .init = setup_full_ctx, .fini = t
rv = acvp_get_expected_results(ctx, NULL, NULL);
cr_assert(rv == ACVP_MISSING_ARG);

rv = acvp_get_expected_results(ctx, "testFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLong", NULL);
rv = acvp_get_expected_results(ctx, ACVP_TEST_STRING_TOO_LONG, NULL);
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_get_expected_results(ctx, "json/testSession_0.json", \
"testFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLongtestFileNameTooLong");
ACVP_TEST_STRING_TOO_LONG);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_get_expected_results(ctx, "json/getResults.json", NULL);
Expand Down
8 changes: 4 additions & 4 deletions test/test_acvp_capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ Test(EnableCapAES, invalid_keylens, .fini = teardown) {

rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CFB1, ACVP_SYM_CIPH_KEYLEN, 333);
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CFB1, ACVP_SYM_CIPH_KEYLEN, 333333);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CFB1, ACVP_SYM_CIPH_KEYLEN, 999999);
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CFB1, ACVP_SYM_CIPH_KEYLEN, 0);
cr_assert(rv == ACVP_INVALID_ARG);
Expand All @@ -840,7 +840,7 @@ Test(EnableCapAES, invalid_param_lens, .fini = teardown) {
setup_empty_ctx(&ctx);
rv = acvp_cap_sym_cipher_enable(ctx, ACVP_AES_CFB1, &dummy_handler_success);
cr_assert(rv == ACVP_SUCCESS);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CFB1, ACVP_SYM_CIPH_PTLEN, 333333);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CFB1, ACVP_SYM_CIPH_PTLEN, 999999);
cr_assert(rv == ACVP_INVALID_ARG);

rv = acvp_cap_sym_cipher_enable(ctx, ACVP_AES_CCM, &dummy_handler_success);
Expand All @@ -851,11 +851,11 @@ Test(EnableCapAES, invalid_param_lens, .fini = teardown) {
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CCM, ACVP_SYM_CIPH_IVLEN, 0);
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CCM, ACVP_SYM_CIPH_IVLEN, 333333);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CCM, ACVP_SYM_CIPH_IVLEN, 999999);
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CCM, ACVP_SYM_CIPH_IVLEN, 0);
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CCM, ACVP_SYM_CIPH_AADLEN, 333333);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CCM, ACVP_SYM_CIPH_AADLEN, 999999);
cr_assert(rv == ACVP_INVALID_ARG);
rv = acvp_cap_sym_cipher_set_parm(ctx, ACVP_AES_CCM, ACVP_SYM_CIPH_AADLEN, -333);
cr_assert(rv == ACVP_INVALID_ARG);
Expand Down
18 changes: 18 additions & 0 deletions test/ut_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,21 @@ int dummy_handler_failure(ACVP_TEST_CASE *test_case);
JSON_Object *ut_get_obj_from_rsp (JSON_Value *arry_val);
unsigned int base64_decode(const char *in, unsigned int inlen, unsigned char *out);
unsigned int dummy_totp(char **token, int token_max);

#define ACVP_TEST_STRING_TOO_LONG "TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"\
"TestStringTooLongTestStringTooLongTestStringTooLongTestStringTooLong"

0 comments on commit ce3c46f

Please sign in to comment.