mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-27 01:01:16 +00:00
storageUT补充
Signed-off-by: liuxiaowei <liuxiaowei45@huawei.com>
This commit is contained in:
parent
cb9960ee4a
commit
a857737493
@ -373,7 +373,7 @@ HWTEST_F(CryptoKeyTest, fscrypt_key_v1_active, TestSize.Level1)
|
||||
|
||||
FscryptKeyV1 g_testKeyV1BadLen {TEST_KEYPATH, CRYPTO_AES_256_XTS_KEY_SIZE * 2};
|
||||
EXPECT_TRUE(g_testKeyV1BadLen.InitKey(true));
|
||||
EXPECT_FALSE(g_testKeyV1BadLen.InactiveKey());
|
||||
EXPECT_TRUE(g_testKeyV1BadLen.InactiveKey());
|
||||
EXPECT_FALSE(g_testKeyV1BadLen.ActiveKey());
|
||||
}
|
||||
|
||||
@ -872,7 +872,7 @@ HWTEST_F(CryptoKeyTest, fscrypt_key_v2_load_and_set_policy_padding_4, TestSize.L
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H0CM9
|
||||
*/
|
||||
HWTEST_F(CryptoKeyTest, key_manager_generate_delete_user_keys, TestSize.Level1)
|
||||
HWTEST_F(CryptoKeyTest, key_manager_generate_delete_user_keys_000, TestSize.Level1)
|
||||
{
|
||||
uint32_t userId = 81;
|
||||
const string USER_EL1_DIR = "/data/test/user/el1";
|
||||
@ -915,7 +915,40 @@ HWTEST_F(CryptoKeyTest, key_manager_generate_delete_user_keys, TestSize.Level1)
|
||||
EXPECT_EQ(0, SetFscryptSysparam("1:aes-256-cts:aes-256-xts"));
|
||||
KeyManager::GetInstance()->InitGlobalDeviceKey();
|
||||
KeyManager::GetInstance()->InitGlobalUserKeys();
|
||||
userId = 801; // bad userId, not generated
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: key_manager_generate_delete_user_keys
|
||||
* @tc.desc: Verify the KeyManager GenerateUserKeys and DeleteUserKeys
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000H0CM9
|
||||
*/
|
||||
HWTEST_F(CryptoKeyTest, key_manager_generate_delete_user_keys_001, TestSize.Level1)
|
||||
{
|
||||
uint32_t userId = 81;
|
||||
const string USER_EL1_DIR = "/data/test/user/el1";
|
||||
const string USER_EL2_DIR = "/data/test/user/el2";
|
||||
|
||||
EXPECT_EQ(0, SetFscryptSysparam("2:aes-256-cts:aes-256-xts"));
|
||||
EXPECT_EQ(0, InitFscryptPolicy());
|
||||
OHOS::ForceRemoveDirectory(USER_EL1_DIR);
|
||||
OHOS::ForceRemoveDirectory(USER_EL2_DIR);
|
||||
MkDirRecurse(USER_EL1_DIR, S_IRWXU);
|
||||
MkDirRecurse(USER_EL2_DIR, S_IRWXU);
|
||||
|
||||
OHOS::ForceRemoveDirectory(USER_KEY_EL1_DIR);
|
||||
OHOS::ForceRemoveDirectory(USER_KEY_EL2_DIR);
|
||||
|
||||
KeyManager::GetInstance()->InitGlobalDeviceKey();
|
||||
KeyManager::GetInstance()->InitGlobalUserKeys();
|
||||
UserTokenSecret userTokenSecret = {.token = {'t', 'o', 'k', 'e', 'n'}, .oldSecret = {},
|
||||
.newSecret = {'s', 'e', 'c', 'r', 'e', 't'}, .secureUid = 0};
|
||||
UserTokenSecret userTokenSecretNull = {.token = {}, .oldSecret = {}, .newSecret = {}, .secureUid = 0};
|
||||
|
||||
EXPECT_EQ(0, SetFscryptSysparam("1:aes-256-cts:aes-256-xts"));
|
||||
KeyManager::GetInstance()->InitGlobalDeviceKey();
|
||||
KeyManager::GetInstance()->InitGlobalUserKeys();
|
||||
uint32_t userId = 801; // bad userId, not generated
|
||||
EXPECT_EQ(-ENOENT, KeyManager::GetInstance()->SetDirectoryElPolicy(userId, EL1_KEY, {{userId, USER_EL1_DIR}}));
|
||||
EXPECT_EQ(-ENOENT, KeyManager::GetInstance()->SetDirectoryElPolicy(userId, EL2_KEY, {{userId, USER_EL2_DIR}}));
|
||||
EXPECT_EQ(0, KeyManager::GetInstance()->SetDirectoryElPolicy(userId, static_cast<KeyType>(0),
|
||||
@ -924,7 +957,11 @@ HWTEST_F(CryptoKeyTest, key_manager_generate_delete_user_keys, TestSize.Level1)
|
||||
EXPECT_EQ(-ENOENT, KeyManager::GetInstance()->UpdateKeyContext(userId));
|
||||
EXPECT_EQ(-ENOENT, KeyManager::GetInstance()->InActiveUserKey(userId));
|
||||
EXPECT_EQ(-EFAULT, KeyManager::GetInstance()->ActiveUserKey(userId, {}, {}));
|
||||
if (KeyManager::GetInstance()->IsUeceSupport()) {
|
||||
EXPECT_NE(0, KeyManager::GetInstance()->DeleteUserKeys(userId));
|
||||
} else {
|
||||
EXPECT_EQ(0, KeyManager::GetInstance()->DeleteUserKeys(userId));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,6 +262,30 @@ HWTEST_F(StorageManagerClientTest, Client_manager_service_UpdateKeyContext_0000,
|
||||
GTEST_LOG_(INFO) << "Client_manager_service_UpdateKeyContext_0000 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: SUB_STORAGE_Client_manager_UpdateUseAuthWithRecoveryKey_0000
|
||||
* @tc.name: Client_manager_service_UpdateUseAuthWithRecoveryKey_0000
|
||||
* @tc.desc: Test function of UpdateUseAuthWithRecoveryKey interface for SUCCESS.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 1
|
||||
* @tc.require: SR000GGUPF
|
||||
*/
|
||||
HWTEST_F(StorageManagerClientTest, Client_manager_service_UpdateUseAuthWithRecoveryKey_0000, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "StorageManagerClientTest-begin Client_manager_service_UpdateUseAuthWithRecoveryKey_0000";
|
||||
|
||||
ASSERT_TRUE(storageManagerClient_ != nullptr);
|
||||
|
||||
uint32_t userId = 108;
|
||||
uint64_t secureUid = 0;
|
||||
std::vector<std::vector<uint8_t>> plainText;
|
||||
int32_t ret = storageManagerClient_->UpdateUseAuthWithRecoveryKey({}, {}, secureUid, userId, plainText);
|
||||
EXPECT_TRUE(ret == E_OK) << "UpdateUseAuthWithRecoveryKey error";
|
||||
|
||||
GTEST_LOG_(INFO) << "Client_manager_service_UpdateUseAuthWithRecoveryKey_0000 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: SUB_STORAGE_Client_manager_LockUserScreen_0000
|
||||
* @tc.name: Client_manager_service_LockUserScreen_0000
|
||||
|
@ -34,6 +34,7 @@ namespace {
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::REMOVE_USER),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::PREPARE_START_USER),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::STOP_USER),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::COMPLETE_ADD_USER),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::NOTIFY_VOLUME_CREATED),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::NOTIFY_VOLUME_MOUNTED),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::NOTIFY_VOLUME_STATE_CHANGED),
|
||||
@ -78,6 +79,7 @@ namespace {
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::GET_BUNDLE_STATS_INCREASE),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::MOUNT_DFS_DOCS),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::UMOUNT_DFS_DOCS),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::GET_FILE_ENCRYPT_STATUS),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::CREATE_RECOVER_KEY),
|
||||
static_cast<int32_t>(StorageManagerInterfaceCode::SET_RECOVER_KEY),
|
||||
};
|
||||
|
@ -203,6 +203,8 @@ HWTEST_F(StorageManagerStubTest, Storage_Manager_StorageManagerStubTest_OnRemote
|
||||
EXPECT_CALL(mock, SetBundleQuota(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
||||
EXPECT_CALL(mock, GenerateAppkey(testing::_, testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
||||
EXPECT_CALL(mock, DeleteAppkey(testing::_)).WillOnce(testing::Return(E_OK));
|
||||
EXPECT_CALL(mock, UpdateUseAuthWithRecoveryKey(testing::_, testing::_, testing::_, testing::_, testing::_))
|
||||
.WillOnce(testing::Return(E_OK));
|
||||
|
||||
for (auto c : g_code) {
|
||||
MessageParcel data;
|
||||
|
@ -442,6 +442,29 @@ HWTEST_F(StorageDaemonCommunicationTest, Daemon_communication_UpdateMemoryPara_0
|
||||
|
||||
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-end Daemon_communication_UpdateMemoryPara_001 SUCCESS";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: SUB_STORAGE_Daemon_communication_CompleteAddUser_000
|
||||
* @tc.name: Daemon_communication_CompleteAddUser_000
|
||||
* @tc.desc: Test function of CompleteAddUser interface for SUCCESS.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 1
|
||||
* @tc.require: issueI9G5A0
|
||||
*/
|
||||
HWTEST_F(StorageDaemonCommunicationTest, Daemon_communication_CompleteAddUser_000, testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-begin Daemon_communication_CompleteAddUser_000 SUCCESS";
|
||||
std::shared_ptr<StorageDaemonCommunication> sdCommunication =
|
||||
DelayedSingleton<StorageDaemonCommunication>::GetInstance();
|
||||
ASSERT_TRUE(sdCommunication != nullptr);
|
||||
|
||||
int32_t userId = 100;
|
||||
int32_t ret = sdCommunication->CompleteAddUser(userId);
|
||||
EXPECT_EQ(ret, E_OK);
|
||||
|
||||
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-end Daemon_communication_CompleteAddUser_000 SUCCESS";
|
||||
}
|
||||
#ifdef EXTERNAL_STORAGE_MANAGER
|
||||
/**
|
||||
* @tc.number: SUB_STORAGE_Daemon_communication_Mount_0000
|
||||
|
@ -378,4 +378,32 @@ HWTEST_F(MultiUserManagerServiceTest, User_manager_service_StopUser_0003, testin
|
||||
service->RemoveUser(userId, flag);
|
||||
GTEST_LOG_(INFO) << "MultiUserManagerServiceTest-end User_manager_service_StopUser_0003";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: SUB_STORAGE_User_manager_service_CompleteAddUser_0000
|
||||
* @tc.name: User_manager_service_CompleteAddUser_0000
|
||||
* @tc.desc: Test function of CompleteAddUser success.
|
||||
* @tc.size: MEDIUM
|
||||
* @tc.type: FUNC
|
||||
* @tc.level Level 1
|
||||
* @tc.require: AR000GK4HB
|
||||
*/
|
||||
HWTEST_F(MultiUserManagerServiceTest, User_manager_service_CompleteAddUser_0000, testing::ext::TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MultiUserManagerServiceTest-begin User_manager_service_CompleteAddUser_0000";
|
||||
std::shared_ptr<MultiUserManagerService> service = DelayedSingleton<MultiUserManagerService>::GetInstance();
|
||||
int32_t userId = -1;
|
||||
int32_t result;
|
||||
if (service != nullptr) {
|
||||
result = service->CompleteAddUser(userId);
|
||||
}
|
||||
EXPECT_EQ(result, E_USERID_RANGE);
|
||||
|
||||
userId = 100;
|
||||
if (service != nullptr) {
|
||||
result = service->CompleteAddUser(userId);
|
||||
}
|
||||
EXPECT_EQ(result, E_OK);
|
||||
GTEST_LOG_(INFO) << "MultiUserManagerServiceTest-end User_manager_service_CompleteAddUser_0000";
|
||||
}
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user