Remove password retry timeouts where not needed.
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 7 Feb 2014 11:00:12 +0000 (12:00 +0100)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Wed, 12 Mar 2014 11:00:24 +0000 (12:00 +0100)
Replace related magic numbers with proper define.

[Issue#]        N/A
[Feature]       Some timeouts are no longer needed.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build and run security-server tests on the target.
                Verify with both smack and nosmack variants.

Change-Id: I75ab774048c0f5793bde7c7f36e423d8cd8a1275

tests/security-server-tests/CMakeLists.txt
tests/security-server-tests/common/security_server_tests_common.cpp
tests/security-server-tests/common/security_server_tests_common.h
tests/security-server-tests/security_server_tests_password.cpp
tests/security-server-tests/server.cpp

index 10cf3a3..8f3ff58 100644 (file)
@@ -34,6 +34,7 @@ PKG_CHECK_MODULES(SEC_SRV_TESTS_DEP
 
 # Targets definition
 
+SET(TARGET_SEC_SRV_COMMON "security-server-tests-common")
 SET(TARGET_SEC_SRV_CLIENT_SMACK_TESTS "security-server-tests-client-smack")
 SET(TARGET_SEC_SRV_TC_SERVER_TESTS "security-server-tests-server")
 SET(TARGET_SEC_SRV_PWD_TESTS "security-server-tests-password")
@@ -45,6 +46,10 @@ SET(TARGET_SEC_SRV_MEASURER "security-server-tests-api-speed")
 
 # Sources definition
 
+SET(SEC_SRV_COMMON_SOURCES
+    ${PROJECT_SOURCE_DIR}/tests/security-server-tests/common/security_server_tests_common.cpp
+   )
+
 SET(SEC_SRV_CLIENT_SMACK_SOURCES
     ${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_tests_client_smack.cpp
     ${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_mockup.cpp
@@ -55,7 +60,6 @@ SET(SEC_SRV_TC_SERVER_SOURCES
     ${PROJECT_SOURCE_DIR}/tests/security-server-tests/open_for.cpp
     ${PROJECT_SOURCE_DIR}/tests/security-server-tests/cookie_api.cpp
     ${PROJECT_SOURCE_DIR}/tests/security-server-tests/weird_arguments.cpp
-    ${PROJECT_SOURCE_DIR}/tests/security-server-tests/common/security_server_tests_common.cpp
     ${PROJECT_SOURCE_DIR}/tests/security-server-tests/security_server_clean_env.cpp
    )
 
@@ -94,6 +98,7 @@ ADD_DEFINITIONS("-I/usr/include/dbus-1.0/dbus")
 
 #LINK_DIRECTORIES(${SEC_SRV_PKGS_LIBRARY_DIRS})
 
+ADD_LIBRARY(${TARGET_SEC_SRV_COMMON} STATIC ${SEC_SRV_COMMON_SOURCES})
 ADD_EXECUTABLE(${TARGET_SEC_SRV_CLIENT_SMACK_TESTS} ${SEC_SRV_CLIENT_SMACK_SOURCES})
 ADD_EXECUTABLE(${TARGET_SEC_SRV_TC_SERVER_TESTS} ${SEC_SRV_TC_SERVER_SOURCES})
 ADD_EXECUTABLE(${TARGET_SEC_SRV_PWD_TESTS} ${SEC_SRV_PWD_SOURCES})
@@ -108,10 +113,12 @@ TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_CLIENT_SMACK_TESTS}
     tests-common)
 
 TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_TC_SERVER_TESTS}
+    ${TARGET_SEC_SRV_COMMON}
     ${SEC_SRV_TESTS_DEP_LIBRARIES}
     tests-common)
 
 TARGET_LINK_LIBRARIES(${TARGET_SEC_SRV_PWD_TESTS}
+    ${TARGET_SEC_SRV_COMMON}
     ${SEC_SRV_TESTS_DEP_LIBRARIES}
     tests-common)
 
index 9051058..942749c 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "security_server_tests_common.h"
 
+const unsigned int PASSWORD_RETRY_TIMEOUT_US = 500000;
+
 void check_app_has_privilege(const char *app_id, const app_type_t app_type,
                              const char *perm_list[], const int expected_result)
 {
index e2e774b..275cadf 100644 (file)
@@ -28,6 +28,8 @@
 #ifndef SECURITY_SERVER_TESTS_COMMON_H_
 #define SECURITY_SERVER_TESTS_COMMON_H_
 
+extern const unsigned int PASSWORD_RETRY_TIMEOUT_US;
+
 void check_app_has_privilege(const char *app_id, const app_type_t app_type,
                              const char *perm_list[], const int expected_result);
 
index dd3ecb3..4f63cda 100644 (file)
 #include <tests_common.h>
 #include <dlog.h>
 #include "security_server_clean_env.h"
+#include "security_server_tests_common.h"
 #include <summary_collector.h>
 
 
-// security server retry timeout in microseconds
-const unsigned int PASSWORD_RETRY_TIMEOUT_US = 500000;
-
 // the maximum time (in seconds) passwords can expire in
 const unsigned int PASSWORD_INFINITE_EXPIRATION_TIME = 0xFFFFFFFF;
 
@@ -246,11 +244,11 @@ RUNNER_TEST(tc10_security_server_set_pwd_current_pwd_max_valid_period_in_days)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     // UINT_MAX will cause api error, it is to big value
     ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, UINT_MAX);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     // calculate max applicable valid days that will not be rejected by ss
     // ensure, that after conversion from days to seconds in ss there will be no uint overflow
     unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1;
@@ -270,7 +268,7 @@ RUNNER_TEST(tc11_security_server_set_pwd_current_pwd_max_max_challenge)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, UINT_MAX, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 }
@@ -287,7 +285,7 @@ RUNNER_TEST(tc12_security_server_set_pwd_current_pwd_nonempty2zero)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd(TEST_PASSWORD, "", 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 }
@@ -304,7 +302,7 @@ RUNNER_TEST(tc14_security_server_set_pwd_current_pwd_too_long_input_param)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     std::string lng_pwd(5000, 'A');
     ret = security_server_set_pwd(TEST_PASSWORD,lng_pwd.c_str(), 10, 10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
@@ -324,7 +322,7 @@ RUNNER_TEST(tc15_security_server_chk_pwd_empty_password)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd("", &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 }
@@ -369,7 +367,6 @@ RUNNER_TEST(tc17_security_server_is_pwd_valid)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST:
-    sleep(1);
     ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST,  "ret = " << ret);
     RUNNER_ASSERT_MSG_BT((expire_sec > 172795) && (expire_sec < 172805),  "expire_sec = " << expire_sec);
