Fixes for query information and usage reporting
* The Usage APIs return usage reports from either L1 or L3 (if available). * Correction to when usage reports are saved. In addition to other events they are now saved when keys are loaded, usage reports are released and soon after first decryption and periodically (60 seconds) after that, if decryption takes place. * Usage reports now get deleted on an unprovision request. * Policy timer is now started when offline licenses are restored. * Usage session is now released, when a usage response is received. * Usage tests ahev been enabled. * Added CDM extended duration (integration) tests to test usage reporting and querying. These need to be run manually as they take a while (currently half an hour). b/15592374 [ Merge of https://widevine-internal-review.googlesource.com/#/c/10800 from the Widevine CDM repo ] Change-Id: Ia817e03ebbe880e08ba7b4a235ecb82b3ff35fbf
This commit is contained in:
@@ -581,8 +581,49 @@ class WvCdmRequestLicenseTest : public testing::Test {
|
||||
}
|
||||
}
|
||||
|
||||
void Unprovision() {
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL1));
|
||||
EXPECT_EQ(NO_ERROR, decryptor_.Unprovision(kSecurityLevelL3));
|
||||
}
|
||||
|
||||
void Provision() {
|
||||
CdmResponseType status =
|
||||
decryptor_.OpenSession(g_key_system, NULL, &session_id_);
|
||||
switch (status) {
|
||||
case NO_ERROR:
|
||||
decryptor_.CloseSession(session_id_);
|
||||
return;
|
||||
case NEED_PROVISIONING:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(NO_ERROR, status);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
|
||||
status = decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &key_msg_, &provisioning_server_url);
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, status);
|
||||
if (NO_ERROR != status) return;
|
||||
EXPECT_EQ(provisioning_server_url, g_config->provisioning_server_url());
|
||||
|
||||
std::string response =
|
||||
GetCertRequestResponse(g_config->provisioning_server_url());
|
||||
EXPECT_NE(0, static_cast<int>(response.size()));
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.HandleProvisioningResponse(
|
||||
response, &cert, &wrapped_key));
|
||||
EXPECT_EQ(0, static_cast<int>(cert.size()));
|
||||
EXPECT_EQ(0, static_cast<int>(wrapped_key.size()));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string GetSecurityLevel(TestWvCdmClientPropertySet* property_set) {
|
||||
decryptor_.OpenSession(g_key_system, property_set, &session_id_);
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.OpenSession(g_key_system, property_set, &session_id_));
|
||||
CdmQueryMap query_info;
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.QuerySessionStatus(session_id_, &query_info));
|
||||
@@ -864,6 +905,9 @@ TEST_F(WvCdmRequestLicenseTest, AddStreamingKeyTest) {
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, AddKeyOfflineTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
// override default settings unless configured through the command line
|
||||
std::string key_id;
|
||||
std::string client_auth;
|
||||
@@ -876,6 +920,9 @@ TEST_F(WvCdmRequestLicenseTest, AddKeyOfflineTest) {
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
// override default settings unless configured through the command line
|
||||
std::string key_id;
|
||||
std::string client_auth;
|
||||
@@ -896,6 +943,9 @@ TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) {
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
// override default settings unless configured through the command line
|
||||
std::string key_id;
|
||||
std::string client_auth;
|
||||
@@ -923,6 +973,9 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
// override default settings unless configured through the command line
|
||||
std::string key_id;
|
||||
std::string client_auth;
|
||||
@@ -959,6 +1012,9 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
|
||||
Unprovision();
|
||||
Provision();
|
||||
|
||||
// override default settings unless configured through the command line
|
||||
std::string key_id;
|
||||
std::string client_auth;
|
||||
@@ -1034,7 +1090,7 @@ class WvCdmUsageInfoTest
|
||||
: public WvCdmRequestLicenseTest,
|
||||
public ::testing::WithParamInterface<UsageInfoSubSampleInfo*> {};
|
||||
|
||||
TEST_P(WvCdmUsageInfoTest, DISABLED_UsageInfo) {
|
||||
TEST_P(WvCdmUsageInfoTest, UsageInfo) {
|
||||
CdmSecurityLevel security_level = GetDefaultSecurityLevel();
|
||||
DeviceFiles handle;
|
||||
EXPECT_TRUE(handle.Init(security_level));
|
||||
|
||||
Reference in New Issue
Block a user