Source release v3.0.0-0-g8d3792b-ce + third_party

Change-Id: I399e71ddfffcd436171d1c60283c63ab4658e0b1
This commit is contained in:
Joey Parrish
2015-06-19 15:13:34 -07:00
parent 58aba6b2ec
commit 0546ee6732
965 changed files with 426663 additions and 12897 deletions

View File

@@ -1,709 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
//
// This source file provides a basic set of unit tests for the Content
// Decryption Module (CDM). It exercises much of the API that will be
// required by the host application to get the license and keys for
// rendering protected content.
#include "cdm_test_config.h"
#include "test_host_1.h"
#include "test_util.h"
#include <getopt.h>
#include <gtest/gtest.h>
#include "clock.h"
#include "config_test_env.h"
#include "content_decryption_module.h"
#include "device_cert.h"
#include "license_request.h"
#include "log.h"
#include "properties.h"
#include "scoped_ptr.h"
#include "string_conversions.h"
#include "url_request.h"
static const int kTestPolicyRenewalDelaySeconds = 180;
static const int kDelayWaitToForRenewalMessageSeconds = 2;
static const int kHttpOk = 200;
static const int kHttpBadGateway = 502;
static const int kNumRetries = 5;
static const int kRetryBaseDelaySeconds = 3;
namespace {
// Default key system identifier.
const char kKeySystemWidevine[] = "com.widevine.alpha";
// Default mime type for key request generation.
const char kMimeType[] = "video/mp4";
// Key ID of key used to encrypt the test content.
// This is used to look up the content key.
const std::vector<uint8_t> kTestKeyId =
wvcdm::a2b_hex("371ea35e1a985d75d198a7f41020dc23");
// Dummy encrypted data.
const std::vector<uint8_t> kInputVector1 = wvcdm::a2b_hex(
"64ab17b3e3dfab47245c7cce4543d4fc7a26dcf248f19f9b59f3c92601440b36"
"17c8ed0c96c656549e461f38708cd47a434066f8df28ccc28b79252eee3f9c2d"
"7f6c68ebe40141fe818fe082ca523c03d69ddaf183a93c022327fedc5582c5ab"
"ca9d342b71263a67f9cb2336f12108aaaef464f17177e44e9b0c4e56e61da53c"
"2150b4405cc82d994dfd9bf4087c761956d6688a9705db4cf350381085f383c4"
"9666d4aed135c519c1f0b5cba06e287feea96ea367bf54e7368dcf998276c6e4"
"6497e0c50e20fef74e42cb518fe7f22ef27202428688f86404e8278587017012"
"c1d65537c6cbd7dde04aae338d68115a9f430afc100ab83cdadf45dca39db685");
const std::vector<uint8_t> kIv1 =
wvcdm::a2b_hex("f6f4b1e600a5b67813ed2bded913ba9f");
// Expected output for kInputVector1.
const std::vector<uint8_t> kOutputVector1 = wvcdm::a2b_hex(
"217ce9bde99bd91e9733a1a00b9b557ac3a433dc92633546156817fae26b6e1c"
"942ac20a89ff79f4c2f25fba99d6a44618a8c0420b27d54e3da17b77c9d43cca"
"595d259a1e4a8b6d7744cd98c5d3f921adc252eb7d8af6b916044b676a574747"
"8df21fdc42f166880d97a2225cd5c9ea5e7b752f4cf81bbdbe98e542ee10e1c6"
"ad868a6ac55c10d564fc23b8acff407daaf4ed2743520e02cda9680d9ea88e91"
"029359c4cf5906b6ab5bf60fbb3f1a1c7c59acfc7e4fb4ad8e623c04d503a3dd"
"4884604c8da8a53ce33db9ff8f1c5bb6bb97f37b39906bf41596555c1bcce9ed"
"08a899cd760ff0899a1170c2f224b9c52997a0785b7fe170805fd3e8b1127659");
// Dummy encrypted data. This is a combination of clear and encrypted data.
const std::vector<uint8_t> kInputVector2 = wvcdm::a2b_hex(
// subsample 0
"abcdef"
"53cc758763904ea5870458e6b23d36db1e6d7f7aaa2f3eeebb5393a7264991e7"
"ce4f57b198326e1a208a821799b2a29c90567ab57321b06e51fc20dc9bc5fc55"
"10720a8bb1f5e002c3e50ff70d2d806a9432cad237050d09581f5b0d59b00090"
"b3ad69b4087f5a155b17e13c44d33fa007475d207fc4ac2ef3b571ecb9"
// subsample 1
"0123456789"
"f3c852"
"ce00dc4806f0c6856ae1732e20308096478e1d822d75c2bb768119565d3bd6e6"
"901e36164f4802355ee758fc46ef6cf5f852dd5256c7b1e5f96d29"
// subsample 2
"deadbeefbaadf00d"
"3b20525d5e"
"78b8e5aa344d5c4e425e67ddf889ea7c4bb1d49af67eba67718b765e0a940402"
"8d306f4ce693ad6dc0a931d507fa14fff4d293d4170280b3e0fca2d628f722e8"
);
const std::vector<uint8_t> kIv2 =
wvcdm::a2b_hex("6ba18dd40f49da7f64c368e4db43fc88");
// Expected output for kInputVector2.
const std::vector<uint8_t> kOutputVector2 = wvcdm::a2b_hex(
// subsample 0
"abcdef"
"52e65334501acadf78e2b26460def3ac973771ed7c64001a2e82917342a7eab3"
"047f5e85449692fae8f677be425a47bdea850df5a3ffff17043afb1f2b437ab2"
"b1d5e0784c4ed8f97fc24b8f565e85ed63fb7d1365980d9aea7b8b58f488f83c"
"1ce80b6096c60f3b113c988ff185b26e798da8fc6f327e4ff00e4b3fbf"
// subsample 1
"0123456789"
"b1ed0a"
"a054bce40ccb0ebc70b181d1a12055f46ac55e29c7c2473a29d2a366d240ec48"
"7cede274f012813a877f99159e7062b6a37cfc9327a7bc2195814e"
// subsample 2
"deadbeefbaadf00d"
"653b818d1d"
"4ab9a9128361d8ca6a9d2766df5c096ee29f4f5204febdf217a94a5b560cd692"
"cc36d3e071df789fdeac2fb7ec6dcd7af94bb1f85c22025b25e702e38212b927"
);
// Dummy encrypted data. This will be decrypted with a data_offset
// instead of subsamples.
const std::vector<uint8_t> kInputVector3 = wvcdm::a2b_hex(
"64ab17b3e3dfab47245c7cce4543d4fc7a26dcf248f19f9b59f3c92601440b36"
"17c8ed0c96c656549e461f38708cd47a434066f8df28ccc28b79252eee3f9c2d"
"7f6c68ebe40141fe818fe082ca523c03d69ddaf183a93c022327fedc5582c5ab"
"ca9d342b71263a67f9cb2336f12108aaaef464f17177e44e9b0c4e56e61da53c"
"2150b4405cc82d994dfd9bf4087c761956d6688a9705db4cf350381085f383c4"
"9666d4aed135c519c1f0b5cba06e287feea96ea367bf54e7368dcf998276c6e4"
"6497e0c50e20fef74e42cb518fe7f22ef27202428688f86404e8278587017012"
"c1d65537c6cbd7dde04aae338d68115a9f430afc100ab83cdadf45dca39db685");
const std::vector<uint8_t> kIv3 =
wvcdm::a2b_hex("f6f4b1e600a5b67813ed2bded913ba9f");
// The data_offset for kInputVector3.
const uint32_t kInputOffset3 = 9;
// Expected output for kInputVector3 offset by kInputOffset3.
const std::vector<uint8_t> kOutputVector3 = wvcdm::a2b_hex(
"19ab304b49908e2395b32f26bf471adf4a4bc92f9e999cca8476d24a257931b4"
"c5fd177693ed55e31cd2b85dc196b2b722cd8854eb9334f3dab0b5bd26aa5e66"
"a9d1cfbba877c9456b11dc99a6bdc7015ca1544f7ce66171a8179eca19efe515"
"8c4c1d0612dff64100387065da108fdbfcc14738202ac3d27520eb48c020ddb7"
"714dca22e5e2241aff6932dba1587a97ac1a952827d411d8582dfecc2e9e1494"
"644046ca7044bc41c3c5e0a3a405d5551f3f5bdd6f36042e2f0f3693778b9277"
"6ed8d106647a7539df7d30288803cd9ca1c274bebe688151c72b451f571a441f"
"83d0ff77d8d57dcb395122e175f4944569917627d6c3dc");
void* GetCdmHost(int host_interface_version, void* user_data) {
if (host_interface_version != cdm::Host_1::kVersion) return NULL;
return user_data;
}
} // namespace
namespace wvcdm {
class CdmApi1Test : public testing::Test {
public:
CdmApi1Test() : cdm_(NULL) {}
~CdmApi1Test() {}
protected:
virtual void SetUp() {
// Create the Host.
host_.reset(new TestHost_1());
// Set various parameters that the CDM will query.
host_->SetPlatformString("SecurityLevel", "L1");
host_->SetPlatformString("PrivacyOn", "False");
std::string cert(reinterpret_cast<const char*>(kDeviceCert),
kDeviceCertSize);
host_->SetPlatformString("DeviceCertificate", cert);
// Initialize the CDM module before creating a CDM instance.
InitializeCdmModule();
// Create the CDM.
cdm_ =
reinterpret_cast<cdm::ContentDecryptionModule_1*>(::CreateCdmInstance(
cdm::ContentDecryptionModule_1::kVersion, kKeySystemWidevine,
strlen(kKeySystemWidevine), GetCdmHost, host_.get()));
// Tell the Host about the CDM.
host_->SetCdmPtr(cdm_);
}
cdm::Status GenerateKeyRequest(const std::string& init_data) {
cdm::Status status = cdm_->GenerateKeyRequest(
kMimeType, strlen(kMimeType),
(const uint8_t*)init_data.data(), init_data.length());
return status;
}
cdm::Status GenerateKeyRequestWithMimeType(const std::string& mime_type) {
cdm::Status status = cdm_->GenerateKeyRequest(
mime_type.c_str(), mime_type.length(),
(const uint8_t*)g_key_id.data(), g_key_id.length());
return status;
}
// posts a request and extracts the drm message from the response
std::string GetKeyRequestResponse(const TestHost_1::KeyMessage& key_msg) {
std::string url;
if (key_msg.default_url.empty()) {
url = g_license_server + g_client_auth;
} else {
// Note that the client auth string is not appended when the CDM tells
// us what URL to use.
url = key_msg.default_url;
}
int status_code;
std::string response;
UrlRequest url_request(url);
for (int retries = 0; retries < kNumRetries; ++retries) {
EXPECT_TRUE(url_request.is_connected());
if (!url_request.is_connected()) {
return "";
}
url_request.PostRequest(key_msg.message);
int resp_bytes = url_request.GetResponse(&response);
status_code = url_request.GetStatusCode(response);
// Sometimes, the server returns "HTTP 502 bad gateway".
// If we treat this as a non-fatal error, we reduce test flakiness.
if (status_code != kHttpBadGateway) {
// Move on with normal processing.
break;
}
// Reconnect to the server and try again. Since the server's 502
// response could indicate a temporary failure due to load, we use
// an exponential backoff. Each time we reconnect, we delay by
// exactly twice as long as the last time. This is a simplified
// version of the delay strategy recommended by Google in the
// internal document "Rate Limiting in Google Applications" under
// the heading "Settings for client exponential backoff". We do
// not bother to fuzz the delay, since unit tests are not running
// simultaneously in large numbers like real clients would be.
LOGE("Bad gateway, retrying.");
sleep(kRetryBaseDelaySeconds << retries);
url_request.Reconnect();
}
// Some license servers return 400 for invalid message, some
// return 500; treat anything other than 200 as an invalid message.
EXPECT_EQ(kHttpOk, status_code);
if (status_code != kHttpOk) {
return "";
} else {
std::string drm_msg;
LicenseRequest lic_request;
lic_request.GetDrmMessage(response, drm_msg);
LOGV("drm msg: %u bytes\n%s", drm_msg.size(),
HexEncode(reinterpret_cast<const uint8_t*>(drm_msg.data()),
drm_msg.size()).c_str());
return drm_msg;
}
}
void ProcessKeyResponse() {
TestHost_1::KeyMessage key_msg = host_->GetLastKeyMessage();
ASSERT_FALSE(key_msg.message.empty());
EXPECT_TRUE(key_msg.default_url.empty());
std::string drm_msg = GetKeyRequestResponse(key_msg);
EXPECT_EQ(cdm::kSuccess, AddKey(key_msg.session_id, drm_msg));
}
void ProcessKeyRenewalResponse() {
TestHost_1::KeyMessage key_msg = host_->GetLastKeyMessage();
ASSERT_FALSE(key_msg.message.empty());
EXPECT_FALSE(key_msg.default_url.empty());
std::string drm_msg = GetKeyRequestResponse(key_msg);
EXPECT_EQ(cdm::kSuccess, AddKey(key_msg.session_id, drm_msg));
}
void CloseSession(const std::string& session_id) {
cdm::Status status =
cdm_->CloseSession(session_id.data(), session_id.length());
EXPECT_EQ(cdm::kSuccess, status);
}
cdm::Status AddKey(const std::string& session_id,
const std::string& drm_msg) {
cdm::Status status =
cdm_->AddKey(session_id.data(), session_id.size(),
(const uint8_t*)drm_msg.data(), drm_msg.size(), NULL, 0);
return status;
}
cdm::InputBuffer BuildInputBuffer(const std::vector<uint8_t>& encrypted,
const std::vector<uint8_t>& iv) {
cdm::InputBuffer buf;
buf.data = &encrypted[0];
buf.data_size = encrypted.size();
buf.key_id = &kTestKeyId[0];
buf.key_id_size = kTestKeyId.size();
buf.iv = &iv[0];
buf.iv_size = iv.size();
buf.data_offset = 0;
buf.timestamp = 10;
return buf;
}
cdm::InputBuffer BuildInputBuffer(
const std::vector<uint8_t>& encrypted,
const std::vector<uint8_t>& iv,
const std::vector<cdm::SubsampleEntry>& sub) {
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv);
buf.subsamples = &sub[0];
buf.num_subsamples = sub.size();
return buf;
}
cdm::InputBuffer BuildInputBuffer(
const std::vector<uint8_t>& encrypted,
const std::vector<uint8_t>& iv,
const uint32_t offset) {
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv);
buf.data_offset = offset;
return buf;
}
std::vector<cdm::SubsampleEntry> BuildMultipleSubsamples() {
std::vector<cdm::SubsampleEntry> sub;
sub.push_back(cdm::SubsampleEntry(3, 125));
sub.push_back(cdm::SubsampleEntry(5, 62));
sub.push_back(cdm::SubsampleEntry(8, 69));
return sub;
}
std::vector<cdm::SubsampleEntry> BuildSingleSubsample(size_t size) {
std::vector<cdm::SubsampleEntry> sub;
sub.push_back(cdm::SubsampleEntry(0, size));
return sub;
}
cdm::ContentDecryptionModule_1* cdm_; // owned by host_
wvcdm::scoped_ptr<TestHost_1> host_;
};
namespace {
class DummyCDM : public cdm::ContentDecryptionModule_1 {
public:
DummyCDM() : timer_fired_(false), last_context_(NULL) {}
virtual cdm::Status GenerateKeyRequest(const char*, int, const uint8_t*,
int) OVERRIDE {
return cdm::kSessionError;
}
virtual cdm::Status AddKey(const char*, int, const uint8_t*, int,
const uint8_t*, int) OVERRIDE {
return cdm::kSessionError;
}
virtual bool IsKeyValid(const uint8_t*, int) OVERRIDE { return false; }
virtual cdm::Status CloseSession(const char*, int) OVERRIDE {
return cdm::kSessionError;
}
virtual void TimerExpired(void* context) OVERRIDE {
timer_fired_ = true;
last_context_ = context;
}
virtual cdm::Status Decrypt(const cdm::InputBuffer&,
cdm::DecryptedBlock*) OVERRIDE {
return cdm::kSessionError;
}
virtual cdm::Status DecryptDecodeAndRenderFrame(
const cdm::InputBuffer&) OVERRIDE {
return cdm::kSessionError;
}
virtual cdm::Status DecryptDecodeAndRenderSamples(
const cdm::InputBuffer&) OVERRIDE {
return cdm::kSessionError;
}
virtual void Destroy() OVERRIDE { delete this; }
virtual cdm::Status GetProvisioningRequest(std::string*,
std::string*) OVERRIDE {
return cdm::kSessionError;
}
virtual cdm::Status HandleProvisioningResponse(std::string&) OVERRIDE {
return cdm::kSessionError;
}
bool TimerFired() const { return timer_fired_; }
void* LastTimerContext() const { return last_context_; }
void ResetTimerStatus() {
timer_fired_ = false;
last_context_ = NULL;
}
private:
bool timer_fired_;
void* last_context_;
};
} // namespace
TEST_F(CdmApi1Test, TestHostTimer) {
// Validate that the TestHost timers are processed in the correct order.
// To do this, we replace the cdm with a dummy that only tracks timers.
DummyCDM* cdm = new DummyCDM();
// The old CDM is destroyed by SetCdmPtr.
cdm_ = cdm;
host_->SetCdmPtr(cdm);
const double kTimerDelaySeconds = 1.0;
const int64_t kTimerDelayMs = kTimerDelaySeconds * 1000;
void* kCtx1 = reinterpret_cast<void*>(0x1);
void* kCtx2 = reinterpret_cast<void*>(0x2);
host_->SetTimer(kTimerDelayMs * 1, kCtx1);
host_->SetTimer(kTimerDelayMs * 2, kCtx2);
host_->FastForwardTime(kTimerDelaySeconds);
EXPECT_TRUE(cdm->TimerFired());
EXPECT_EQ(kCtx1, cdm->LastTimerContext());
cdm->ResetTimerStatus();
host_->FastForwardTime(kTimerDelaySeconds);
EXPECT_TRUE(cdm->TimerFired());
EXPECT_EQ(kCtx2, cdm->LastTimerContext());
cdm->ResetTimerStatus();
host_->FastForwardTime(kTimerDelaySeconds);
EXPECT_FALSE(cdm->TimerFired());
}
TEST_F(CdmApi1Test, DeviceCertificateTest) {
if (Properties::use_certificates_as_identification()) {
// Clear any existing device cert.
host_->SetPlatformString("DeviceCertificate", "");
ASSERT_EQ(cdm::kNeedsDeviceCertificate, GenerateKeyRequest(g_key_id));
// The Host must handle the certificate provisioning request.
std::string server_url;
std::string request;
cdm::Status status = cdm_->GetProvisioningRequest(&request, &server_url);
ASSERT_EQ(cdm::kSuccess, status);
UrlRequest url_request(server_url);
url_request.PostCertRequestInQueryString(request);
std::string message;
bool ok = url_request.GetResponse(&message);
ASSERT_TRUE(ok);
status = cdm_->HandleProvisioningResponse(message);
ASSERT_EQ(cdm::kSuccess, status);
// Now we are provisioned, so GKR should succeed.
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
} else {
LOGI(
"Skipping CdmApi1Test::DeviceCertificateTest because this platform "
"does not support device certificates.");
}
}
// Note that these tests, BaseMessageTest, NormalDecryption and RenewalTest,
// are dependent on getting back a license from the license server where the
// url for the license server is defined in the conf_test_env.cpp. If these
// tests fail immediately, verify that the license server URL is correct
// and works in your test environment.
TEST_F(CdmApi1Test, BaseMessageTest) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
}
TEST_F(CdmApi1Test, NormalDecryption) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
// Level 1 / Level 2 payload comes back in the cpu memory as cleartext.
std::vector<uint8_t> encrypted = kInputVector1;
std::vector<uint8_t> iv = kIv1;
std::vector<uint8_t> expected = kOutputVector1;
std::vector<cdm::SubsampleEntry> sub = BuildSingleSubsample(encrypted.size());
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kSuccess, status);
EXPECT_EQ(
0, memcmp(output.DecryptedBuffer()->Data(), &expected[0], buf.data_size));
}
TEST_F(CdmApi1Test, NormalSubSampleDecryptionWithSubsampleInfo) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
// Level 1 / Level 2 payload comes back in the cpu memory as cleartext.
std::vector<uint8_t> encrypted = kInputVector2;
std::vector<uint8_t> iv = kIv2;
std::vector<uint8_t> expected = kOutputVector2;
std::vector<cdm::SubsampleEntry> sub = BuildMultipleSubsamples();
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kSuccess, status);
EXPECT_EQ(
0, memcmp(output.DecryptedBuffer()->Data(), &expected[0], buf.data_size));
}
TEST_F(CdmApi1Test, NormalSubSampleDecryptionWithMissingSubsampleInfo) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
std::vector<uint8_t> encrypted = kInputVector2;
std::vector<uint8_t> iv = kIv2;
std::vector<uint8_t> expected = kOutputVector2;
std::vector<cdm::SubsampleEntry> sub = BuildMultipleSubsamples();
// Don't add these subsamples yet!
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv);
buf.num_subsamples = sub.size();
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kDecryptError, status);
// Add the subsamples pointer and expect success.
buf.subsamples = &sub[0];
status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kSuccess, status);
EXPECT_EQ(
0, memcmp(output.DecryptedBuffer()->Data(), &expected[0], buf.data_size));
}
TEST_F(CdmApi1Test, DecryptWithDataOffset) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
std::vector<uint8_t> encrypted = kInputVector3;
std::vector<uint8_t> iv = kIv3;
std::vector<uint8_t> expected = kOutputVector3;
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, kInputOffset3);
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
cdm::Buffer *output_buf = output.DecryptedBuffer();
EXPECT_EQ(cdm::kSuccess, status);
EXPECT_EQ(buf.data_size - buf.data_offset, output_buf->Size());
EXPECT_EQ(0, memcmp(output.DecryptedBuffer()->Data(), &expected[0],
output_buf->Size()));
}
TEST_F(CdmApi1Test, DecryptReturnsSizedBuffer) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
std::vector<uint8_t> encrypted = kInputVector1;
std::vector<uint8_t> iv = kIv1;
std::vector<uint8_t> expected = kOutputVector1;
std::vector<cdm::SubsampleEntry> sub = BuildSingleSubsample(encrypted.size());
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kSuccess, status);
cdm::Buffer* buffer = output.DecryptedBuffer();
EXPECT_NE((void*)NULL, buffer);
if (buffer) {
EXPECT_EQ(expected.size(), output.DecryptedBuffer()->Size());
}
}
TEST_F(CdmApi1Test, RenewalTest) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
// We expect that by the time we've added a key, the CDM has set a timer.
// Otherwise, it couldn't correctly handle renewal.
EXPECT_NE(0, host_->NumTimers());
host_->FastForwardTime(kTestPolicyRenewalDelaySeconds +
kDelayWaitToForRenewalMessageSeconds);
// When the timer expired, we should have sent a renewal, so we can
// add this renewed key now, assuming things are working as expected.
ProcessKeyRenewalResponse();
}
TEST_F(CdmApi1Test, SecureDecryptionLevel1) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
// Level 1 passes encrypted payload straight through. By calling the
// CDM's DecryptDecodeAndRenderSamples, and/or DecryptDecodeAndRenderFrame,
// OEMCrypto_DecryptCTR will be told to use Direct Rendering.
std::vector<uint8_t> encrypted = kInputVector1;
std::vector<uint8_t> iv = kIv1;
std::vector<cdm::SubsampleEntry> sub = BuildSingleSubsample(encrypted.size());
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
cdm::Status status;
status = cdm_->DecryptDecodeAndRenderSamples(buf);
EXPECT_EQ(cdm::kSuccess, status);
status = cdm_->DecryptDecodeAndRenderFrame(buf);
EXPECT_EQ(cdm::kSuccess, status);
}
TEST_F(CdmApi1Test, SecureDecryptionLevel1WithSubsampleInfo) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
// Level 1 passes encrypted payload straight through. By calling the
// CDM's DecryptDecodeAndRenderSamples, and/or DecryptDecodeAndRenderFrame,
// OEMCrypto_DecryptCTR will be told to use Direct Rendering.
std::vector<uint8_t> encrypted = kInputVector2;
std::vector<uint8_t> iv = kIv2;
std::vector<cdm::SubsampleEntry> sub = BuildMultipleSubsamples();
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
cdm::Status status;
status = cdm_->DecryptDecodeAndRenderSamples(buf);
EXPECT_EQ(cdm::kSuccess, status);
status = cdm_->DecryptDecodeAndRenderFrame(buf);
EXPECT_EQ(cdm::kSuccess, status);
}
TEST_F(CdmApi1Test, SecureDecryptionLevel1WithMissingSubsampleInfo) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
ProcessKeyResponse();
std::vector<uint8_t> encrypted = kInputVector2;
std::vector<uint8_t> iv = kIv2;
std::vector<cdm::SubsampleEntry> sub = BuildMultipleSubsamples();
// Don't add these subsamples yet!
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv);
buf.num_subsamples = sub.size();
cdm::Status status;
status = cdm_->DecryptDecodeAndRenderSamples(buf);
EXPECT_EQ(cdm::kDecryptError, status);
status = cdm_->DecryptDecodeAndRenderFrame(buf);
EXPECT_EQ(cdm::kDecryptError, status);
// Add the subsamples pointer and expect success.
buf.subsamples = &sub[0];
status = cdm_->DecryptDecodeAndRenderSamples(buf);
EXPECT_EQ(cdm::kSuccess, status);
status = cdm_->DecryptDecodeAndRenderFrame(buf);
EXPECT_EQ(cdm::kSuccess, status);
}
TEST_F(CdmApi1Test, GenerateKeyRequestFailureSendsKeyError) {
// Pass a bogus key id and expect failure.
EXPECT_EQ(cdm::kSessionError, GenerateKeyRequest(""));
// Expect the CDM to pass a key error back to the host.
EXPECT_EQ(1, host_->KeyErrorsSize());
}
TEST_F(CdmApi1Test, AddKeyFailureSendsKeyError) {
EXPECT_EQ(cdm::kSuccess, GenerateKeyRequest(g_key_id));
// Get the message and response.
TestHost_1::KeyMessage key_msg = host_->GetLastKeyMessage();
EXPECT_TRUE(key_msg.default_url.empty());
std::string drm_msg = GetKeyRequestResponse(key_msg);
// Call AddKey with a bad session id and expect failure.
EXPECT_EQ(cdm::kSessionError, AddKey("BLAH", drm_msg));
// Expect the CDM to pass a key error back to the host.
EXPECT_EQ(1, host_->KeyErrorsSize());
// Call AddKey with a bad license and expect failure.
EXPECT_EQ(cdm::kSessionError, AddKey(key_msg.session_id, "BLAH"));
// Expect the CDM to pass one more key error back to the host.
EXPECT_EQ(2, host_->KeyErrorsSize());
}
TEST_F(CdmApi1Test, MimeTypeMatters) {
cdm::Status status;
status = GenerateKeyRequestWithMimeType("video/mp4");
ASSERT_EQ(cdm::kSuccess, status);
status = GenerateKeyRequestWithMimeType("video/webm");
ASSERT_EQ(cdm::kSuccess, status);
status = GenerateKeyRequestWithMimeType("video/blah");
ASSERT_EQ(cdm::kSessionError, status);
}
} // namespace wvcdm