@@ -390,19 +387,15 @@ RUNNER_TEST(tc18_security_server_set_pwd_max_challenge)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TESTS
-    sleep(1);
     ret = security_server_set_pwd_max_challenge(0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_max_challenge(UINT_MAX);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_max_challenge(5);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_max_challenge(6);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 }
@@ -419,7 +412,7 @@ RUNNER_TEST(tc19_security_server_is_pwd_valid)
     reset_security_server();
     ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
-    sleep(1);
+
     ret = security_server_set_pwd_max_challenge(6);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -443,11 +436,10 @@ RUNNER_TEST(tc20_security_server_chk_pwd)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, ret);
 
-    sleep(1);
     ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
 }
@@ -466,7 +458,7 @@ RUNNER_TEST(tc21_security_server_chk_incorrect_pwd)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
 }
@@ -484,7 +476,7 @@ RUNNER_TEST(tc22_security_server_set_pwd_incorrect_current)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd(SECOND_TEST_PASSWORD, THIRD_TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH,  "ret = " << ret);
 }
@@ -502,7 +494,7 @@ RUNNER_TEST(tc23_security_server_set_pwd_correct_current)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 }
@@ -523,18 +515,17 @@ RUNNER_TEST(tc24_security_server_attempt_exceeding)
     // TEST
     printf("5 subtests started...");
     for (i = 1; i <= 5; i++) {
-        sleep(1);
+        usleep(PASSWORD_RETRY_TIMEOUT_US);
         ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
         RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
         RUNNER_ASSERT_MSG_BT(attempt == i, "attempt = " << attempt << ", expected " << i);
     }
     printf("DONE\n");
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
     RUNNER_ASSERT_MSG_BT(attempt == 0, "ret = " << ret);
