diff --git a/services/tunnelbroker/src/Database/DatabaseManager.cpp b/services/tunnelbroker/src/Database/DatabaseManager.cpp --- a/services/tunnelbroker/src/Database/DatabaseManager.cpp +++ b/services/tunnelbroker/src/Database/DatabaseManager.cpp @@ -188,7 +188,7 @@ request.AddItem( MessageItem::FIELD_CREATED_AT, Aws::DynamoDB::Model::AttributeValue( - std::to_string(static_cast(std::time(0))))); + std::to_string(tools::getCurrentTimestamp()))); this->innerPutItem(std::make_shared(item), request); } diff --git a/services/tunnelbroker/test/DatabaseManagerTest.cpp b/services/tunnelbroker/test/DatabaseManagerTest.cpp --- a/services/tunnelbroker/test/DatabaseManagerTest.cpp +++ b/services/tunnelbroker/test/DatabaseManagerTest.cpp @@ -38,7 +38,7 @@ "6d37StvXBzfJoZVU79UeOF2bFvb3DNoArEOe", "7s6ZUSDoFfZe3eJWQ15ngYhgMw1TsfbECnMVQTYvY6OyqWPBQi5wiftFcluoxor8", static_cast(std::time(0)) + 600); - const size_t currentTimestamp = static_cast(std::time(0)); + const size_t currentTimestamp = tools::getCurrentTimestamp(); EXPECT_EQ( database::DatabaseManager::getInstance().isTableAvailable( item.getTableName()), @@ -54,9 +54,9 @@ EXPECT_EQ(item.getBlobHashes(), foundItem->getBlobHashes()); EXPECT_EQ(item.getExpire(), foundItem->getExpire()); EXPECT_EQ( - foundItem->getCreatedAt() >= currentTimestamp && - foundItem->getCreatedAt() <= static_cast(std::time(0), - true); + foundItem->getCreatedAt() >= currentTimestamp && + foundItem->getCreatedAt() <= tools::getCurrentTimestamp(), + true); database::DatabaseManager::getInstance().removeMessageItem( item.getMessageID()); }