View File

@@ -1,925 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
//
// This source file provides a basic set of unit tests for the Content
// Decryption Module (CDM). It exercises much of the API that will be
// required by the host application to get the license and keys for
// rendering protected content.
#include "cdm_test_config.h"
#include "test_host_4.h"
#include "test_util.h"
#include <getopt.h>
#include <gtest/gtest.h>
#include "cdm_client_property_set.h"
#include "clock.h"
#include "config_test_env.h"
#include "content_decryption_module.h"
#include "device_cert.h"
#include "license_request.h"
#include "log.h"
#include "properties.h"
#include "scoped_ptr.h"
#include "string_conversions.h"
#include "url_request.h"
#include "wv_content_decryption_module_4.h"
static const int kTestPolicyRenewalDelaySeconds = 180;
static const int kDelayWaitToForRenewalMessageSeconds = 2;
static const int kHttpOk = 200;
static const int kSessionId1 = 1;
static const int kSessionId2 = 2;
static const int kSessionId3 = 3;
namespace {
// Default key system identifier.
const char kKeySystemWidevine[] = "com.widevine.alpha";
// Default mime type for session creation.
const char kMimeType[] = "video/mp4";
// Known filename for certificate manipulation.
const std::string kCertFilename = "cert.bin";
// Key ID of key used to encrypt the test content.
// This is used to look up the content key.
const std::vector<uint8_t> kTestKeyId =
wvcdm::a2b_hex("371ea35e1a985d75d198a7f41020dc23");
// Dummy encrypted data.
const std::vector<uint8_t> kInputVector1 = wvcdm::a2b_hex(
"64ab17b3e3dfab47245c7cce4543d4fc7a26dcf248f19f9b59f3c92601440b36"
"17c8ed0c96c656549e461f38708cd47a434066f8df28ccc28b79252eee3f9c2d"
"7f6c68ebe40141fe818fe082ca523c03d69ddaf183a93c022327fedc5582c5ab"
"ca9d342b71263a67f9cb2336f12108aaaef464f17177e44e9b0c4e56e61da53c"
"2150b4405cc82d994dfd9bf4087c761956d6688a9705db4cf350381085f383c4"
"9666d4aed135c519c1f0b5cba06e287feea96ea367bf54e7368dcf998276c6e4"
"6497e0c50e20fef74e42cb518fe7f22ef27202428688f86404e8278587017012"
"c1d65537c6cbd7dde04aae338d68115a9f430afc100ab83cdadf45dca39db685");
const std::vector<uint8_t> kIv1 =
wvcdm::a2b_hex("f6f4b1e600a5b67813ed2bded913ba9f");
// Expected output for kInputVector1.
const std::vector<uint8_t> kOutputVector1 = wvcdm::a2b_hex(
"217ce9bde99bd91e9733a1a00b9b557ac3a433dc92633546156817fae26b6e1c"
"942ac20a89ff79f4c2f25fba99d6a44618a8c0420b27d54e3da17b77c9d43cca"
"595d259a1e4a8b6d7744cd98c5d3f921adc252eb7d8af6b916044b676a574747"
"8df21fdc42f166880d97a2225cd5c9ea5e7b752f4cf81bbdbe98e542ee10e1c6"
"ad868a6ac55c10d564fc23b8acff407daaf4ed2743520e02cda9680d9ea88e91"
"029359c4cf5906b6ab5bf60fbb3f1a1c7c59acfc7e4fb4ad8e623c04d503a3dd"
"4884604c8da8a53ce33db9ff8f1c5bb6bb97f37b39906bf41596555c1bcce9ed"
"08a899cd760ff0899a1170c2f224b9c52997a0785b7fe170805fd3e8b1127659");
// Dummy encrypted data. This is a combination of clear and encrypted data.
const std::vector<uint8_t> kInputVector2 = wvcdm::a2b_hex(
// subsample 0
"abcdef"
"53cc758763904ea5870458e6b23d36db1e6d7f7aaa2f3eeebb5393a7264991e7"
"ce4f57b198326e1a208a821799b2a29c90567ab57321b06e51fc20dc9bc5fc55"
"10720a8bb1f5e002c3e50ff70d2d806a9432cad237050d09581f5b0d59b00090"
"b3ad69b4087f5a155b17e13c44d33fa007475d207fc4ac2ef3b571ecb9"
// subsample 1
"0123456789"
"f3c852"
"ce00dc4806f0c6856ae1732e20308096478e1d822d75c2bb768119565d3bd6e6"
"901e36164f4802355ee758fc46ef6cf5f852dd5256c7b1e5f96d29"
// subsample 2
"deadbeefbaadf00d"
"3b20525d5e"
"78b8e5aa344d5c4e425e67ddf889ea7c4bb1d49af67eba67718b765e0a940402"
"8d306f4ce693ad6dc0a931d507fa14fff4d293d4170280b3e0fca2d628f722e8"
);
const std::vector<uint8_t> kIv2 =
wvcdm::a2b_hex("6ba18dd40f49da7f64c368e4db43fc88");
// Expected output for kInputVector2.
const std::vector<uint8_t> kOutputVector2 = wvcdm::a2b_hex(
// subsample 0
"abcdef"
"52e65334501acadf78e2b26460def3ac973771ed7c64001a2e82917342a7eab3"
"047f5e85449692fae8f677be425a47bdea850df5a3ffff17043afb1f2b437ab2"
"b1d5e0784c4ed8f97fc24b8f565e85ed63fb7d1365980d9aea7b8b58f488f83c"
"1ce80b6096c60f3b113c988ff185b26e798da8fc6f327e4ff00e4b3fbf"
// subsample 1
"0123456789"
"b1ed0a"
"a054bce40ccb0ebc70b181d1a12055f46ac55e29c7c2473a29d2a366d240ec48"
"7cede274f012813a877f99159e7062b6a37cfc9327a7bc2195814e"
// subsample 2
"deadbeefbaadf00d"
"653b818d1d"
"4ab9a9128361d8ca6a9d2766df5c096ee29f4f5204febdf217a94a5b560cd692"
"cc36d3e071df789fdeac2fb7ec6dcd7af94bb1f85c22025b25e702e38212b927"
);
// Dummy encrypted data. This will be decrypted with a data_offset
// instead of subsamples.
const std::vector<uint8_t> kInputVector3 = wvcdm::a2b_hex(
"64ab17b3e3dfab47245c7cce4543d4fc7a26dcf248f19f9b59f3c92601440b36"
"17c8ed0c96c656549e461f38708cd47a434066f8df28ccc28b79252eee3f9c2d"
"7f6c68ebe40141fe818fe082ca523c03d69ddaf183a93c022327fedc5582c5ab"
"ca9d342b71263a67f9cb2336f12108aaaef464f17177e44e9b0c4e56e61da53c"
"2150b4405cc82d994dfd9bf4087c761956d6688a9705db4cf350381085f383c4"
"9666d4aed135c519c1f0b5cba06e287feea96ea367bf54e7368dcf998276c6e4"
"6497e0c50e20fef74e42cb518fe7f22ef27202428688f86404e8278587017012"
"c1d65537c6cbd7dde04aae338d68115a9f430afc100ab83cdadf45dca39db685");
const std::vector<uint8_t> kIv3 =
wvcdm::a2b_hex("f6f4b1e600a5b67813ed2bded913ba9f");
// The data_offset for kInputVector3.
const uint32_t kInputOffset3 = 9;
// Expected output for kInputVector3 offset by kInputOffset3.
const std::vector<uint8_t> kOutputVector3 = wvcdm::a2b_hex(
"19ab304b49908e2395b32f26bf471adf4a4bc92f9e999cca8476d24a257931b4"
"c5fd177693ed55e31cd2b85dc196b2b722cd8854eb9334f3dab0b5bd26aa5e66"
"a9d1cfbba877c9456b11dc99a6bdc7015ca1544f7ce66171a8179eca19efe515"
"8c4c1d0612dff64100387065da108fdbfcc14738202ac3d27520eb48c020ddb7"
"714dca22e5e2241aff6932dba1587a97ac1a952827d411d8582dfecc2e9e1494"
"644046ca7044bc41c3c5e0a3a405d5551f3f5bdd6f36042e2f0f3693778b9277"
"6ed8d106647a7539df7d30288803cd9ca1c274bebe688151c72b451f571a441f"
"83d0ff77d8d57dcb395122e175f4944569917627d6c3dc");
// Dummy data used as a server certificate. Not a real cert.
const std::vector<uint8_t> kFakeServerCertficiate = wvcdm::a2b_hex(
"65393939a0e4a28fb07aa8237bdc9e2fd30fdf763061ed9ed91b368a2b78fc2d"
"15f0b6add5d56d05f7e5852aeae67de6127d6b61b39bb5d6e9657f352ba75e72"
"c436f334878568504f697ad01aa329efbadebc3b9aaf502ada9b8e6fcf066252"
"76690a0f50cd3852dd39f7c5444402f86831d8bb2cbbd7cba11ab1caa35445fe"
"35a332529845f2f4b5d5a0b1e2c0855fc2d644443eb967e1f9030fd0d9e6375b"
"a5100a997ff8a958606d59a00151d251eaf69f9e00465b5aa4c23ef33a11b05b"
"212c1ff830fcd095c681ef25a18db08d7bddfeee16763e9fec06daa8275de2b0"
"554a0bec821fb7bb6fbda081d8cecce6c51195e6b6a1c0fcbb2470bcff2a962e"
"57e767f83cc8b6c31d41d7c59526128f19cbf625fa4f5f382393a3bd2b76463a"
"fe97e4a6f30f631c83308aa5fdccc2d1765c113d474bf2496e03c030c18e5ca8"
"84cb98fa120804baa245682966926ccbf555450437de10e549afc088f8c36f63"
"8a943178bdd58e4ef1f7d501e2296bbe2df57ce8816d6ae9e7ab18b1e01dac9b"
"8c312298356cad58c6ed46b1cd3a895e496c66f5229da39e260a7c1f782653bd"
"ade5f6132fc4771bb8caca80eb063abb47144abc44aaba8d23fcc721199291b3"
"0b95bc7d310c3f90756916552151a6008feba73ddab87454822914732d6ee78a"
"3587f33c698b0ab90f01b38a71abd01660a5ef1473e4556aa8c17d34679065c5"
"689dd21026601e94146254346f4ccd979bc378046473b3de64b8654e18406e94"
"b673dc13fdcc70213365bd098f212ed7a973ef35da18e16b1c118f8d4eda0b39"
"ffb8084ca93a44923df8475e3feec6c0941a2a37d5df514e686dd182dc9ebbff"
"41d8d80aa39d059de3b7849d4e5946b09937c6e7a6f6392ea5e9370ba1867553"
"b716e31433c2e3ca3eff1e7c08a31b201fd18c363b8daeed59df7afb68ad5166"
"659914a2e137c9d2e5940aaa921694c8d84d5ea1c83486e473e3021cb825c0ed"
"f778c621598d35e44843cd53e32f90925e74bc8eb469889fb221a2c592b43d94"
"2079d6393ab76e47d30dbf837fa5ca07d7186710973c5bb17c04b3207a85a166"
"153053f6b0ec35c6b124efd43be274cdf8300234806a72231272d13b331cafd3"
"dab01002b5e1961a5f3221d4c589fac3e42c1d1de9f244090e31a08999d3434d"
"15a5159f09fa3307e0d9466ac40af63c0a62f8d2719e1df80bb24d4d7ab256f7"
"0906ee342a47a9bd6805d796cf928f0d5251701ba8e6888675b1b6fd03e77df0"
"8150495c778cb7942d8c060ace4b080ad22e44854988d5e2232f5dbcf2db559f"
"24bae8667c33cea77f1c6a58d9dd010363c233cff6d5d26f5f77230ee681456c"
"35a8f90d37c2fc0ab07a2a795431f829cca574fd37d8822e04fc500ba468f08a"
"556e53ba8992dd1ccbd44559a7b93bebc27cec81a834755cf110bce183481e42");
void* GetCdmHost(int host_interface_version, void* user_data) {
if (host_interface_version != cdm::Host_4::kVersion) return NULL;
return user_data;
}
} // namespace
namespace wvcdm {
class CdmApi4Test : public testing::Test {
public:
CdmApi4Test() : cdm_(NULL) {}
~CdmApi4Test() {}
protected:
virtual void SetUp() {
// Create the Host.
host_.reset(new TestHost_4());
// Load the device cert that was already "saved" to the device.
std::string cert(reinterpret_cast<const char*>(kDeviceCert),
kDeviceCertSize);
host_->file_store[kCertFilename] = cert;
// Initialize the CDM module before creating a CDM instance.
InitializeCdmModule();
// Create the CDM.
cdm_ =
reinterpret_cast<cdm::ContentDecryptionModule_4*>(::CreateCdmInstance(
cdm::ContentDecryptionModule_4::kVersion, kKeySystemWidevine,
strlen(kKeySystemWidevine), GetCdmHost, host_.get()));
if (cdm_ == NULL) {
FAIL() << "Fatal CDM creation error!";
}
// Tell the Host about the CDM.
host_->SetCdmPtr(cdm_);
}
void CreateSession(const uint32_t session_id, const std::string& init_data,
cdm::SessionType session_type) {
cdm_->CreateSession(session_id, kMimeType, strlen(kMimeType),
reinterpret_cast<const uint8_t*>(init_data.data()),
init_data.length(), session_type);
}
void CreateSessionWithMimeType(const uint32_t session_id,
const std::string& mime_type) {
cdm_->CreateSession(session_id, mime_type.c_str(), mime_type.length(),
reinterpret_cast<const uint8_t*>(g_key_id.data()),
g_key_id.length(), cdm::kTemporary);
}
void LoadSession(uint32_t session_id, const std::string& web_session_id) {
cdm_->LoadSession(session_id, web_session_id.data(),
web_session_id.length());
}
// posts a request and extracts the drm message from the response
std::string GetKeyRequestResponse(
const TestHost_4::SessionMessage& session_msg,
const std::string& default_url, bool is_provision) {
std::string url;
if (session_msg.default_url.empty()) {
url = default_url;
} else {
// Note that the client auth string is assumed to already be appended when
// the CDM tells us what URL to use.
url = session_msg.default_url;
}
UrlRequest url_request(url);
EXPECT_TRUE(url_request.is_connected());
if (!url_request.is_connected()) {
return "";
}
if (!is_provision) {
url_request.PostRequest(session_msg.message);
} else {
url_request.PostCertRequestInQueryString(session_msg.message);
}
std::string response;
int resp_bytes = url_request.GetResponse(&response);
// Some license servers return 400 for invalid message, some
// return 500; treat anything other than 200 as an invalid message.
int status_code = url_request.GetStatusCode(response);
EXPECT_EQ(kHttpOk, status_code);
if (status_code != kHttpOk) {
return "";
} else {
std::string drm_msg;
LicenseRequest lic_request;
lic_request.GetDrmMessage(response, drm_msg);
LOGV("drm msg: %u bytes\n%s", drm_msg.size(),
HexEncode(reinterpret_cast<const uint8_t*>(drm_msg.data()),
drm_msg.size()).c_str());
return drm_msg;
}
}
void ProcessKeyResponse(bool expect_url_in_message) {
ProcessKeyResponse(expect_url_in_message, g_license_server + g_client_auth);
}
void ProcessKeyResponse(bool expect_url_in_message,
const std::string& default_url) {
ProcessServerResponse(expect_url_in_message, false, default_url);
}
void ProcessProvisionResponse() { ProcessServerResponse(true, true, ""); }
void ProcessServerResponse(bool expect_url_in_message, bool is_provision,
const std::string& default_url) {
TestHost_4::SessionMessage session_msg = host_->GetLastSessionMessage();
ASSERT_FALSE(session_msg.message.empty());
// Use EXPECT_bool instead of EXPECT_EQ to get better error printing.
if (expect_url_in_message) {
EXPECT_FALSE(session_msg.default_url.empty());
} else {
EXPECT_TRUE(session_msg.default_url.empty());
}
std::string drm_msg =
GetKeyRequestResponse(session_msg, default_url, is_provision);
UpdateSession(session_msg.session_id, (const uint8_t*)drm_msg.c_str(),
drm_msg.length());
}
void ReleaseSession(uint32_t session_id) { cdm_->ReleaseSession(session_id); }
void RemoveSession(uint32_t session_id, const std::string& web_session_id) {
cdm_->RemoveSession(session_id, web_session_id.data(),
web_session_id.length());
}
void UpdateSession(uint32_t session_id, const uint8_t* response,
uint32_t response_size) {
cdm_->UpdateSession(session_id, response, response_size);
}
cdm::Status UsePrivacyMode() { return cdm_->UsePrivacyMode(); }
cdm::Status SetServerCertificate(const std::vector<uint8_t>& cert) {
return cdm_->SetServerCertificate(&cert[0], cert.size());
}
bool SessionErrorPresent(uint32_t session_id) {
TestHost_4::SessionError serr = host_->GetLastSessionError();
if (serr.session_id == session_id) {
return true;
}
return false;
}
bool SessionErrorPresent(uint32_t session_id, cdm::Status error_code) {
TestHost_4::SessionError serr = host_->GetLastSessionError();
if (serr.session_id == session_id && serr.error_code == error_code) {
return true;
}
return false;
}
cdm::InputBuffer BuildInputBuffer(const std::vector<uint8_t>& encrypted,
const std::vector<uint8_t>& iv) {
cdm::InputBuffer buf;
buf.data = &encrypted[0];
buf.data_size = encrypted.size();
buf.key_id = &kTestKeyId[0];
buf.key_id_size = kTestKeyId.size();
buf.iv = &iv[0];
buf.iv_size = iv.size();
buf.data_offset = 0;
buf.timestamp = 10;
return buf;
}
cdm::InputBuffer BuildInputBuffer(
const std::vector<uint8_t>& encrypted, const std::vector<uint8_t>& iv,
const std::vector<cdm::SubsampleEntry>& sub) {
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv);
buf.subsamples = &sub[0];
buf.num_subsamples = sub.size();
return buf;
}
cdm::InputBuffer BuildInputBuffer(const std::vector<uint8_t>& encrypted,
const std::vector<uint8_t>& iv,
const uint32_t data_offset) {
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv);
buf.data_offset = data_offset;
return buf;
}
std::vector<cdm::SubsampleEntry> BuildMultipleSubsamples() {
std::vector<cdm::SubsampleEntry> sub;
sub.push_back(cdm::SubsampleEntry(3, 125));
sub.push_back(cdm::SubsampleEntry(5, 62));
sub.push_back(cdm::SubsampleEntry(8, 69));
return sub;
}
std::vector<cdm::SubsampleEntry> BuildSingleSubsample(size_t size) {
std::vector<cdm::SubsampleEntry> sub;
sub.push_back(cdm::SubsampleEntry(0, size));
return sub;
}
void GetOfflineConfiguration(std::string* key_id, std::string* license_server,
std::string* client_auth) {
// This method compares three different places settings could be found:
// 1) A configuration object using the default settings.
// 2) The global variables prefixed with g_.
// 3) A configuration object configured for offline playback.
// The desire is to use 3 unless the user customized the settings on the
// command line, in which case we want to defer to them and use 2. The "if"
// statements check if 1 and 2 are the same. If so, we know the user
// did not customize the settings on the command line, and therefore we can
// use 3. Otherwise, we use 2. This will never return the values from 1;
// 1 is only used to check if 2 has been altered by the user.
ConfigTestEnv std_config(kLicenseServerId);
// TODO (juce): Switch this to kLicenseServerId once
// kContentProtectionServer is the default.
ConfigTestEnv config(wvcdm::kContentProtectionServer, false);
if (g_key_id.compare(a2bs_hex(std_config.key_id())) == 0)
key_id->assign(wvcdm::a2bs_hex(config.key_id()));
else
key_id->assign(g_key_id);
if (g_license_server.compare(std_config.license_server()) == 0)
license_server->assign(config.license_server());
else
license_server->assign(g_license_server);
if (g_client_auth.compare(std_config.client_auth()) == 0)
client_auth->assign(config.client_auth());
else
client_auth->assign(g_client_auth);
}
cdm::ContentDecryptionModule_4* cdm_; // owned by host_
wvcdm::scoped_ptr<TestHost_4> host_;
};
namespace {
class DummyCDM : public cdm::ContentDecryptionModule_4 {
public:
DummyCDM() : timer_fired_(false), last_context_(NULL) {}
virtual void CreateSession(uint32_t session_id,
const char* mime_type, uint32_t mime_type_size,
const uint8_t* init_data, uint32_t init_data_size,
cdm::SessionType session_type) OVERRIDE {}
virtual void LoadSession(uint32_t session_id, const char* web_session_id,
uint32_t web_session_id_length) OVERRIDE {}
virtual void UpdateSession(uint32_t session_id, const uint8_t* response,
uint32_t response_size) OVERRIDE {}
virtual bool IsKeyValid(const uint8_t*, int) OVERRIDE { return false; }
virtual void ReleaseSession(uint32_t session_id) OVERRIDE {}
virtual void RemoveSession(uint32_t session_id, const char* web_session_id,
uint32_t web_session_id_length) {}
virtual cdm::Status UsePrivacyMode() OVERRIDE { return cdm::kSuccess; }
virtual cdm::Status SetServerCertificate(
const uint8_t* server_certificate_data,
uint32_t server_certificate_data_size) OVERRIDE {
return cdm::kSuccess;
}
virtual void TimerExpired(void* context) OVERRIDE {
timer_fired_ = true;
last_context_ = context;
}
virtual cdm::Status Decrypt(const cdm::InputBuffer&,
cdm::DecryptedBlock*) OVERRIDE {
return cdm::kSessionError;
}
virtual cdm::Status DecryptDecodeAndRender(
const cdm::InputBuffer& encrypted_buffer,
cdm::StreamType stream_type) OVERRIDE {
return cdm::kDecryptError;
}
virtual void Destroy() OVERRIDE { delete this; }
bool TimerFired() const { return timer_fired_; }
void* LastTimerContext() const { return last_context_; }
void ResetTimerStatus() {
timer_fired_ = false;
last_context_ = NULL;
}
private:
bool timer_fired_;
void* last_context_;
};
} // namespace
TEST_F(CdmApi4Test, TestHostTimer) {
// Validate that the TestHost timers are processed in the correct order.
// To do this, we replace the cdm with a dummy that only tracks timers.
DummyCDM* cdm = new DummyCDM();
// The old CDM is destroyed by SetCdmPtr.
cdm_ = cdm;
host_->SetCdmPtr(cdm);
const double kTimerDelaySeconds = 1.0;
const int64_t kTimerDelayMs = kTimerDelaySeconds * 1000;
void* kCtx1 = reinterpret_cast<void*>(0x1);
void* kCtx2 = reinterpret_cast<void*>(0x2);
host_->SetTimer(kTimerDelayMs * 1, kCtx1);
host_->SetTimer(kTimerDelayMs * 2, kCtx2);
host_->FastForwardTime(kTimerDelaySeconds);
EXPECT_TRUE(cdm->TimerFired());
EXPECT_EQ(kCtx1, cdm->LastTimerContext());
cdm->ResetTimerStatus();
host_->FastForwardTime(kTimerDelaySeconds);
EXPECT_TRUE(cdm->TimerFired());
EXPECT_EQ(kCtx2, cdm->LastTimerContext());
cdm->ResetTimerStatus();
host_->FastForwardTime(kTimerDelaySeconds);
EXPECT_FALSE(cdm->TimerFired());
}
TEST_F(CdmApi4Test, DeviceCertificateTest) {
if (Properties::use_certificates_as_identification()) {
// Clear any existing certificates
host_->file_store.erase(kCertFilename);
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ASSERT_TRUE(SessionErrorPresent(kSessionId1, cdm::kNeedsDeviceCertificate));
// The Host must handle the certificate provisioning request.
CreateSession(kSessionId2, "", cdm::kProvisioning);
ASSERT_FALSE(SessionErrorPresent(kSessionId2));
ProcessProvisionResponse();
ASSERT_FALSE(SessionErrorPresent(kSessionId2));
CreateSession(kSessionId3, g_key_id, cdm::kTemporary);
ASSERT_FALSE(SessionErrorPresent(kSessionId3));
} else {
LOGI(
"Skipping CdmApi4Test::DeviceCertificateTest because this platform "
"does not support device certificates.");
}
}
// Note that these tests, BaseMessageTest, NormalDecryption, TimeTest, and
// others are dependent on getting back a license from the license server where
// the url for the license server is defined in the conf_test_env.cpp. If these
// tests fail immediately, verify that the license server URL is correct
// and works in your test environment.
TEST_F(CdmApi4Test, BaseMessageTest) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, NormalDecryption) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
// Level 1 / Level 2 payload comes back in the cpu memory as cleartext.
std::vector<uint8_t> encrypted = kInputVector1;
std::vector<uint8_t> iv = kIv1;
std::vector<uint8_t> expected = kOutputVector1;
std::vector<cdm::SubsampleEntry> sub = BuildSingleSubsample(encrypted.size());
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kSuccess, status);
EXPECT_EQ(
0, memcmp(output.DecryptedBuffer()->Data(), &expected[0], buf.data_size));
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, NormalSubSampleDecryptionWithSubsampleInfo) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
// Level 1 / Level 2 payload comes back in the cpu memory as cleartext.
std::vector<uint8_t> encrypted = kInputVector2;
std::vector<uint8_t> iv = kIv2;
std::vector<uint8_t> expected = kOutputVector2;
std::vector<cdm::SubsampleEntry> sub = BuildMultipleSubsamples();
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kSuccess, status);
EXPECT_EQ(
0, memcmp(output.DecryptedBuffer()->Data(), &expected[0], buf.data_size));
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, NormalSubSampleDecryptionWithMissingSubsampleInfo) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
std::vector<uint8_t> encrypted = kInputVector2;
std::vector<uint8_t> iv = kIv2;
std::vector<uint8_t> expected = kOutputVector2;
std::vector<cdm::SubsampleEntry> sub = BuildMultipleSubsamples();
// Don't add these subsamples yet!
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv);
buf.num_subsamples = sub.size();
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kDecryptError, status);
// Add the subsamples pointer and expect success.
buf.subsamples = &sub[0];
status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kSuccess, status);
EXPECT_EQ(
0, memcmp(output.DecryptedBuffer()->Data(), &expected[0], buf.data_size));
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, DecryptWithDataOffset) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
std::vector<uint8_t> encrypted = kInputVector3;
std::vector<uint8_t> iv = kIv3;
std::vector<uint8_t> expected = kOutputVector3;
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, kInputOffset3);
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
cdm::Buffer* output_buf = output.DecryptedBuffer();
EXPECT_EQ(cdm::kSuccess, status);
EXPECT_EQ(buf.data_size - buf.data_offset, output_buf->Size());
EXPECT_EQ(0, memcmp(output.DecryptedBuffer()->Data(), &expected[0],
output_buf->Size()));
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, DecryptReturnsSizedBuffer) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
std::vector<uint8_t> encrypted = kInputVector1;
std::vector<uint8_t> iv = kIv1;
std::vector<uint8_t> expected = kOutputVector1;
std::vector<cdm::SubsampleEntry> sub = BuildSingleSubsample(encrypted.size());
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
TestDecryptedBlock output;
cdm::Status status = cdm_->Decrypt(buf, &output);
EXPECT_EQ(cdm::kSuccess, status);
cdm::Buffer* buffer = output.DecryptedBuffer();
EXPECT_NE((void*)NULL, buffer);
if (buffer) {
EXPECT_EQ(expected.size(), output.DecryptedBuffer()->Size());
}
ReleaseSession(kSessionId1);
}
// This exercises both timers and renewal.
TEST_F(CdmApi4Test, RenewalTest) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
// We expect that by the time we've added a key, the CDM has set a timer.
// Otherwise, it couldn't correctly handle renewal.
EXPECT_NE(0, host_->NumTimers());
host_->FastForwardTime(kTestPolicyRenewalDelaySeconds +
kDelayWaitToForRenewalMessageSeconds);
// When the timer expired, we should have sent a renewal, so we can
// add this renewed key now, assuming things are working as expected.
ProcessKeyResponse(true);
// And the key should have been added.
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, SecureDecryptionLevel1) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
// Level 1 passes encrypted payload straight through. By calling the CDM's
// DecryptDecodeAndRender, OEMCrypto_DecryptCTR will be told to use Direct
// Rendering.
std::vector<uint8_t> encrypted = kInputVector1;
std::vector<uint8_t> iv = kIv1;
std::vector<cdm::SubsampleEntry> sub = BuildSingleSubsample(encrypted.size());
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
cdm::Status status;
status = cdm_->DecryptDecodeAndRender(buf, cdm::kStreamTypeVideo);
EXPECT_EQ(cdm::kSuccess, status);
status = cdm_->DecryptDecodeAndRender(buf, cdm::kStreamTypeAudio);
EXPECT_EQ(cdm::kSuccess, status);
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, SecureDecryptionLevel1WithSubsampleInfo) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
// Level 1 passes encrypted payload straight through. By calling the
// CDM's DecryptDecodeAndRender, OEMCrypto_DecryptCTR will be told
// to use Direct Rendering.
std::vector<uint8_t> encrypted = kInputVector2;
std::vector<uint8_t> iv = kIv2;
std::vector<cdm::SubsampleEntry> sub = BuildMultipleSubsamples();
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv, sub);
cdm::Status status;
status = cdm_->DecryptDecodeAndRender(buf, cdm::kStreamTypeVideo);
EXPECT_EQ(cdm::kSuccess, status);
status = cdm_->DecryptDecodeAndRender(buf, cdm::kStreamTypeAudio);
EXPECT_EQ(cdm::kSuccess, status);
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, SecureDecryptionLevel1WithMissingSubsampleInfo) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
std::vector<uint8_t> encrypted = kInputVector2;
std::vector<uint8_t> iv = kIv2;
std::vector<cdm::SubsampleEntry> sub = BuildMultipleSubsamples();
// Don't add these subsamples yet!
cdm::InputBuffer buf = BuildInputBuffer(encrypted, iv);
buf.num_subsamples = sub.size();
cdm::Status status;
status = cdm_->DecryptDecodeAndRender(buf, cdm::kStreamTypeVideo);
EXPECT_EQ(cdm::kDecryptError, status);
status = cdm_->DecryptDecodeAndRender(buf, cdm::kStreamTypeAudio);
EXPECT_EQ(cdm::kDecryptError, status);
// Add the subsamples pointer and expect success.
buf.subsamples = &sub[0];
status = cdm_->DecryptDecodeAndRender(buf, cdm::kStreamTypeVideo);
EXPECT_EQ(cdm::kSuccess, status);
status = cdm_->DecryptDecodeAndRender(buf, cdm::kStreamTypeAudio);
EXPECT_EQ(cdm::kSuccess, status);
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, GenerateKeyRequestFailureSendsKeyError) {
// Pass a bogus key id and expect failure.
// Expect the CDM to pass a key error back to the host.
CreateSession(kSessionId1, g_wrong_key_id, cdm::kTemporary);
EXPECT_EQ(1, host_->SessionErrorsSize());
EXPECT_EQ(0, host_->SessionMessagesSize());
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, UpdateSessionFailureSendsKeyError) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
TestHost_4::SessionMessage session_msg = host_->GetLastSessionMessage();
EXPECT_TRUE(session_msg.default_url.empty());
std::string drm_msg = GetKeyRequestResponse(
session_msg, g_license_server + g_client_auth, false);
// Call UpdateSession with a bad session id, and expect the CDM to pass a key
// error back to the host.
UpdateSession(kSessionId2, reinterpret_cast<const uint8_t*>(drm_msg.c_str()),
drm_msg.length());
EXPECT_EQ(1, host_->SessionErrorsSize());
// Call UpdateSession with a bad license, and expect the CDM to pass a key
// error back to the host.
static const std::string kBadLicense = "!kGoodLicense";
UpdateSession(kSessionId1,
reinterpret_cast<const uint8_t*>(kBadLicense.c_str()),
kBadLicense.length());
EXPECT_EQ(2, host_->SessionErrorsSize());
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, IsKeyValidDetectsValidKey) {
EXPECT_FALSE(cdm_->IsKeyValid(
reinterpret_cast<const uint8_t*>(kTestKeyId.data()), kTestKeyId.size()));
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ProcessKeyResponse(false);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
EXPECT_TRUE(cdm_->IsKeyValid(
reinterpret_cast<const uint8_t*>(kTestKeyId.data()), kTestKeyId.size()));
ReleaseSession(kSessionId1);
EXPECT_FALSE(cdm_->IsKeyValid(
reinterpret_cast<const uint8_t*>(kTestKeyId.data()), kTestKeyId.size()));
}
TEST_F(CdmApi4Test, OfflineLicense) {
// override default settings unless configured through the command line
std::string key_id;
std::string license_server;
std::string client_auth;
GetOfflineConfiguration(&key_id, &license_server, &client_auth);
CreateSession(kSessionId1, key_id, cdm::kPersistent);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
ProcessKeyResponse(false, license_server + client_auth);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, RestoreOfflineLicense) {
// override default settings unless configured through the command line
std::string key_id;
std::string license_server;
std::string client_auth;
GetOfflineConfiguration(&key_id, &license_server, &client_auth);
CreateSession(kSessionId1, key_id, cdm::kPersistent);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
ProcessKeyResponse(false, license_server + client_auth);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
std::string web_session_id = host_->session_map[kSessionId1];
EXPECT_FALSE(web_session_id.empty());
ReleaseSession(kSessionId1);
LoadSession(kSessionId2, web_session_id);
ASSERT_FALSE(SessionErrorPresent(kSessionId2));
ReleaseSession(kSessionId2);
}
TEST_F(CdmApi4Test, ReleaseOfflineLicense) {
// override default settings unless configured through the command line
std::string key_id;
std::string license_server;
std::string client_auth;
GetOfflineConfiguration(&key_id, &license_server, &client_auth);
CreateSession(kSessionId1, key_id, cdm::kPersistent);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
ProcessKeyResponse(false, license_server + client_auth);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
std::string web_session_id = host_->session_map[kSessionId1];
EXPECT_FALSE(web_session_id.empty());
ReleaseSession(kSessionId1);
RemoveSession(kSessionId2, web_session_id);
ProcessKeyResponse(true, license_server + client_auth);
ASSERT_FALSE(SessionErrorPresent(kSessionId2));
}
TEST_F(CdmApi4Test, MimeTypeMatters) {
CreateSessionWithMimeType(kSessionId1, "video/mp4");
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
ReleaseSession(kSessionId1);
CreateSessionWithMimeType(kSessionId1, "video/webm");
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
ReleaseSession(kSessionId1);
CreateSessionWithMimeType(kSessionId1, "video/blah");
ASSERT_TRUE(SessionErrorPresent(kSessionId1));
}
TEST_F(CdmApi4Test, UsePrivacyMode) {
ASSERT_EQ(cdm::kSuccess, UsePrivacyMode());
const CdmClientPropertySet& property_set =
reinterpret_cast<WvContentDecryptionModule_4*>(cdm_)->property_set_;
EXPECT_TRUE(property_set.use_privacy_mode());
}
TEST_F(CdmApi4Test, UsePrivacyModeFailsWithOpenSessions) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
EXPECT_NE(cdm::kSuccess, UsePrivacyMode());
const CdmClientPropertySet& property_set =
reinterpret_cast<WvContentDecryptionModule_4*>(cdm_)->property_set_;
EXPECT_FALSE(property_set.use_privacy_mode());
ReleaseSession(kSessionId1);
}
TEST_F(CdmApi4Test, SetExplicitServerCertificate) {
ASSERT_EQ(cdm::kSuccess, SetServerCertificate(kFakeServerCertficiate));
const CdmClientPropertySet& property_set =
reinterpret_cast<WvContentDecryptionModule_4*>(cdm_)->property_set_;
EXPECT_TRUE(property_set.use_privacy_mode());
const std::string& set_cert = property_set.service_certificate();
ASSERT_EQ(kFakeServerCertficiate.size(), set_cert.size());
EXPECT_EQ(0,
memcmp(&kFakeServerCertficiate[0], &set_cert[0], set_cert.size()));
}
TEST_F(CdmApi4Test, SetServerCertificateFailsWithOpenSessions) {
CreateSession(kSessionId1, g_key_id, cdm::kTemporary);
ASSERT_FALSE(SessionErrorPresent(kSessionId1));
EXPECT_NE(cdm::kSuccess, SetServerCertificate(kFakeServerCertficiate));
const CdmClientPropertySet& property_set =
reinterpret_cast<WvContentDecryptionModule_4*>(cdm_)->property_set_;
EXPECT_FALSE(property_set.use_privacy_mode());
ReleaseSession(kSessionId1);
}
} // namespace wvcdm

