Allow selective removal of Usage Table Entries by PST
This is a merge of http://go/wvgerrit/13693 in the Widevine repository. This adds level 3 and mock implementation and unit tests for the OEMCrypto function OEMCrypto_ForceDeleteUsageEntry. It also plumbs this function up into CdmEngine, CdmSession, and CryptoSession so that deleting all usage information for a given app id will now delete the entries in OEMCrypto, too. b/18194071 Change-Id: Iaea4034a507b323878657215784edfe95876386a
This commit is contained in:
@@ -1938,6 +1938,52 @@ TEST_P(DeviceFilesUsageInfoTest, Delete) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(DeviceFilesUsageInfoTest, DeleteAll) {
|
||||
MockFile file;
|
||||
std::string app_id; // TODO(fredgc): expand tests.
|
||||
std::string path =
|
||||
device_base_path_ + DeviceFiles::GetUsageInfoFileName(app_id);
|
||||
|
||||
int index = GetParam();
|
||||
EXPECT_CALL(file, IsDirectory(StrEq(device_base_path_)))
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(file, CreateDirectory(_)).Times(0);
|
||||
EXPECT_CALL(file, Write(_, _)).Times(0);
|
||||
|
||||
std::string data;
|
||||
if (index < 0) {
|
||||
EXPECT_CALL(file, Exists(StrEq(path))).WillOnce(Return(false));
|
||||
} else {
|
||||
data = kUsageInfoTestData[index].file_data;
|
||||
EXPECT_CALL(file, Exists(StrEq(path))).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(file, FileSize(StrEq(path))).WillOnce(Return(data.size()));
|
||||
EXPECT_CALL(file, Open(StrEq(path), IsBinaryFileFlagSet()))
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(file, Read(NotNull(), Eq(data.size())))
|
||||
.WillOnce(DoAll(SetArrayArgument<0>(data.begin(), data.end()),
|
||||
Return(data.size())));
|
||||
EXPECT_CALL(file, Close()).Times(1);
|
||||
EXPECT_CALL(file, Remove(StrEq(path))).WillOnce(Return(true));
|
||||
}
|
||||
|
||||
DeviceFiles device_files;
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
device_files.SetTestFile(&file);
|
||||
|
||||
std::vector<std::string> psts;
|
||||
ASSERT_TRUE(device_files.DeleteAllUsageInfoForApp(app_id, &psts));
|
||||
if (index < 0) {
|
||||
EXPECT_EQ(0u, psts.size());
|
||||
} else {
|
||||
// DeleteAllUsageInfoForApp returns a list of all psts that
|
||||
// should be deleted by oemcrypto.
|
||||
EXPECT_EQ(static_cast<unsigned int>(index), psts.size());
|
||||
for(int i=0; i < index; i++) {
|
||||
EXPECT_EQ(kUsageInfoTestData[i+1].provider_session_token, psts[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(UsageInfo, DeviceFilesUsageInfoTest,
|
||||
::testing::Values(-1, 0, 1, 2, 3));
|
||||
|
||||
|
||||
@@ -845,7 +845,7 @@ TEST_F(PolicyEngineTest, QuerySuccess_LicenseStartTimeNotSet) {
|
||||
|
||||
CdmQueryMap query_info;
|
||||
EXPECT_EQ(NO_ERROR, policy_engine_->Query(&query_info));
|
||||
EXPECT_EQ(0, query_info.size());
|
||||
EXPECT_EQ(0u, query_info.size());
|
||||
}
|
||||
|
||||
TEST_F(PolicyEngineTest, QuerySuccess) {
|
||||
|
||||
Reference in New Issue
Block a user