*/
#include <auth-passwd-admin.h>
+#include <unistd.h>
+
#include <dpl/test/test_runner.h>
+namespace {
+
+const char *default_pass = "test-password";
+
+}
+
RUNNER_TEST_GROUP_INIT(T0020_AUTH_FW_PASSWD_ADMIN);
-RUNNER_TEST(T00201_init)
+RUNNER_TEST(T00200_init)
+{
+ int 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);
+}
+
+RUNNER_TEST(T00201_set_policy_params)
+{
+ policy_h *policy = nullptr;
+
+ 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_max_attempts(policy, 10);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set max attempts to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_validity(policy, 1);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set validity days to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_history_size(policy, 5);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set history size to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_min_length(policy, 8);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set min length to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_minComplexCharNumber(policy, 2);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set min complex char number to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_maxCharOccurrences(policy, 2);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set max char occurrence number to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_maxNumSeqLength(policy, 2);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set max num sequence length to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_quality(policy, AUTH_PWD_QUALITY_SOMETHING);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set quality to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_quality(policy, AUTH_PWD_QUALITY_NUMERIC);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set quality to policy handle. 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_quality(policy, AUTH_PWD_QUALITY_ALPHANUMERIC);
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set quality to policy handle. ret: " << ret);
+
+ ret = auth_passwd_set_forbiddenPasswd(policy, "a1b2c3d4");
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to set forbidden passwd 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(T00202_disable_policy)
{
+ int ret = auth_passwd_disable_policy(getuid());
+ RUNNER_ASSERT_MSG(ret == AUTH_PASSWD_API_SUCCESS,
+ "Failed to disable policy for uid: " << getuid() << " ret: " << ret);
}