1078
cdm/test/cdm_test.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +0,0 @@
// Copyright 2014 Google Inc. All Rights Reserved.
#ifndef WVCDM_CDM_TEST_CDM_TEST_CONFIG_H_
#define WVCDM_CDM_TEST_CDM_TEST_CONFIG_H_
#include <string>
#include "config_test_env.h"
extern std::string g_client_auth;
extern std::string g_key_id;
extern std::string g_license_server;
extern std::string g_wrong_key_id;
static const wvcdm::LicenseServerId kLicenseServerId =
wvcdm::kContentProtectionServer;
#endif // WVCDM_CDM_TEST_CDM_TEST_CONFIG_H_

View File

@@ -1,96 +1,87 @@
// Copyright 2014 Google Inc. All Rights Reserved.
#include "cdm_test_config.h"
// Copyright 2015 Google Inc. All Rights Reserved.
#include <assert.h>
#include <getopt.h>
#include <gtest/gtest.h>
#include <time.h>
#include "log.h"
#include "string_conversions.h"
#if defined(__linux__)
#include <sys/utsname.h>
#endif
// 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;
std::string g_key_id;
std::string g_license_server;
std::string g_wrong_key_id;
#include "cdm.h"
#include "device_cert.h"
#include "override.h"
#include "test_host.h"
#if defined(OEMCRYPTO_TESTS)
# include "oemcrypto_test.h"
#endif
using namespace widevine;
TestHost* g_host = NULL;
int main(int argc, char** argv) {
// Init gtest and let it consume arguments.
::testing::InitGoogleTest(&argc, argv);
wvcdm::InitLogging(argc, argv);
wvcdm::ConfigTestEnv config(kLicenseServerId);
g_client_auth.assign(config.client_auth());
g_wrong_key_id.assign(config.wrong_key_id());
// The following variables are configurable through command line options.
g_license_server.assign(config.license_server());
g_key_id.assign(config.key_id());
std::string license_server(g_license_server);
// Parse arguments.
int show_usage = 0;
static const struct option long_options[] = {
{"keyid", required_argument, NULL, 'k'},
{"server", required_argument, NULL, 's'},
{NULL, 0, NULL, '\0'}};
int option_index = 0;
int opt = 0;
while ((opt = getopt_long(argc, argv, "k:s:v", long_options,
&option_index)) != -1) {
int opt;
int verbosity = 0;
while ((opt = getopt_long(argc, argv, "v", NULL, NULL)) != -1) {
switch (opt) {
case 'k': {
g_key_id.clear();
g_key_id.assign(optarg);
case 'v':
++verbosity;
break;
}
case 's': {
g_license_server.clear();
g_license_server.assign(optarg);
break;
}
case 'v': {
// This option has already been consumed by wvcdm::InitLogging() above.
// We only tell getopt about it so that it is not an error. We ignore
// the option here when seen.
// TODO: Stop passing argv to InitLogging, and instead set the log
// level here through the logging API. We should keep all command-line
// parsing at the application level, rather than split between various
// apps and various platform-specific logging implementations.
break;
}
case '?': {
case '?':
show_usage = 1;
break;
}
}
}
if (show_usage) {
std::cout << std::endl;
std::cout << "usage: " << argv[0] << " [options]" << std::endl << std::endl;
std::cout << std::setw(30) << std::left << " --server=<server_url>";
std::cout
<< "configure the license server url, please include http[s] in the url"
<< std::endl;
std::cout << std::setw(30) << std::left << " ";
std::cout << "default: " << license_server << std::endl;
std::cout << std::setw(30) << std::left << " --keyid=<key_id>";
std::cout << "configure the key id or pssh, in hex format" << std::endl;
std::cout << std::setw(30) << std::left << " default keyid:";
std::cout << g_key_id << std::endl;
fprintf(stderr, "Usage: %s [-v|-vv|-vvv]\n\n", argv[0]);
return 0;
}
std::cout << std::endl;
std::cout << "Server: " << g_license_server << std::endl;
std::cout << "KeyID: " << g_key_id << std::endl << std::endl;
// Set up a Host so that tests and initialize the library. This makes these
// services available to the tests. We would do this in the test suite
// itself, but the core & OEMCrypto tests don't know they depend on this
// for storage.
g_host = new TestHost();
Cdm::ClientInfo client_info;
// Set client info that denotes this as the test suite:
client_info.product_name = "CE cdm tests";
client_info.company_name = "www";
client_info.model_name = "www";
#if defined(__linux__)
client_info.device_name = "Linux";
{
struct utsname name;
if (uname(&name) == 0) {
client_info.arch_name = name.machine;
}
}
#else
client_info.device_name = "unknown";
#endif
client_info.build_info = __DATE__;
g_key_id = wvcdm::a2bs_hex(g_key_id);
config.set_license_server(g_license_server);
config.set_key_id(g_key_id);
Cdm::DeviceCertificateRequest cert_request;
Cdm::Status status = Cdm::initialize(
Cdm::kNoSecureOutput, client_info, g_host, g_host, g_host, &cert_request,
static_cast<Cdm::LogLevel>(verbosity));
assert(status == Cdm::kSuccess);
assert(cert_request.needed == false);
#if defined(OEMCRYPTO_TESTS)
// Set up the OEMCrypto test harness.
wvoec::global_features.Initialize(false /* is_cast_receiver */,
false /* force_load_test_keybox */);
::testing::GTEST_FLAG(filter)
= wvoec::global_features.RestrictFilter(::testing::GTEST_FLAG(filter));
#endif
return RUN_ALL_TESTS();
}

View File

@@ -0,0 +1,67 @@
// Copyright 2015 Google Inc. All Rights Reserved.
#include "cdm_test_printers.h"
namespace widevine {
void PrintTo(const Cdm::MessageType& value, ::std::ostream* os) {
switch (value) {
case Cdm::kLicenseRequest: *os << "Cdm::kLicenseRequest";
break;
case Cdm::kLicenseRenewal: *os << "Cdm::kLicenseRenewal";
break;
case Cdm::kLicenseRelease: *os << "Cdm::kLicenseRelease";
break;
case Cdm::kIndividualizationRequest:
*os << "Cdm::kIndividualizationRequest";
break;
default: *os << "Unknown Cdm::MessageType value " << value;
break;
}
}
void PrintTo(const Cdm::Status& value, ::std::ostream* os) {
switch (value) {
case Cdm::kSuccess: *os << "Cdm::kSuccess";
break;
case Cdm::kNeedsDeviceCertificate: *os << "Cdm::kNeedsDeviceCertificate";
break;
case Cdm::kSessionNotFound: *os << "Cdm::kSessionNotFound";
break;
case Cdm::kDecryptError: *os << "Cdm::kDecryptError";
break;
case Cdm::kNoKey: *os << "Cdm::kNoKey";
break;
case Cdm::kInvalidAccess: *os << "Cdm::kInvalidAccess";
break;
case Cdm::kNotSupported: *os << "Cdm::kNotSupported";
break;
case Cdm::kInvalidState: *os << "Cdm::kInvalidState";
break;
case Cdm::kQuotaExceeded: *os << "Cdm::kQuotaExceeded";
break;
case Cdm::kUnexpectedError: *os << "Cdm::kUnexpectedError";
break;
default: *os << "Unknown Cdm::Status value " << value;
break;
}
}
void PrintTo(const Cdm::KeyStatus& value, ::std::ostream* os) {
switch (value) {
case Cdm::kUsable: *os << "Cdm::kUsable";
break;
case Cdm::kExpired: *os << "Cdm::kExpired";
break;
case Cdm::kOutputNotAllowed: *os << "Cdm::kOutputNotAllowed";
break;
case Cdm::kStatusPending: *os << "Cdm::kStatusPending";
break;
case Cdm::kInternalError: *os << "Cdm::kInternalError";
break;
default: *os << "Unknown Cdm::KeyStatus value " << value;
break;
}
}
} // namespace widevine

View File

@@ -0,0 +1,19 @@
// Copyright 2015 Google Inc. All Rights Reserved.
// This file adds some print methods so that when unit tests fail, the
// will print the name of an enumeration instead of the numeric value.
#ifndef WVCDM_CDM_TEST_CDM_TEST_PRINTERS_H_
#define WVCDM_CDM_TEST_CDM_TEST_PRINTERS_H_
#include <iostream>
#include "cdm.h"
namespace widevine {
void PrintTo(const Cdm::MessageType& value, ::std::ostream* os);
void PrintTo(const Cdm::Status& value, ::std::ostream* os);
void PrintTo(const Cdm::KeyStatus& value, ::std::ostream* os);
} // namespace widevine
#endif // WVCDM_CDM_TEST_CDM_TEST_PRINTERS_H_

View File

@@ -5,77 +5,77 @@
const uint8_t kDeviceCert[] = {
0x0A, 0x9A, 0x14, 0x08, 0x01, 0x10, 0x01, 0x1A,
0x93, 0x14, 0x0A, 0xED, 0x09, 0x0A, 0xAE, 0x02,
0x08, 0x02, 0x12, 0x10, 0x19, 0x77, 0x50, 0x4D,
0x66, 0x1C, 0x28, 0xBE, 0x41, 0xD3, 0xAA, 0x33,
0x98, 0x3D, 0xB5, 0x46, 0x18, 0x8D, 0xA3, 0x81,
0x9E, 0x05, 0x22, 0x8E, 0x02, 0x30, 0x82, 0x01,
0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xB2, 0xA8,
0x6A, 0x68, 0x01, 0x84, 0xC2, 0x62, 0x08, 0x8D,
0xFB, 0x5E, 0xA7, 0x5B, 0xC2, 0x70, 0x6E, 0xF0,
0xE1, 0xF7, 0xCE, 0x0D, 0x06, 0x29, 0x8A, 0x8C,
0x11, 0x6C, 0xB8, 0xBD, 0xEC, 0xA5, 0x9F, 0x60,
0x65, 0x9F, 0x89, 0x52, 0xC0, 0x72, 0xF8, 0x2A,
0x30, 0xBD, 0xB8, 0x52, 0xFF, 0x2F, 0x6C, 0xAE,
0x36, 0x1E, 0xED, 0xC2, 0x0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 0x17, 0x7A, 0xF2, 0x77, 0x57,
0x5F, 0x40, 0xF8, 0x58, 0xF4, 0x96, 0xDF, 0x6E,
0xFC, 0xB9, 0x70, 0x17, 0x08, 0x5B, 0x43, 0x29,
0x4D, 0xD4, 0xA7, 0x6C, 0xDD, 0x8E, 0xC7, 0xFD,
0x8D, 0xE9, 0xE1, 0xBA, 0x7E, 0xFF, 0x39, 0xE5,
0x74, 0x79, 0x5E, 0x9A, 0x29, 0x2F, 0xC3, 0x0D,
0xDD, 0x65, 0x1C, 0x2F, 0xBB, 0x3C, 0x50, 0x8F,
0x5B, 0x47, 0x9A, 0x91, 0xEF, 0xC4, 0x0F, 0x7F,
0xCD, 0x85, 0xBC, 0x7C, 0x41, 0x9C, 0x96, 0x59,
0x17, 0x9B, 0x95, 0x3E, 0x26, 0x41, 0xDD, 0xE5,
0xD1, 0x72, 0x85, 0x10, 0x05, 0x9C, 0xBF, 0x88,
0x26, 0x29, 0xBE, 0x96, 0x6C, 0x0C, 0x36, 0x76,
0xE8, 0x06, 0xC5, 0x04, 0xD9, 0x06, 0xA8, 0x79,
0xF8, 0xEA, 0xF0, 0x60, 0xAF, 0x12, 0x20, 0xA8,
0x98, 0xAD, 0x74, 0xB9, 0x6F, 0x94, 0xCA, 0xCB,
0xDD, 0x9C, 0x4E, 0x62, 0xDF, 0xD1, 0x59, 0x3E,
0x58, 0xEE, 0x82, 0xB9, 0xAD, 0x9E, 0xB7, 0x45,
0x2C, 0x1F, 0x8C, 0x15, 0x77, 0xCC, 0xD2
};
const size_t kDeviceCertSize = sizeof(kDeviceCert);

93
cdm/test/test_host.cpp Normal file
View File

@@ -0,0 +1,93 @@
// Copyright 2015 Google Inc. All Rights Reserved.
#include "test_host.h"
#include <gtest/gtest.h>
#include <sys/time.h>
#include "device_cert.h"
#include "log.h"
using namespace widevine;
TestHost::TestHost() {
Reset();
}
void TestHost::Reset() {
struct timeval tv;
tv.tv_sec = tv.tv_usec = 0;
gettimeofday(&tv, NULL);
now_ = (tv.tv_sec * 1000LL) + (tv.tv_usec / 1000LL);
// Surprisingly, std::priority_queue has no clear().
while (!timers_.empty()) {
timers_.pop();
}
files_.clear();
files_["cert.bin"] =
std::string((const char*)kDeviceCert, kDeviceCertSize);
}
void TestHost::ElapseTime(int64_t milliseconds) {
int64_t goal_time = now_ + milliseconds;
while (now_ < goal_time) {
if (timers_.empty()) {
now_ = goal_time;
} else {
Timer t = timers_.top();
timers_.pop();
ASSERT_GE(t.expiry_time, now_);
now_ = t.expiry_time;
t.client->onTimerExpired(t.context);
}
}
}
int TestHost::NumTimers() const { return timers_.size(); }
bool TestHost::read(const std::string& name,
std::string* data) {
StorageMap::iterator it = files_.find(name);
bool ok = it != files_.end();
LOGD("read file: %s: %s", name.c_str(), ok ? "ok" : "fail");
if (!ok) return false;
*data = it->second;
return true;
}
bool TestHost::write(const std::string& name,
const std::string& data) {
LOGD("write file: %s", name.c_str());
files_[name] = data;
return true;
}
bool TestHost::exists(const std::string& name) {
StorageMap::iterator it = files_.find(name);
bool ok = it != files_.end();
LOGD("exists? %s: %s", name.c_str(), ok ? "true" : "false");
return ok;
}
bool TestHost::remove(const std::string& name) {
files_.erase(name);
return true;
}
int32_t TestHost::size(const std::string& name) {
StorageMap::iterator it = files_.find(name);
if (it == files_.end()) return -1;
return it->second.size();
}
int64_t TestHost::now() {
return now_;
}
void TestHost::setTimeout(int64_t delay_ms,
IClient* client,
void* context) {
int64_t expiry_time = now_ + delay_ms;
timers_.push(Timer(expiry_time, client, context));
}

60
cdm/test/test_host.h Normal file
View File

@@ -0,0 +1,60 @@
// Copyright 2015 Google Inc. All Rights Reserved.
#ifndef WVCDM_CDM_TEST_TEST_HOST_H_
#define WVCDM_CDM_TEST_TEST_HOST_H_
#include <queue>
#include "cdm.h"
#include "override.h"
class TestHost : public widevine::Cdm::IStorage,
public widevine::Cdm::IClock,
public widevine::Cdm::ITimer {
public:
TestHost();
void Reset();
void ElapseTime(int64_t milliseconds);
int NumTimers() const;
virtual bool read(const std::string& name,
std::string* data) OVERRIDE;
virtual bool write(const std::string& name,
const std::string& data) OVERRIDE;
virtual bool exists(const std::string& name) OVERRIDE;
virtual bool remove(const std::string& name) OVERRIDE;
virtual int32_t size(const std::string& name) OVERRIDE;
virtual int64_t now() OVERRIDE;
virtual void setTimeout(int64_t delay_ms,
IClient* client,
void* context) OVERRIDE;
private:
struct Timer {
Timer(int64_t expiry_time, IClient* client, void* context)
: expiry_time(expiry_time), client(client), context(context) {}
bool operator<(const Timer& other) const {
// We want to reverse the order so that the smallest expiry times go to
// the top of the priority queue.
return expiry_time > other.expiry_time;
}
int64_t expiry_time;
IClient* client;
void* context;
};
int64_t now_;
std::priority_queue<Timer> timers_;
typedef std::map<std::string, std::string> StorageMap;
StorageMap files_;
};
// Owned and managed by the test runner.
extern TestHost* g_host;
#endif // WVCDM_CDM_TEST_TEST_HOST_H_

View File

@@ -1,134 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
// Review the TestHost_1 class below to observe how the CDM interfaces with
// the host application.
#include "test_host_1.h"
#include <gtest/gtest.h>
#include <sys/time.h>
#include "test_util.h"
static double GetCurrentTime() {
struct timeval tv;
tv.tv_sec = tv.tv_usec = 0;
gettimeofday(&tv, NULL);
return tv.tv_sec + (tv.tv_usec / (1000.0 * 1000.0));
}
TestHost_1::TestHost_1()
: current_time_(GetCurrentTime()),
has_new_key_message_(false),
has_new_key_error_(false),
cdm_(NULL) {
}
TestHost_1::~TestHost_1() {
if (cdm_)
cdm_->Destroy();
}
cdm::Buffer* TestHost_1::Allocate(int32_t capacity) {
return TestBuffer::Create(capacity);
}
void TestHost_1::SetTimer(int64_t delay_ms, void* context) {
double expiry_time = current_time_ + (delay_ms / 1000.0);
timers_.push(Timer(expiry_time, context));
}
double TestHost_1::GetCurrentWallTimeInSeconds() {
return current_time_;
}
void TestHost_1::SendKeyMessage(const char* session_id,
int32_t session_id_length, const char* message,
int32_t message_length, const char* default_url,
int32_t default_url_length) {
KeyMessage key_message;
key_message.session_id.assign(session_id, session_id_length);
key_message.message.assign(message, message_length);
key_message.default_url.assign(default_url, default_url_length);
key_messages_.push_back(key_message);
has_new_key_message_ = true;
}
void TestHost_1::SendKeyError(const char* session_id, int32_t session_id_length,
cdm::MediaKeyError error_code,
uint32_t system_code) {
KeyError key_error;
key_error.session_id.assign(session_id, session_id_length);
key_error.error_code = error_code;
key_error.system_code = system_code;
key_errors_.push_back(key_error);
has_new_key_error_ = true;
}
void TestHost_1::FastForwardTime(double seconds) {
double goal_time = current_time_ + seconds;
while (current_time_ < goal_time) {
if (timers_.empty()) {
current_time_ = goal_time;
} else {
Timer t = timers_.top();
timers_.pop();
ASSERT_GE(t.expiry_time, current_time_);
current_time_ = t.expiry_time;
cdm_->TimerExpired(t.context);
}
}
}
void TestHost_1::GetPlatformString(const std::string& name,
std::string* value) {
*value = platform_strings_[name];
}
void TestHost_1::SetPlatformString(const std::string& name,
const std::string& value) {
platform_strings_[name] = value;
}
int TestHost_1::KeyMessagesSize() const { return key_messages_.size(); }
int TestHost_1::KeyErrorsSize() const { return key_errors_.size(); }
int TestHost_1::NumTimers() const { return timers_.size(); }
TestHost_1::KeyMessage TestHost_1::GetLastKeyMessage() {
if (!has_new_key_message_) {
return KeyMessage();
}
if (key_messages_.empty()) {
return KeyMessage();
}
has_new_key_message_ = false;
return key_messages_.back();
}
TestHost_1::KeyError TestHost_1::GetLastKeyError() {
if (!has_new_key_error_) return KeyError();
if (key_errors_.empty()) return KeyError();
has_new_key_error_ = false;
return key_errors_.back();
}
TestHost_1::KeyMessage TestHost_1::GetKeyMessage(int index) const {
return key_messages_[index];
}
TestHost_1::KeyError TestHost_1::GetKeyError(int index) const {
return key_errors_[index];
}
void TestHost_1::SetCdmPtr(cdm::ContentDecryptionModule_1* cdm) {
if (cdm_) {
cdm_->Destroy();
}
cdm_ = cdm;
}

View File

@@ -1,105 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
#ifndef WVCDM_CDM_TEST_TEST_HOST_1_H_
#define WVCDM_CDM_TEST_TEST_HOST_1_H_
#include "content_decryption_module.h"
#include <map>
#include <queue>
#include "wv_cdm_common.h"
#include "wv_cdm_types.h"
class TestHost_1 : public cdm::Host_1 {
public:
// These structs are used to store the KeyMessages and KeyErrors passed to
// this class' objects.
struct KeyMessage {
std::string session_id;
std::string message;
std::string default_url;
};
struct KeyError {
KeyError() : error_code(cdm::kUnknownError), system_code(0) {}
std::string session_id;
cdm::MediaKeyError error_code;
uint32_t system_code;
};
TestHost_1();
virtual ~TestHost_1();
// cdm::Host implementation.
virtual cdm::Buffer* Allocate(int32_t capacity) OVERRIDE;
virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE;
virtual double GetCurrentWallTimeInSeconds() OVERRIDE;
virtual void SendKeyMessage(const char* session_id, int32_t session_id_length,
const char* message, int32_t message_length,
const char* default_url,
int32_t default_url_length) OVERRIDE;
virtual void SendKeyError(const char* session_id, int32_t session_id_length,
cdm::MediaKeyError error_code,
uint32_t system_code) OVERRIDE;
virtual void GetPlatformString(const std::string& name,
std::string* value) OVERRIDE;
virtual void SetPlatformString(const std::string& name,
const std::string& value) OVERRIDE;
// Methods only for this test.
void FastForwardTime(double seconds);
int KeyMessagesSize() const;
int KeyErrorsSize() const;
int NumTimers() const;
// Returns Key{Message,Error} (replace Message with Error for KeyError). It
// returns the most recent message passed to SendKeyMessage(). Another call
// to this method without a new SendKeyMessage() call will return an empty
// KeyMessage struct.
KeyMessage GetLastKeyMessage();
KeyError GetLastKeyError();
KeyMessage GetKeyMessage(int index) const;
KeyError GetKeyError(int index) const;
void SetCdmPtr(cdm::ContentDecryptionModule_1* cdm);
private:
struct Timer {
Timer(double expiry_time, void* context)
: expiry_time(expiry_time), context(context) {}
bool operator<(const Timer& other) const {
// We want to reverse the order so that the smallest expiry times go to
// the top of the priority queue.
return expiry_time > other.expiry_time;
}
double expiry_time;
void* context;
};
double current_time_;
std::priority_queue<Timer> timers_;
std::vector<KeyMessage> key_messages_;
std::vector<KeyError> key_errors_;
bool has_new_key_message_;
bool has_new_key_error_;
std::map<std::string, std::string> platform_strings_;
cdm::ContentDecryptionModule_1* cdm_;
CORE_DISALLOW_COPY_AND_ASSIGN(TestHost_1);
};
#endif // WVCDM_CDM_TEST_TEST_HOST_1_H_

View File

@@ -1,137 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
// Review the TestHost_4 class below to observe how the CDM interfaces with
// the host application.
#include "test_host_4.h"
#include <gtest/gtest.h>
#include <sys/time.h>
#include "test_host_4_file_io.h"
#include "test_util.h"
static double GetCurrentTime() {
struct timeval tv;
tv.tv_sec = tv.tv_usec = 0;
gettimeofday(&tv, NULL);
return tv.tv_sec + (tv.tv_usec / (1000.0 * 1000.0));
}
TestHost_4::TestHost_4()
: current_time_(GetCurrentTime()),
has_new_session_message_(false),
has_new_session_error_(false),
cdm_(NULL) {}
TestHost_4::~TestHost_4() {
if (cdm_) cdm_->Destroy();
}
cdm::Buffer* TestHost_4::Allocate(uint32_t capacity) {
return TestBuffer::Create(capacity);
}
void TestHost_4::SetTimer(int64_t delay_ms, void* context) {
double expiry_time = current_time_ + (delay_ms / 1000.0);
timers_.push(Timer(expiry_time, context));
}
double TestHost_4::GetCurrentWallTimeInSeconds() { return current_time_; }
void TestHost_4::FastForwardTime(double seconds) {
double goal_time = current_time_ + seconds;
while (current_time_ < goal_time) {
if (timers_.empty()) {
current_time_ = goal_time;
} else {
Timer t = timers_.top();
timers_.pop();
ASSERT_GE(t.expiry_time, current_time_);
current_time_ = t.expiry_time;
cdm_->TimerExpired(t.context);
}
}
}
int TestHost_4::SessionMessagesSize() const { return session_messages_.size(); }
int TestHost_4::SessionErrorsSize() const { return session_errors_.size(); }
int TestHost_4::NumTimers() const { return timers_.size(); }
TestHost_4::SessionMessage TestHost_4::GetLastSessionMessage() {
if (!has_new_session_message_) {
return SessionMessage();
}
if (session_messages_.empty()) {
return SessionMessage();
}
has_new_session_message_ = false;
return session_messages_.back();
}
TestHost_4::SessionError TestHost_4::GetLastSessionError() {
if (!has_new_session_error_) return SessionError();
if (session_errors_.empty()) return SessionError();
has_new_session_error_ = false;
return session_errors_.back();
}
TestHost_4::SessionMessage TestHost_4::GetSessionMessage(int index) const {
return session_messages_[index];
}
TestHost_4::SessionError TestHost_4::GetSessionError(int index) const {
return session_errors_[index];
}
void TestHost_4::SetCdmPtr(cdm::ContentDecryptionModule_4* cdm) {
if (cdm_) {
cdm_->Destroy();
}
cdm_ = cdm;
}
void TestHost_4::OnSessionCreated(uint32_t session_id,
const char* web_session_id,
uint32_t web_session_id_length) {
std::string webid(web_session_id, web_session_id_length);
session_map[session_id] = webid; // keep a parallel map with cdm.
}
void TestHost_4::OnSessionMessage(uint32_t session_id, const char* message,
uint32_t message_length,
const char* destination_url,
uint32_t destination_url_length) {
SessionMessage session_message;
session_message.session_id = session_id;
session_message.message.assign(message, message_length);
session_message.default_url.assign(destination_url, destination_url_length);
session_messages_.push_back(session_message);
has_new_session_message_ = true;
}
void TestHost_4::OnSessionUpdated(uint32_t session_id) {}
void TestHost_4::OnSessionClosed(uint32_t session_id) {
session_map.erase(session_id);
}
void TestHost_4::OnSessionError(uint32_t session_id, cdm::Status error_code,
uint32_t system_code) {
SessionError session_error;
session_error.session_id = session_id;
session_error.error_code = error_code;
session_error.system_code = system_code;
session_errors_.push_back(session_error);
has_new_session_error_ = true;
}
cdm::FileIO* TestHost_4::CreateFileIO(cdm::FileIOClient* client) {
return new TestHost_4_FileIO(this, client);
}

View File

@@ -1,108 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
#ifndef WVCDM_CDM_TEST_TEST_HOST_4_H_
#define WVCDM_CDM_TEST_TEST_HOST_4_H_
#include "content_decryption_module.h"
#include "gmock/gmock.h"
#include <queue>
#include "wv_cdm_common.h"
#include "wv_cdm_types.h"
class TestHost_4 : public cdm::Host_4 {
public:
// These structs are used to store the SessionMessages and SessionErrors
// passed to this class' objects.
struct SessionMessage {
uint32_t session_id;
std::string message;
std::string default_url;
};
struct SessionError {
uint32_t session_id;
cdm::Status error_code;
uint32_t system_code;
};
TestHost_4();
virtual ~TestHost_4();
// cdm::Host implementation.
virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE;
virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE;
virtual double GetCurrentWallTimeInSeconds() OVERRIDE;
virtual void OnSessionCreated(uint32_t session_id, const char* web_session_id,
uint32_t web_session_id_length) OVERRIDE;
virtual void OnSessionMessage(uint32_t session_id, const char* message,
uint32_t message_length,
const char* destination_url,
uint32_t destination_url_length) OVERRIDE;
virtual void OnSessionUpdated(uint32_t session_id) OVERRIDE;
virtual void OnSessionClosed(uint32_t session_id) OVERRIDE;
virtual void OnSessionError(uint32_t session_id, cdm::Status error_code,
uint32_t system_code) OVERRIDE;
virtual cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) OVERRIDE;
// Methods only for this test.
void FastForwardTime(double seconds);
int SessionMessagesSize() const;
int SessionErrorsSize() const;
int NumTimers() const;
// Returns Key{Message,Error} (replace Message with Error for SessionError).
// It returns the most recent message passed to SendSessionMessage(). Another
// call to this method without a new SendSessionMessage() call will return an
// empty SessionMessage struct.
SessionMessage GetLastSessionMessage();
SessionError GetLastSessionError();
SessionMessage GetSessionMessage(int index) const;
SessionError GetSessionError(int index) const;
void SetCdmPtr(cdm::ContentDecryptionModule_4* cdm);
std::map<uint32_t, std::string> session_map;
// Accessed by all FileIO objects.
std::map<std::string, std::string> file_store;
private:
struct Timer {
Timer(double expiry_time, void* context)
: expiry_time(expiry_time), context(context) {}
bool operator<(const Timer& other) const {
// We want to reverse the order so that the smallest expiry times go to
// the top of the priority queue.
return expiry_time > other.expiry_time;
}
double expiry_time;
void* context;
};
double current_time_;
std::priority_queue<Timer> timers_;
std::vector<SessionMessage> session_messages_;
std::vector<SessionError> session_errors_;
bool has_new_session_message_;
bool has_new_session_error_;
cdm::ContentDecryptionModule_4* cdm_;
CORE_DISALLOW_COPY_AND_ASSIGN(TestHost_4);
};
#endif // WVCDM_CDM_TEST_TEST_HOST_4_H_

