Secure stop API related changes
[ Merge of http://go/wvgerrit/44921 ] * Added the ability to remove a single usage information record. * Added a method to retrieve all secure stop Ids. Bug: 69674645 Test: WV unit, integration tests Change-Id: I04ac8224b4bdda69541e61ff1103af3836138228
This commit is contained in:
@@ -2629,6 +2629,73 @@ TEST_F(DeviceFilesUsageInfoTest, ListNullParam) {
|
||||
EXPECT_FALSE(device_files.ListUsageInfoFiles(NULL));
|
||||
}
|
||||
|
||||
TEST_F(DeviceFilesUsageInfoTest, ListIdsNull) {
|
||||
MockFileSystem file_system;
|
||||
MockFile file;
|
||||
|
||||
std::string app_id = kUsageInfoTestData[0].app_id;
|
||||
|
||||
DeviceFiles device_files(&file_system);
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
EXPECT_FALSE(device_files.ListUsageIds(app_id, NULL, NULL));
|
||||
}
|
||||
|
||||
TEST_F(DeviceFilesUsageInfoTest, ListUsageIds) {
|
||||
MockFileSystem file_system;
|
||||
MockFile file;
|
||||
|
||||
int index = 8;
|
||||
std::string app_id = kUsageInfoTestData[index].app_id;
|
||||
|
||||
std::string file_name = DeviceFiles::GetUsageInfoFileName(app_id);
|
||||
std::string path = device_base_path_ + file_name;
|
||||
std::string file_data = (index < 0) ? kEmptyUsageInfoFileData
|
||||
: kUsageInfoTestData[index].file_data;
|
||||
if (index >= 0) {
|
||||
EXPECT_CALL(file_system, Exists(StrEq(path)))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(file_system, FileSize(StrEq(path)))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(kUsageInfoTestData[index].file_data.size()));
|
||||
EXPECT_CALL(file_system, Open(StrEq(path), _)).WillOnce(Return(&file));
|
||||
EXPECT_CALL(file,
|
||||
Read(NotNull(), Eq(kUsageInfoTestData[index].file_data.size())))
|
||||
.WillOnce(DoAll(SetArrayArgument<0>(file_data.begin(), file_data.end()),
|
||||
Return(file_data.size())));
|
||||
EXPECT_CALL(file, Close());
|
||||
}
|
||||
else {
|
||||
EXPECT_CALL(file_system, Exists(StrEq(path)))
|
||||
.WillOnce(Return(false));
|
||||
}
|
||||
|
||||
DeviceFiles device_files(&file_system);
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
|
||||
std::vector<std::string> key_set_ids;
|
||||
std::vector<std::string> provider_session_tokens;
|
||||
EXPECT_TRUE(device_files.ListUsageIds(
|
||||
app_id, &key_set_ids, &provider_session_tokens));
|
||||
|
||||
EXPECT_EQ(key_set_ids.size(), provider_session_tokens.size());
|
||||
if (index >= 0) {
|
||||
for (size_t i = 0; i < provider_session_tokens.size(); ++i) {
|
||||
bool found = false;
|
||||
for (int j = 0; !found && j <= index; ++j) {
|
||||
if (app_id == kUsageInfoTestData[j].app_id &&
|
||||
kUsageInfoTestData[j].usage_data.provider_session_token ==
|
||||
provider_session_tokens[i] &&
|
||||
kUsageInfoTestData[j].usage_data.key_set_id ==
|
||||
key_set_ids[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(DeviceFilesUsageInfoListTest, UsageInfoList) {
|
||||
MockFileSystem file_system;
|
||||
MockFile file;
|
||||
@@ -2767,6 +2834,113 @@ TEST_P(DeviceFilesUsageInfoTest, Retrieve) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(DeviceFilesUsageInfoTest, ListKeySetIds) {
|
||||
MockFileSystem file_system;
|
||||
MockFile file;
|
||||
|
||||
int index = GetParam();
|
||||
|
||||
std::string app_id;
|
||||
if (index >= 0) app_id = kUsageInfoTestData[index].app_id;
|
||||
|
||||
std::string file_name = DeviceFiles::GetUsageInfoFileName(app_id);
|
||||
std::string path = device_base_path_ + file_name;
|
||||
std::string file_data = (index < 0) ? kEmptyUsageInfoFileData
|
||||
: kUsageInfoTestData[index].file_data;
|
||||
if (index >= 0) {
|
||||
EXPECT_CALL(file_system, Exists(StrEq(path)))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(file_system, FileSize(StrEq(path)))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(kUsageInfoTestData[index].file_data.size()));
|
||||
EXPECT_CALL(file_system, Open(StrEq(path), _)).WillOnce(Return(&file));
|
||||
EXPECT_CALL(file,
|
||||
Read(NotNull(), Eq(kUsageInfoTestData[index].file_data.size())))
|
||||
.WillOnce(DoAll(SetArrayArgument<0>(file_data.begin(), file_data.end()),
|
||||
Return(file_data.size())));
|
||||
EXPECT_CALL(file, Close());
|
||||
}
|
||||
else {
|
||||
EXPECT_CALL(file_system, Exists(StrEq(path)))
|
||||
.WillOnce(Return(false));
|
||||
}
|
||||
|
||||
DeviceFiles device_files(&file_system);
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
|
||||
std::vector<std::string> key_set_ids;
|
||||
EXPECT_TRUE(device_files.ListUsageIds(app_id, &key_set_ids, NULL));
|
||||
|
||||
if (index >= 0) {
|
||||
for (size_t i = 0; i < key_set_ids.size(); ++i) {
|
||||
bool found = false;
|
||||
for (int j = 0; !found && j <= index; ++j) {
|
||||
if (app_id == kUsageInfoTestData[j].app_id &&
|
||||
kUsageInfoTestData[j].usage_data.key_set_id ==
|
||||
key_set_ids[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(DeviceFilesUsageInfoTest, ListProviderSessionTokenIds) {
|
||||
MockFileSystem file_system;
|
||||
MockFile file;
|
||||
|
||||
int index = GetParam();
|
||||
|
||||
std::string app_id;
|
||||
if (index >= 0) app_id = kUsageInfoTestData[index].app_id;
|
||||
|
||||
std::string file_name = DeviceFiles::GetUsageInfoFileName(app_id);
|
||||
std::string path = device_base_path_ + file_name;
|
||||
std::string file_data = (index < 0) ? kEmptyUsageInfoFileData
|
||||
: kUsageInfoTestData[index].file_data;
|
||||
if (index >= 0) {
|
||||
EXPECT_CALL(file_system, Exists(StrEq(path)))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(file_system, FileSize(StrEq(path)))
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(kUsageInfoTestData[index].file_data.size()));
|
||||
EXPECT_CALL(file_system, Open(StrEq(path), _)).WillOnce(Return(&file));
|
||||
EXPECT_CALL(file,
|
||||
Read(NotNull(), Eq(kUsageInfoTestData[index].file_data.size())))
|
||||
.WillOnce(DoAll(SetArrayArgument<0>(file_data.begin(), file_data.end()),
|
||||
Return(file_data.size())));
|
||||
EXPECT_CALL(file, Close());
|
||||
}
|
||||
else {
|
||||
EXPECT_CALL(file_system, Exists(StrEq(path)))
|
||||
.WillOnce(Return(false));
|
||||
}
|
||||
|
||||
DeviceFiles device_files(&file_system);
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
|
||||
std::vector<std::string> provider_session_tokens;
|
||||
EXPECT_TRUE(
|
||||
device_files.ListUsageIds(app_id, NULL, &provider_session_tokens));
|
||||
|
||||
if (index >= 0) {
|
||||
for (size_t i = 0; i < provider_session_tokens.size(); ++i) {
|
||||
bool found = false;
|
||||
for (int j = 0; !found && j <= index; ++j) {
|
||||
if (app_id == kUsageInfoTestData[j].app_id &&
|
||||
kUsageInfoTestData[j].usage_data.provider_session_token ==
|
||||
provider_session_tokens[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(DeviceFilesUsageInfoTest, RetrieveByProviderSessionToken) {
|
||||
MockFileSystem file_system;
|
||||
MockFile file;
|
||||
|
||||
Reference in New Issue
Block a user