CKM: Add negative test for CKM::Control::unlock function.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Wed, 4 Feb 2015 12:24:48 +0000 (13:24 +0100)
committerMaciej J. Karpiuk <m.karpiuk2@samsung.com>
Wed, 18 Feb 2015 09:47:22 +0000 (10:47 +0100)
Change-Id: I2ddc8572d033eb7b138fe6ad255669082fc31245

tests/ckm/main.cpp

index 3a9f380..a3ebe02 100644 (file)
@@ -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)