Add integration tests to verify releaseAllSecureStops
[ Merge of http://go/wvgerrit/15477 ]
The fix was committed to mnc-dev 25a6185c84
b/23498809
Change-Id: I298ce3f1e52866f3998d964c97a588a06b36ea92
This commit is contained in:
@@ -135,6 +135,7 @@ class DeviceFiles {
|
||||
FRIEND_TEST(WvCdmRequestLicenseTest, UnprovisionTest);
|
||||
FRIEND_TEST(WvCdmRequestLicenseTest, ForceL3Test);
|
||||
FRIEND_TEST(WvCdmRequestLicenseTest, UsageInfoRetryTest);
|
||||
FRIEND_TEST(WvCdmRequestLicenseTest, UsageReleaseAllTest);
|
||||
FRIEND_TEST(WvCdmUsageInfoTest, UsageInfo);
|
||||
FRIEND_TEST(WvCdmUsageTest, WithClientId);
|
||||
FRIEND_TEST(WvCdmExtendedDurationTest, UsageOverflowTest);
|
||||
|
||||
@@ -36,6 +36,9 @@ using ::testing::Pair;
|
||||
using ::testing::StrictMock;
|
||||
|
||||
namespace {
|
||||
|
||||
#define N_ELEM(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
const char kPathDelimiter = '/';
|
||||
|
||||
// HTTP response codes.
|
||||
@@ -1941,6 +1944,77 @@ INSTANTIATE_TEST_CASE_P(Cdm, WvCdmUsageInfoTest,
|
||||
&usage_info_sub_sample_info[6],
|
||||
&usage_info_sub_sample_info[7]));
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, UsageReleaseAllTest) {
|
||||
Unprovision();
|
||||
|
||||
std::string app_id_empty = "";
|
||||
std::string app_id_not_empty = "not empty";
|
||||
|
||||
TestWvCdmClientPropertySet property_set;
|
||||
Provision(kLevelDefault);
|
||||
|
||||
CdmSecurityLevel security_level = GetDefaultSecurityLevel();
|
||||
DeviceFiles handle;
|
||||
EXPECT_TRUE(handle.Init(security_level));
|
||||
File file;
|
||||
handle.SetTestFile(&file);
|
||||
std::vector<std::string> psts;
|
||||
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp("", &psts));
|
||||
|
||||
for (size_t i = 0; i < N_ELEM(usage_info_sub_samples_icp); ++i) {
|
||||
SubSampleInfo* data = usage_info_sub_samples_icp + i;
|
||||
property_set.set_app_id(i % 2 == 0 ? app_id_empty : app_id_not_empty);
|
||||
decryptor_.OpenSession(g_key_system, &property_set, EMPTY_ORIGIN, NULL,
|
||||
&session_id_);
|
||||
std::string key_id = a2bs_hex(
|
||||
"000000427073736800000000" // blob size and pssh
|
||||
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
|
||||
"08011a0d7769646576696e655f74657374220f73" // pssh data
|
||||
"747265616d696e675f636c6970");
|
||||
|
||||
char ch = 0x33 + i;
|
||||
key_id.append(1, ch);
|
||||
|
||||
GenerateKeyRequest(key_id, kLicenseTypeStreaming, &property_set);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||
|
||||
std::vector<uint8_t> decrypt_buffer(data->encrypt_data.size());
|
||||
CdmDecryptionParameters decryption_parameters(
|
||||
&data->key_id, &data->encrypt_data.front(), data->encrypt_data.size(),
|
||||
&data->iv, data->block_offset, &decrypt_buffer[0]);
|
||||
decryption_parameters.is_encrypted = data->is_encrypted;
|
||||
decryption_parameters.is_secure = data->is_secure;
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Decrypt(session_id_, data->validate_key_id,
|
||||
decryption_parameters));
|
||||
|
||||
EXPECT_TRUE(std::equal(data->decrypt_data.begin(), data->decrypt_data.end(),
|
||||
decrypt_buffer.begin()));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
}
|
||||
|
||||
CdmUsageInfo usage_info;
|
||||
EXPECT_EQ(KEY_MESSAGE, decryptor_.GetUsageInfo(app_id_empty, &usage_info));
|
||||
EXPECT_TRUE(usage_info.size() > 0);
|
||||
EXPECT_EQ(KEY_MESSAGE,
|
||||
decryptor_.GetUsageInfo(app_id_not_empty, &usage_info));
|
||||
EXPECT_TRUE(usage_info.size() > 0);
|
||||
|
||||
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseAllUsageInfo(app_id_not_empty));
|
||||
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.GetUsageInfo(app_id_not_empty, &usage_info));
|
||||
EXPECT_TRUE(usage_info.empty());
|
||||
EXPECT_EQ(KEY_MESSAGE, decryptor_.GetUsageInfo(app_id_empty, &usage_info));
|
||||
EXPECT_TRUE(usage_info.size() > 0);
|
||||
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseAllUsageInfo(app_id_empty));
|
||||
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.GetUsageInfo(app_id_not_empty, &usage_info));
|
||||
EXPECT_TRUE(usage_info.empty());
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.GetUsageInfo(app_id_empty, &usage_info));
|
||||
EXPECT_TRUE(usage_info.empty());
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, QueryUnmodifiedSessionStatus) {
|
||||
// Test that the global value is returned when no properties are modifying it.
|
||||
CdmQueryMap system_query_info;
|
||||
|
||||
Reference in New Issue
Block a user