ALIAS_DATA
} alias_type_;
+const char* USER_PASS = "user-pass";
+
int count_aliases(alias_type_ type, int minimum_initial_element_count = 0)
{
ckmc_alias_list_s *aliasList = NULL;
RUNNER_TEST(T3014_Control_C_API)
{
int temp;
+ const uid_t UNIQUE_USER = 15;
- RUNNER_ASSERT_MSG( CKMC_ERROR_BAD_REQUEST == (temp = ckmc_reset_user_password(14, "simple-password")),
+ // clean up environment
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
+ "Error=" << temp);
+ // unlock with default password
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(UNIQUE_USER, NULL)),
+ "Error=" << temp);
+ // reset password (NULL, "simple-password")
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_reset_user_password(UNIQUE_USER, "simple-password")),
+ "Error=" << temp);
+ // get rid of NULL DKEK
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(UNIQUE_USER, "simple-password")),
+ "Error=" << temp);
+ // lock db
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(UNIQUE_USER)),
+ "Error=" << temp);
+ // try to reset password when db locked
+ RUNNER_ASSERT_MSG( CKMC_ERROR_BAD_REQUEST == (temp = ckmc_reset_user_password(UNIQUE_USER, "simple-password")),
+ "Error=" << temp);
+ // clean up environment
+ RUNNER_ASSERT_MSG( CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(UNIQUE_USER)),
"Error=" << temp);
}
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
"Error=" << temp);
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "user-pass")),
+ CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
"Error=" << temp);
}
"Error=" << temp);
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "user-pass")),
+ CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
"Error=" << temp);
}
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
"Error=" << temp);
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "user-pass")),
+ CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
"Error=" << temp);
}
"Error=" << temp);
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "user-pass")),
+ CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
"Error=" << temp);
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(0, "test-pass")),
"Error=" << temp);
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, "user-pass")),
+ CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
"Error=" << temp);
}
RUNNER_TEST_GROUP_INIT(T3000_CAPI_LOCKTYPE_TESTS);
+RUNNER_TEST(T3100_CAPI_locktype_init)
+{
+ int temp;
+ RUNNER_ASSERT_MSG_BT(
+ CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
+ "Error=" << temp);
+ RUNNER_ASSERT_MSG_BT(
+ CKMC_ERROR_NONE == (temp = ckmc_unlock_user_key(USER_APP, USER_PASS)),
+ "Error=" << temp);
+}
+
RUNNER_CHILD_TEST(T3101_CAPI_init_lock_key)
{
int tmp;
char *null_password = NULL;
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,"user-pass",null_password)),
+ CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,USER_PASS,null_password)),
CKM::ErrorToString(tmp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
ap.applyAndSwithToUser(USER_APP, GROUP_APP);
char *null_password = NULL;
+
+ // database has been automatically unlocked with NULL pw in previous test. Lock it now
+ RUNNER_ASSERT_MSG(
+ CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
+ CKM::ErrorToString(tmp));
RUNNER_ASSERT_MSG(
- CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,null_password,"user-pass")),
+ CKMC_ERROR_NONE == (tmp = ckmc_change_user_password(USER_APP,null_password,USER_PASS)),
+ CKM::ErrorToString(tmp));
+ // get rid of NULL DKEK
+ RUNNER_ASSERT_MSG(
+ CKMC_ERROR_NONE == (tmp = ckmc_unlock_user_key(USER_APP,USER_PASS)),
CKM::ErrorToString(tmp));
RUNNER_ASSERT_MSG(
CKMC_ERROR_NONE == (tmp = ckmc_lock_user_key(USER_APP)),
RUNNER_CHILD_TEST(T3109_CAPI_deinit)
{
- AccessProvider ap("my-label");
- ap.allowAPI("key-manager::api-control", "rw");
- ap.applyAndSwithToUser(USER_APP, GROUP_APP);
+ int temp;
+ RUNNER_ASSERT_MSG_BT(
+ CKMC_ERROR_NONE == (temp = ckmc_lock_user_key(USER_APP)),
+ "Error=" << temp);
+ RUNNER_ASSERT_MSG_BT(
+ CKMC_ERROR_NONE == (temp = ckmc_remove_user_data(USER_APP)),
+ "Error=" << temp);
}
RUNNER_TEST_GROUP_INIT(T320_CAPI_EMPTY_DATABASE);