View File

@@ -1,31 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
// Review the TestHost_4 class below to observe how the CDM interfaces with
// the host application.
#include "test_host_4_file_io.h"
#include <gtest/gtest.h>
void TestHost_4_FileIO::Open(const char* file_name, uint32_t file_name_size) {
ASSERT_EQ(0, file_name_.size());
file_name_.assign(file_name, file_name_size);
client_->OnOpenComplete(cdm::FileIOClient::kSuccess);
}
void TestHost_4_FileIO::Read() {
ASSERT_NE(0, file_name_.size());
const std::string& data = host_->file_store[file_name_];
client_->OnReadComplete(cdm::FileIOClient::kSuccess,
reinterpret_cast<const uint8_t*>(data.data()),
data.size());
}
void TestHost_4_FileIO::Write(const uint8_t* data, uint32_t data_size) {
ASSERT_NE(0, file_name_.size());
host_->file_store[file_name_].assign(reinterpret_cast<const char*>(data),
data_size);
client_->OnWriteComplete(cdm::FileIOClient::kSuccess);
}
void TestHost_4_FileIO::Close() { delete this; }

View File

@@ -1,34 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
#ifndef WVCDM_CDM_TEST_TEST_HOST_4_FILE_IO_H_
#define WVCDM_CDM_TEST_TEST_HOST_4_FILE_IO_H_
#include <string>
#include "content_decryption_module.h"
#include "test_host_4.h"
#include "wv_cdm_common.h"
#include "wv_cdm_types.h"
class TestHost_4_FileIO : public cdm::FileIO {
public:
TestHost_4_FileIO(TestHost_4* host, cdm::FileIOClient* client)
: host_(host), client_(client) {}
virtual ~TestHost_4_FileIO() {}
// cdm::FileIO implementation.
virtual void Open(const char* file_name, uint32_t file_name_size) OVERRIDE;
virtual void Read() OVERRIDE;
virtual void Write(const uint8_t* data, uint32_t data_size) OVERRIDE;
virtual void Close() OVERRIDE;
private:
TestHost_4* host_;
cdm::FileIOClient* client_;
std::string file_name_;
CORE_DISALLOW_COPY_AND_ASSIGN(TestHost_4_FileIO);
};
#endif // WVCDM_CDM_TEST_TEST_HOST_4_FILE_IO_H_

