From 1966ec5562af9e56b2a81c735e08dcd234019513 Mon Sep 17 00:00:00 2001 From: Bartlomiej Grzelewski Date: Wed, 4 Feb 2015 13:24:48 +0100 Subject: [PATCH] CKM: Add negative test for CKM::Control::unlock function. Change-Id: I2ddc8572d033eb7b138fe6ad255669082fc31245 --- tests/ckm/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/ckm/main.cpp b/tests/ckm/main.cpp index 3a9f380..a3ebe02 100644 --- a/tests/ckm/main.cpp +++ b/tests/ckm/main.cpp @@ -125,6 +125,27 @@ RUNNER_TEST(T0015_Control) "Error=" << CKM::ErrorToString(temp)); } +RUNNER_TEST(T0016_Control_negative_wrong_password) +{ + int temp; + auto control = CKM::Control::create(); + RUNNER_ASSERT_MSG_BT( + CKM_API_SUCCESS == (temp = control->unlockUserKey(20, "test-pass")), + "Error=" << CKM::ErrorToString(temp)); + RUNNER_ASSERT_MSG_BT( + CKM_API_SUCCESS == (temp = control->changeUserPassword(20, "test-pass", "new-pass")), + "Error=" << CKM::ErrorToString(temp)); + RUNNER_ASSERT_MSG_BT( + CKM_API_SUCCESS == (temp = control->lockUserKey(20)), + "Error=" << CKM::ErrorToString(temp)); + RUNNER_ASSERT_MSG_BT( + CKM_API_ERROR_AUTHENTICATION_FAILED == (temp = control->unlockUserKey(20, "incorrect-password")), + "Error=" << CKM::ErrorToString(temp)); + RUNNER_ASSERT_MSG_BT( + CKM_API_SUCCESS == (temp = control->removeUserData(20)), + "Error=" << CKM::ErrorToString(temp)); +} + RUNNER_TEST_GROUP_INIT(T101_CKM_QUICK_SET_GET_TESTS); RUNNER_TEST(T1010_init) -- 2.7.4