-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(core): SecureStorage unit tests
- Loading branch information
1 parent
f338572
commit 23ea19a
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/sdks/core/src/cpp/sdk/cpptest/unit/securestorageTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "unit.h" | ||
|
||
class SecureStorageTest : public ::testing::Test | ||
{ | ||
protected: | ||
JsonEngine *jsonEngine; | ||
Firebolt::Error error = Firebolt::Error::None; | ||
|
||
void SetUp() override | ||
{ | ||
jsonEngine = new JsonEngine(); | ||
} | ||
|
||
void TearDown() override | ||
{ | ||
delete jsonEngine; | ||
} | ||
}; | ||
|
||
// Check enum issue with test app verse actual transport | ||
TEST_F(SecureStorageTest, Get) | ||
{ | ||
auto expectedValue = jsonEngine->get_value("SecureStorage.get"); | ||
|
||
Firebolt::SecureStorage::StorageScope scope = Firebolt::SecureStorage::StorageScope::DEVICE; | ||
|
||
std::string actualValue = Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().get(scope, "authRefreshToken", &error); | ||
|
||
EXPECT_EQ(expectedValue, actualValue); | ||
} | ||
|
||
TEST_F(SecureStorageTest, Set) | ||
{ | ||
// Call setter to set the value | ||
Firebolt::SecureStorage::StorageScope scope = Firebolt::SecureStorage::StorageScope::DEVICE; | ||
std::string expectedValue = "123456"; | ||
Firebolt::SecureStorage::StorageOptions options; | ||
options.ttl = 6.0; | ||
Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().set(scope, "authRefreshToken", expectedValue, options, &error); | ||
|
||
// Check if there was an error during the set operation | ||
EXPECT_EQ(error, Firebolt::Error::None) << "Failed to set value in SecureStorage.set() method"; | ||
} | ||
|
||
TEST_F(SecureStorageTest, Remove) | ||
{ | ||
Firebolt::SecureStorage::StorageScope scope = Firebolt::SecureStorage::StorageScope::DEVICE; | ||
Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().remove(scope, "authRefreshToken", &error); | ||
|
||
// Check if there was an error during the remove operation | ||
EXPECT_EQ(error, Firebolt::Error::None) << "Failed to remove value in SecureStorage.remove() method"; | ||
} | ||
|
||
TEST_F(SecureStorageTest, Clear) | ||
{ | ||
Firebolt::SecureStorage::StorageScope scope = Firebolt::SecureStorage::StorageScope::DEVICE; | ||
Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().clear(scope, &error); | ||
|
||
// Check if there was an error during the clear operation | ||
EXPECT_EQ(error, Firebolt::Error::None) << "Failed to clear value in SecureStorage.clear() method"; | ||
} |