View File

@@ -1,52 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
#include "test_util.h"
TestBuffer* TestBuffer::Create(uint32_t capacity) {
return new TestBuffer(capacity);
}
void TestBuffer::Destroy() {
delete this;
}
int32_t TestBuffer::Capacity() const { return capacity_; }
uint8_t* TestBuffer::Data() { return buffer_; }
void TestBuffer::SetSize(int32_t size) { size_ = size; }
int32_t TestBuffer::Size() const { return size_; }
TestBuffer::TestBuffer(uint32_t capacity)
: buffer_(new uint8_t[capacity]),
capacity_(capacity) {}
TestBuffer::~TestBuffer() {
if (buffer_) {
delete[] buffer_;
buffer_ = NULL;
}
}
TestDecryptedBlock::TestDecryptedBlock() : buffer_(NULL), timestamp_(0) {}
TestDecryptedBlock::~TestDecryptedBlock() {
if (buffer_) {
buffer_->Destroy();
buffer_ = NULL;
}
}
void TestDecryptedBlock::SetDecryptedBuffer(cdm::Buffer* buffer) {
if (buffer_) buffer_->Destroy();
buffer_ = buffer;
}
cdm::Buffer* TestDecryptedBlock::DecryptedBuffer() { return buffer_; }
void TestDecryptedBlock::SetTimestamp(int64_t timestamp) {
timestamp_ = timestamp;
}
int64_t TestDecryptedBlock::Timestamp() const { return timestamp_; }

