From cc3f289a6b0f2b0288238f1ecab55c78a4c9a3c5 Mon Sep 17 00:00:00 2001 From: Marcin Lis Date: Fri, 30 Aug 2013 12:45:29 +0200 Subject: [PATCH] Correct tests due to change in Security Server password validity calculation [Issue#] SSDWSSP-332 [Bug] Two tests fails after correction in Security Server [Cause] Test cases tc10 and tc18 use UINT_MAX as a value of valid_days for password setting. This value is now rejected by SS pwd, because it causes overflow when changing number of days to seconds. [Solution] Checking if UINT_MAX is correctly rejected when trying to set pwd Added calculation of proper max number of valid days that will not cause unsigned int overflow while changing to seconds. [Varification] Build and run tests. Change-Id: I25139243d11eba4eb58e79db0fc3b869eedb26e6 --- .../security-server-tests/security_server_tests_password.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/security-server-tests/security_server_tests_password.cpp b/tests/security-server-tests/security_server_tests_password.cpp index bb2c4fd..7c59174 100644 --- a/tests/security-server-tests/security_server_tests_password.cpp +++ b/tests/security-server-tests/security_server_tests_password.cpp @@ -259,7 +259,14 @@ RUNNER_TEST(tc10_security_server_set_pwd_current_pwd_max_valid_period_in_days) // TEST sleep(1); + // UINT_MAX will cause api error, it is to big value ret = security_server_set_pwd(TEST_PASSWORD, TEST_PASSWORD, 0, UINT_MAX); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_BAD_REQUEST, "ret = " << ret); + sleep(1); + // 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; + ret = security_server_set_pwd(TEST_PASSWORD, TEST_PASSWORD, 0, valid_days); RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } @@ -390,7 +397,10 @@ RUNNER_TEST(tc18_security_server_set_pwd_max_challenge) int ret; // Prepare environment reset_security_server(); - ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, UINT_MAX); + // 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; + ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, valid_days); RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TESTS -- 2.7.4