Correct tests due to change in Security Server password validity calculation
authorMarcin Lis <m.lis@samsung.com>
Fri, 30 Aug 2013 10:45:29 +0000 (12:45 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 14:07:38 +0000 (15:07 +0100)
[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

tests/security-server-tests/security_server_tests_password.cpp

index bb2c4fd..7c59174 100644 (file)
@@ -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