@@ -557,19 +548,19 @@ RUNNER_TEST(tc25_security_server_attempt_exceeding)
     // TEST
     printf("10 subtests started...");
     for (i = 1; i <= 10; i++) {
-        sleep(1);
+        usleep(PASSWORD_RETRY_TIMEOUT_US);
         ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
         RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
         RUNNER_ASSERT_MSG_BT(attempt == i, "attempt = " << attempt << ", expected " << i);
     }
 
     // The check, that exceeds max number
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED, "ret = " << ret);
     printf("DONE\n");
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd(TEST_PASSWORD,  &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED, "ret = " << ret);
 }
@@ -587,7 +578,6 @@ RUNNER_TEST(tc26_security_server_reset_pwd)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
     ret = security_server_reset_pwd(TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 }
@@ -624,7 +614,6 @@ RUNNER_TEST(tc28_security_server_check_expiration)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
     ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
     RUNNER_ASSERT_MSG_BT((expire_sec < 86402) && (expire_sec > 86396), "expire_sec = " << ret);
@@ -643,35 +632,27 @@ RUNNER_TEST(tc29_security_server_set_pwd_history)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TESTS
-    sleep(1);
     ret = security_server_set_pwd_history(100);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(51);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(-5);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(50);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(INT_MAX);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(INT_MIN);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 }
