@@ -40,7 +40,7 @@ class test_utt_storage : public libutt::api::testing::test_utt_instance {
4040 void restartStorage () { storage_ = std::make_unique<utt::client::FileBasedUserStorage>(storage_path); }
4141
4242 std::string storage_path = " ./test_storage" ;
43- std::unique_ptr<utt::client::IStorage > storage_;
43+ std::unique_ptr<utt::client::FileBasedUserStorage > storage_;
4444};
4545TEST_F (test_utt_storage, test_isNewStorage) {
4646 ASSERT_TRUE (storage_->isNewStorage ());
@@ -54,6 +54,60 @@ TEST_F(test_utt_storage, test_isNewStorage_negative) {
5454 ASSERT_TRUE (storage_->isNewStorage ());
5555}
5656
57+ TEST_F (test_utt_storage, test_set_user_id) {
58+ ASSERT_TRUE (storage_->isNewStorage ());
59+ {
60+ IStorage::tx_guard g (*storage_);
61+ storage_->setUserId (" user_1" );
62+ }
63+ restartStorage ();
64+ ASSERT_FALSE (storage_->isNewStorage ());
65+ ASSERT_EQ (storage_->getUserId (), " user_1" );
66+ }
67+
68+ TEST_F (test_utt_storage, test_get_empty_user_id) {
69+ ASSERT_TRUE (storage_->isNewStorage ());
70+ ASSERT_EQ (storage_->getUserId (), " " );
71+ }
72+
73+ TEST_F (test_utt_storage, test_assert_on_resetting_client_id) {
74+ ASSERT_TRUE (storage_->isNewStorage ());
75+ {
76+ IStorage::tx_guard g (*storage_);
77+ storage_->setUserId (" user_1" );
78+ }
79+ restartStorage ();
80+ ASSERT_NO_THROW (storage_->setUserId (" user_1" ));
81+ ASSERT_ANY_THROW (storage_->setUserId (" user_2" ));
82+ }
83+
84+ TEST_F (test_utt_storage, test_set_utt_public_config) {
85+ ASSERT_TRUE (storage_->isNewStorage ());
86+ {
87+ IStorage::tx_guard g (*storage_);
88+ storage_->setUttPublicConfig (config->getPublicConfig ());
89+ }
90+ restartStorage ();
91+ ASSERT_FALSE (storage_->isNewStorage ());
92+ ASSERT_EQ (storage_->getUttPublicConfig (), config->getPublicConfig ());
93+ }
94+
95+ TEST_F (test_utt_storage, test_get_empty_utt_public_config) {
96+ ASSERT_TRUE (storage_->isNewStorage ());
97+ ASSERT_EQ (storage_->getUttPublicConfig (), libutt::api::PublicConfig ());
98+ }
99+
100+ TEST_F (test_utt_storage, test_assert_on_utt_public_config) {
101+ ASSERT_TRUE (storage_->isNewStorage ());
102+ {
103+ IStorage::tx_guard g (*storage_);
104+ storage_->setUttPublicConfig (config->getPublicConfig ());
105+ }
106+ restartStorage ();
107+ ASSERT_NO_THROW (storage_->setUttPublicConfig (config->getPublicConfig ()));
108+ ASSERT_ANY_THROW (storage_->setUttPublicConfig (libutt::api::PublicConfig ()));
109+ }
110+
57111TEST_F (test_utt_storage, test_setKeyPair) {
58112 std::pair<std::string, std::string> keypair = {pr_keys.front (), pkeys.front ()};
59113 {
0 commit comments