Add missing TCs 76/125476/5
authorDongsun Lee <ds73.lee@samsung.com>
Mon, 17 Apr 2017 11:33:09 +0000 (20:33 +0900)
committerDongsun Lee <ds73.lee@samsung.com>
Tue, 18 Apr 2017 05:11:20 +0000 (14:11 +0900)
- TC for auth_passwd_check_passwd_available
- TC for auth_passwd_set_passwd_recovery
- TC for auth_passwd_set_pattern

Change-Id: I21d5aedc2501e38c72f06d071a8ce7fe3980ccbd
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
src/auth-fw-passwd/auth-passwd-admin.cpp
src/auth-fw-passwd/auth-passwd.cpp

index 00b6c34cdff7151a1b47e2e5d862cd2e8a7b8d4f..31ade189c5f0427e61ba9b788d345f512544f8d5 100644 (file)
@@ -453,3 +453,60 @@ RUNNER_TEST(T00204_min_complex_char)
        auth_passwd_free_policy(policy);
 }
 
+RUNNER_TEST(T00205_pattern)
+{
+       policy_h *policy = nullptr;
+
+       const char* pattern = "[0-9]+";
+       const char* allowed_passwd = "Tizen123";
+       const char* not_allowed_passwd = "Tizen";
+
+       int ret = auth_passwd_new_policy(&policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS && policy != nullptr,
+               "Failed to make new policy. ret: " << ret);
+
+       ret = auth_passwd_set_user(policy, getuid());
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to auth_passwd_set_user. ret: " << ret);
+
+       ret = auth_passwd_set_history_size(policy, 0);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to set history size to policy handle. ret: " << ret);
+
+       ret = auth_passwd_set_quality(policy, AUTH_PWD_QUALITY_UNSPECIFIED);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to set quality to policy handle. ret: " << ret);
+
+       // set pattern
+       ret = auth_passwd_set_pattern(policy, pattern);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to auth_passwd_set_pattern. ret: " << ret);
+
+       ret = auth_passwd_set_policy(policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to set policy. ret: " << ret);
+
+       sleep(1);
+       ret = auth_passwd_reset_passwd(AUTH_PWD_NORMAL, getuid(), default_pass);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+           "Failed to reset passwd of user: " << getuid() << " with ret: " << ret);
+       sleep(1);
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, default_pass, not_allowed_passwd);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_ERROR_INVALID_PATTERN,
+           "Failed to set passwd of user: " << getuid() << " with ret: " << ret);
+       sleep(1);
+       ret = auth_passwd_set_passwd(AUTH_PWD_NORMAL, default_pass, allowed_passwd);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+           "Failed to set passwd of user: " << getuid() << " with ret: " << ret);
+
+       // restore original setting
+       ret = auth_passwd_set_pattern(policy, NULL);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to auth_passwd_set_pattern. ret: " << ret);
+
+       ret = auth_passwd_set_policy(policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to set policy. ret: " << ret);
+
+       auth_passwd_free_policy(policy);
+}
index 8af817e11a2050eefac66bf843661e6e36247f8d..3575c0b2ce08d51a7fdeb6f7a3b3cb29b95b51cd 100644 (file)
@@ -208,3 +208,68 @@ RUNNER_TEST(T00124_set)
        RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
                "Failed to auth_passwd_set_passwd for rollback. ret: " << ret);
 }
+
+RUNNER_TEST(T00125_check_passwd_available)
+{
+    policy_h *policy = nullptr;
+       const char* not_usable_passwd = "123456";
+       const char* usable_passwd = "tizen";
+
+       // prepare test
+       int ret = auth_passwd_new_policy(&policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS && policy != nullptr,
+               "Failed to make new policy. ret: " << ret);
+
+       ret = auth_passwd_set_user(policy, getuid());
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to auth_passwd_set_user. ret: " << ret);
+
+       ret = auth_passwd_set_quality(policy, AUTH_PWD_QUALITY_ALPHABETIC);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to set quality to policy handle. ret: " << ret);
+       ret = auth_passwd_set_policy(policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to set policy. ret: " << ret);
+
+       // test
+       sleep_for_retry_timeout();
+
+       ret = auth_passwd_check_passwd_available(AUTH_PWD_NORMAL, not_usable_passwd);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_ERROR_INVALID_QUALITY_TYPE,
+               "Failed to check_passwd_available: " << getuid() << " with ret: " << ret);
+
+       ret = auth_passwd_check_passwd_available(AUTH_PWD_NORMAL, usable_passwd);
+           RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to check_passwd_available: " << getuid() << " with ret: " << ret);
+
+       // restore original setting
+       ret = auth_passwd_set_quality(policy, AUTH_PWD_QUALITY_UNSPECIFIED);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to set quality to policy handle. ret: " << ret);
+       ret = auth_passwd_set_policy(policy);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to set policy. ret: " << ret);
+
+       auth_passwd_free_policy(policy);
+}
+
+RUNNER_TEST(T00126_set_password_recovery)
+{
+       int ret = AUTH_PASSWD_API_SUCCESS;
+
+       const char* recovery_passwd = "recovery_password";
+       const char* new_passwd = "new_test_password";
+
+       ret = auth_passwd_reset_passwd(AUTH_PWD_NORMAL, getuid(), default_pass);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to reset passwd of user: " << getuid() << " with ret: " << ret);
+
+       ret = auth_passwd_reset_passwd(AUTH_PWD_RECOVERY, getuid(), recovery_passwd);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to reset passwd of user: " << getuid() << " with ret: " << ret);
+
+       ret = auth_passwd_set_passwd_recovery(recovery_passwd, new_passwd);
+       RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+               "Failed to auth_passwd_set_passwd_recovery of user: " << getuid() << " with ret: " << ret);
+}
+