Add unit tests for offline licenses without session usage
[ Merge of http://go/wvgerrit/14824 ] OEMCrypto v9 added support for secure usage reporting with the help of a session usage table. This was enabled through the replay control bits in the key control block. It was expected that streaming licenses would enable the nonce required bit, while offline licenses would enable session usage table entry flag. There are certain cases where content providers would prefer not to enable the flag for offline licenses and this test verifies that this scenario works. b/17514500 Change-Id: Icd1bea8cec2fd52be2be249424891ce1755d5f25
This commit is contained in:
@@ -43,6 +43,10 @@ const int kHttpOk = 200;
|
||||
const int kHttpBadRequest = 400;
|
||||
const int kHttpInternalServerError = 500;
|
||||
|
||||
// Protobuf generated classes
|
||||
using video_widevine_server::sdk::LicenseIdentification;
|
||||
using video_widevine_server::sdk::LicenseRequest_ContentIdentification;
|
||||
|
||||
// Default license server, can be configured using --server command line option
|
||||
// Default key id (pssh), can be configured using --keyid command line option
|
||||
std::string g_client_auth;
|
||||
@@ -829,7 +833,7 @@ TEST_F(WvCdmRequestLicenseTest, ProvisioningInterposedRetryTest) {
|
||||
std::string provisioning_server_url;
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
std::string key_msg1, key_msg2;
|
||||
CdmKeyMessage key_msg1, key_msg2;
|
||||
|
||||
EXPECT_EQ(wvcdm::NO_ERROR, decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, EMPTY_ORIGIN,
|
||||
@@ -1162,6 +1166,63 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeySessionUsageDisabledTest) {
|
||||
Unprovision();
|
||||
Provision(kLevelDefault);
|
||||
|
||||
// The default offline asset "offline_clip2" has the session usage table
|
||||
// entry enabled in the replay control portion of the key control block.
|
||||
// To have it disabled we must use "offline_clip1", so replace the last
|
||||
// char in init data with '1'
|
||||
std::string key_id;
|
||||
std::string client_auth;
|
||||
GetOfflineConfiguration(&key_id, &client_auth);
|
||||
key_id[key_id.size()-1] = '1';
|
||||
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
GenerateKeyRequest(key_id, kLicenseTypeOffline);
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
CdmKeySetId key_set_id = key_set_id_;
|
||||
EXPECT_FALSE(key_set_id_.empty());
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
session_id_.clear();
|
||||
key_set_id_.clear();
|
||||
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
|
||||
decryptor_.CloseSession(session_id_);
|
||||
|
||||
session_id_.clear();
|
||||
key_set_id_.clear();
|
||||
CdmKeyMessage key_msg;
|
||||
GenerateKeyRelease(key_set_id, NULL, &key_msg);
|
||||
key_set_id_ = key_set_id;
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
SignedMessage signed_message;
|
||||
EXPECT_TRUE(signed_message.ParseFromString(key_msg));
|
||||
EXPECT_EQ(SignedMessage::LICENSE_REQUEST, signed_message.type());
|
||||
EXPECT_TRUE(signed_message.has_signature());
|
||||
EXPECT_TRUE(!signed_message.msg().empty());
|
||||
|
||||
// Verify license request
|
||||
video_widevine_server::sdk::LicenseRequest license_renewal;
|
||||
EXPECT_TRUE(license_renewal.ParseFromString(signed_message.msg()));
|
||||
|
||||
// Verify Content Identification
|
||||
const LicenseRequest_ContentIdentification& content_id =
|
||||
license_renewal.content_id();
|
||||
EXPECT_FALSE(content_id.has_cenc_id());
|
||||
EXPECT_FALSE(content_id.has_webm_id());
|
||||
EXPECT_TRUE(content_id.has_license());
|
||||
|
||||
const LicenseRequest_ContentIdentification::ExistingLicense&
|
||||
existing_license = content_id.license();
|
||||
EXPECT_TRUE(existing_license.license_id().provider_session_token().empty());
|
||||
EXPECT_TRUE(existing_license.session_usage_table_entry().empty());
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
|
||||
Unprovision();
|
||||
Provision(kLevelDefault);
|
||||
|
||||
Reference in New Issue
Block a user