View File

@@ -1,58 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
#ifndef WVCDM_CDM_TEST_TEST_UTIL_H_
#define WVCDM_CDM_TEST_TEST_UTIL_H_
#include "content_decryption_module.h"
#include "wv_cdm_common.h"
#include "wv_cdm_types.h"
// These classes below are naive implementation of the abstract classes defined
// in the CDM interface (content_decryptiom_module.h), which are used for tests
// only.
class TestBuffer : public cdm::Buffer {
public:
static TestBuffer* Create(uint32_t capacity);
virtual void Destroy() OVERRIDE;
virtual int32_t Capacity() const OVERRIDE;
virtual uint8_t* Data() OVERRIDE;
virtual void SetSize(int32_t size) OVERRIDE;
virtual int32_t Size() const OVERRIDE;
private:
// TestBuffer can only be created by calling Create().
explicit TestBuffer(uint32_t capacity);
// TestBuffer can only be destroyed by calling Destroy().
virtual ~TestBuffer();
uint8_t* buffer_;
int32_t capacity_;
int32_t size_;
CORE_DISALLOW_COPY_AND_ASSIGN(TestBuffer);
};
class TestDecryptedBlock : public cdm::DecryptedBlock {
public:
TestDecryptedBlock();
virtual ~TestDecryptedBlock();
virtual void SetDecryptedBuffer(cdm::Buffer* buffer) OVERRIDE;
virtual cdm::Buffer* DecryptedBuffer() OVERRIDE;
virtual void SetTimestamp(int64_t timestamp) OVERRIDE;
virtual int64_t Timestamp() const OVERRIDE;
private:
cdm::Buffer* buffer_;
int64_t timestamp_;
CORE_DISALLOW_COPY_AND_ASSIGN(TestDecryptedBlock);
};
#endif // WVCDM_CDM_TEST_TEST_UTIL_H_