Add new test cases for security-server password API.
authorDamian Chromejko <d.chromejko@samsung.com>
Fri, 6 Dec 2013 14:44:22 +0000 (15:44 +0100)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 14:21:36 +0000 (15:21 +0100)
[Issue#]       SSDWSSP-707
[Feature/Buf]  New test case.
[Cause]        Checking cases not considered before.
[Solution]     Added a test checking if security-server behaves as required.
               Test tc41_security_server_empty_history_check was reworked in
               SSDWSSP-708 to check reusing password after limiting history
               because, although technically a part of this issue, it was
               necessary for the whole testsuite to pass.
[Verification] Build, install, run tests.

Change-Id: I0218d5fe411c3479140095c05942bb107fcc83df

tests/security-server-tests/security_server_tests_password.cpp

index d864257..a8dcfb7 100644 (file)
@@ -1481,6 +1481,30 @@ RUNNER_TEST(tc49_security_server_no_retry_timeout_set_pwd_max_challenge)
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 }
 
+RUNNER_TEST(tc50_security_server_set_pwd_current_pwd_with_infinite_expiration_time)
+{
+    int ret;
+    unsigned int attempt, max_attempt, expire_sec;
+
+    // Prepare environment
+    reset_security_server();
+    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
+
+    // Assert security server sets infinite expiration time
+    ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0);
+    RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
+
+    ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
+    RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
+    RUNNER_ASSERT_MSG((time_t) expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME,
+            "invalid expiration time " << expire_sec);
+
+    clean_password_dir();
+}
+
 int main(int argc, char *argv[])
 {
     SummaryCollector::Register();