auth-fw: Add TC about remove-password 38/144638/3
authorsangwan.kwon <sangwan.kwon@samsung.com>
Thu, 17 Aug 2017 07:19:24 +0000 (03:19 -0400)
committersangwan.kwon <sangwan.kwon@samsung.com>
Fri, 18 Aug 2017 05:00:03 +0000 (01:00 -0400)
Change-Id: I23cb5a4749972c639d8caee1307d6418abc8a435
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
src/auth-fw-passwd/auth-passwd.cpp

index 242e4534c703866dfaf64b5f4dc0811e9cd8b4ac..90b5bb7df90190a6a8a87b0382768e0d770e91a0 100644 (file)
@@ -112,6 +112,8 @@ RUNNER_TEST(T00110_init)
 
        RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
                "Failed to reset passwd of user: " << getuid() << " with ret: " << ret);
+
+       auth_passwd_disable_policy(getuid());
 }
 
 RUNNER_TEST(T00111_check)
@@ -131,33 +133,26 @@ RUNNER_TEST(T00113_check_reusable)
 
 RUNNER_TEST(T00114_set)
 {
-       sleep_for_retry_timeout();
-
        const char *new_pass = "new_pass_temp";
 
-       int ret = auth_passwd_set_passwd(
-                       AUTH_PWD_NORMAL,
-                       default_pass,
-                       new_pass);
-
-       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
-               "Failed to auth_passwd_set_passwd. ret: " << ret);
-
        sleep_for_retry_timeout();
+       int ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, default_pass, new_pass);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
 
-       /* roll back passwd to default pass */
-       ret = auth_passwd_set_passwd(
-                       AUTH_PWD_NORMAL,
-                       new_pass,
-                       default_pass);
+       /* remove passwd */
+       sleep_for_retry_timeout();
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, new_pass, NULL);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
 
-       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
-               "Failed to auth_passwd_set_passwd for rollback. ret: " << ret);
+       /* rollback passwd to default pass */
+       sleep_for_retry_timeout();
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, NULL, default_pass);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
 }
 
 RUNNER_TEST(T00115_check_passwd_available)
 {
-    policy_h *policy = nullptr;
+       policy_h *policy = nullptr;
        const char* not_usable_passwd = "123456";
        const char* usable_passwd = "tizen";
 
@@ -198,3 +193,93 @@ RUNNER_TEST(T00115_check_passwd_available)
 
        auth_passwd_free_policy(policy);
 }
+
+RUNNER_TEST(T00116_remove_password_with_empty_policy)
+{
+       /* precondition : set empty policy */
+       policy_h *policy = nullptr;
+       int ret = auth_passwd_new_policy(&policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to make new policy. ret: " << ret);
+
+       ret = auth_passwd_set_user(policy, getuid());
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set user. ret: " << ret);
+
+       ret = auth_passwd_set_policy(policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set policy. ret: " << ret);
+
+       /* test : remove passwd with empty policy */
+       sleep_for_retry_timeout();
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, default_pass, NULL);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
+
+       /* restore */
+       ret = auth_passwd_disable_policy(getuid());
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to disable policy. ret: " << ret);
+       auth_passwd_free_policy(policy);
+
+       sleep_for_retry_timeout();
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, NULL, default_pass);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
+}
+
+RUNNER_TEST(T00117_remove_password_with_min_length_policy)
+{
+       /* precondition : set min-length policy */
+       policy_h *policy = nullptr;
+       int ret = auth_passwd_new_policy(&policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to make new policy. ret: " << ret);
+
+       ret = auth_passwd_set_user(policy, getuid());
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set user. ret: " << ret);
+
+       ret = auth_passwd_set_min_length(policy, 4);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set min length. ret: " << ret);
+
+       ret = auth_passwd_set_policy(policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set policy. ret: " << ret);
+
+       /* test : remove passwd with min-length policy */
+       sleep_for_retry_timeout();
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, default_pass, NULL);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
+
+       /* restore */
+       ret = auth_passwd_disable_policy(getuid());
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to disable policy. ret: " << ret);
+       auth_passwd_free_policy(policy);
+
+       sleep_for_retry_timeout();
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, NULL, default_pass);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
+}
+
+RUNNER_TEST(T00118_remove_password_with_min_complex_char_policy)
+{
+       /* precondition : set min-complex-char policy */
+       policy_h *policy = nullptr;
+       int ret = auth_passwd_new_policy(&policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to make new policy. ret: " << ret);
+
+       ret = auth_passwd_set_user(policy, getuid());
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set user. ret: " << ret);
+
+       ret = auth_passwd_set_min_complex_char_num(policy, AUTH_PWD_COMPLEX_CHAR_GROUP_1);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set min complex. ret: " << ret);
+
+       ret = auth_passwd_set_policy(policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set policy. ret: " << ret);
+
+       /* test : remove passwd with min-complex-char policy */
+       sleep_for_retry_timeout();
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, default_pass, NULL);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
+
+       /* restore */
+       ret = auth_passwd_disable_policy(getuid());
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to disable policy. ret: " << ret);
+       auth_passwd_free_policy(policy);
+
+       sleep_for_retry_timeout();
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, NULL, default_pass);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS, "Failed to set passwd. ret: " << ret);
+}