@@ -720,7 +701,6 @@ RUNNER_TEST(tc30_security_server_check_history)
     ret = security_server_set_pwd_history(9);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    sleep(1);
     ret = security_server_reset_pwd("history0", 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -729,27 +709,27 @@ RUNNER_TEST(tc30_security_server_check_history)
         sprintf(buf1, "history%d", i);
         sprintf(buf2, "history%d", i + 1);
 
-        sleep(1);
+        usleep(PASSWORD_RETRY_TIMEOUT_US);
         ret = security_server_set_pwd(buf1, buf2, 0, 0);
         RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
     }
     printf("DONE\n");
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd("history11", "history1", 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd("history1", "history8", 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd("history1", "history12", 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     printf("48 subtests started...");
     for (i = 12; i < 60; i++) {
-        sleep(1);
+        usleep(PASSWORD_RETRY_TIMEOUT_US);
 
         sprintf(buf1, "history%d", i);
         sprintf(buf2, "history%d", i + 1);
@@ -771,7 +751,7 @@ RUNNER_TEST(tc31_security_server_replay_attack)
     int i = 0;
     unsigned int attempt, max_attempt, expire_sec;
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd("quickquickquick", &attempt, &max_attempt, &expire_sec);
 
     while (ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER) {
@@ -799,7 +779,7 @@ RUNNER_TEST(tc32_security_server_challenge_on_expired_password)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -810,11 +790,11 @@ RUNNER_TEST(tc32_security_server_challenge_on_expired_password)
     ret = settimeofday(&cur_time, NULL);
     RUNNER_ASSERT_MSG_BT(ret > -1, ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXPIRED, "ret = " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret);
 }
@@ -922,7 +902,6 @@ RUNNER_TEST(tc34_security_server_max_attempts)
     for (size_t pass = 0; pass < max_challenge_tab.size(); ++pass) {
         unsigned int max_challenges = max_challenge_tab[pass];
 
-        usleep(PASSWORD_RETRY_TIMEOUT_US);
         ret = security_server_set_pwd_max_challenge(max_challenges);
         RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -964,7 +943,6 @@ RUNNER_TEST(tc35_security_server_decrease_max_attempts)
                        std::string("attempt = ") + std::to_string(attempt));
 
     // lower max_challenge
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd_max_challenge(max_challenge_less);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -972,7 +950,6 @@ RUNNER_TEST(tc35_security_server_decrease_max_attempts)
     verify_chk_pwd(TEST_PASSWORD, SECURITY_SERVER_API_SUCCESS, 1, max_challenge_less);
 
     // remove max attempts limit
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd_max_challenge(0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -1004,7 +981,6 @@ RUNNER_TEST(tc36_security_server_challenge_previous_passwords)
     int ret = security_server_set_pwd_history(history_depth);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_reset_pwd(TEST_PASSWORD, max_challenge, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -1115,7 +1091,6 @@ RUNNER_TEST(tc38_security_server_history_depth_change)
     ret = security_server_set_pwd_history(initial_history_depth);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -1136,7 +1111,6 @@ RUNNER_TEST(tc38_security_server_history_depth_change)
      * Lower history depth. At this point SS should treat THIRD_TEST_PASSWORD as current pwd,
      * and SECOND_TEST_PASSWORD as a part of history.
      */
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd_history(decreased_history_depth);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -1152,7 +1126,6 @@ RUNNER_TEST(tc38_security_server_history_depth_change)
      * Increase history depth to 3. At this point SS should remember TEST_PASSWORD
      * and THIRD_TEST_PASSWORD only.
      */
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd_history(increased_history_depth);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -1190,7 +1163,6 @@ RUNNER_TEST(tc39_security_server_attempts_num_check_after_reset)
             attempt,
             max_challenge);
 
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     attempt = max_attempt = expire_sec = UINT_MAX;
     ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
@@ -1230,7 +1202,6 @@ RUNNER_TEST(tc40_security_server_history_check_after_reset)
     int ret = security_server_set_pwd_history(history_depth);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -1279,7 +1250,6 @@ RUNNER_TEST(tc41_security_server_empty_history_check)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //set new password and fill history
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
@@ -1301,7 +1271,6 @@ RUNNER_TEST(tc41_security_server_empty_history_check)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret);
 
     //reset history limit to no history at all
-    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd_history(empty_history_depth);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
index 68a751d..07d3581 100644 (file)
@@ -211,19 +211,17 @@ RUNNER_CHILD_TEST_SMACK(tc03_check_API_passwd_allow)
     ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd(NULL, "12345", 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
 
-    sleep(1);
     ret = security_server_reset_pwd("12345",0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd("12345", &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
 }
@@ -264,19 +262,17 @@ RUNNER_CHILD_TEST(tc04_check_API_passwd_denied)
     ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd("12345", "12346", 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
 
-    sleep(1);
     ret = security_server_reset_pwd("12346",0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd("12346", &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret);
 }
@@ -521,8 +517,6 @@ int clear_password_nosmack()
         RUNNER_ASSERT_MSG_BT(max_attempt == 0, "max_attempt = " << max_attempt << ", should be 0.");
         RUNNER_ASSERT_MSG_BT(attempt == 0, "attempt = " << attempt << ", should be 0.");
 
-        sleep(1);
-
         return 0;
     }
     return -1;
@@ -562,22 +556,20 @@ RUNNER_CHILD_TEST_NOSMACK(tc03_check_API_passwd_allow_nosmack)
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD,
             "is_pwd_valid should return no password error. Result: " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_set_pwd(NULL, "12345", 0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS,
             "set_pwd failed. Result: " << ret);
 
-    sleep(1);
     ret = security_server_reset_pwd("12345",0, 0);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS,
             "reset_pwd failed. Result: " << ret);
 
-    sleep(1);
+    usleep(PASSWORD_RETRY_TIMEOUT_US);
     ret = security_server_chk_pwd("12345", &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS,
             "chk_pwd failed. Result: " << ret);
 
-    sleep(1);
     ret = security_server_set_pwd_history(10);
     RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS,
             "set_pwd_history failed. Result: " << ret);