Address unit test failures
A number of failures were observed, * GPlay dev license server is being worked on. This causes random failures when running unit tests. Switching to the staging server for now. * Occasionally, the license server times out. Introducing a retry mechanism do deal with HTTP responses (merge from master #45e8ddd5f) * Release license tests are now disabled. Tests were previously passing, even though they were not in fact supported by the GPlay license server. The response included just enough information to be a valid license and passed minimal verification that was taking place. Additional verification was not necessary because session is torndown and resources released as soon as the response has been received. A change at the GPlay server now causes the release license request to be flagged as an error and the tests to fail. Work is in progress to support release of licenses at the GPlay server. * The wrong message test (from request license tests) fails. This is because GPlay behaviour changed from returning a HTTP 500, when processing an invalid PSSH, to returning a HTTP 200 without any included license. * Security level path backward compatibility tests on L3 which failed and caused the succeeding license request tests to fail. b/12000457 Change-Id: I8e6adc490504475d1039793ea555a17799cb78c4
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace {
|
||||
const int kHttpOk = 200;
|
||||
// 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;
|
||||
@@ -128,8 +129,7 @@ class WvCdmEngineTest : public testing::Test {
|
||||
|
||||
// posts a request and extracts the drm message from the response
|
||||
std::string GetKeyRequestResponse(const std::string& server_url,
|
||||
const std::string& client_auth,
|
||||
int expected_response) {
|
||||
const std::string& client_auth) {
|
||||
// Use secure connection and chunk transfer coding.
|
||||
UrlRequest url_request(server_url + client_auth, g_port, true, true);
|
||||
if (!url_request.is_connected()) {
|
||||
@@ -142,15 +142,8 @@ class WvCdmEngineTest : public testing::Test {
|
||||
LOGD("response:\r\n%s", response.c_str());
|
||||
LOGD("end %d bytes response dump", resp_bytes);
|
||||
|
||||
// Youtube server returns 400 for invalid message while play server returns
|
||||
// 500, so just test inequity here for invalid message
|
||||
int status_code = url_request.GetStatusCode(response);
|
||||
int kHttpOk = 200;
|
||||
if (expected_response == kHttpOk) {
|
||||
EXPECT_EQ(kHttpOk, status_code);
|
||||
} else {
|
||||
EXPECT_NE(kHttpOk, status_code);
|
||||
}
|
||||
EXPECT_EQ(kHttpOk, status_code);
|
||||
|
||||
if (status_code != kHttpOk) {
|
||||
return "";
|
||||
@@ -169,8 +162,7 @@ class WvCdmEngineTest : public testing::Test {
|
||||
const std::string& client_auth,
|
||||
std::string& init_data){
|
||||
std::string resp = GetKeyRequestResponse(server_url,
|
||||
client_auth,
|
||||
200);
|
||||
client_auth);
|
||||
CdmKeySetId key_set_id;
|
||||
EXPECT_EQ(cdm_engine_->AddKey(session_id_, resp, &key_set_id), KEY_ADDED);
|
||||
}
|
||||
@@ -179,8 +171,7 @@ class WvCdmEngineTest : public testing::Test {
|
||||
const std::string& client_auth,
|
||||
std::string& init_data){
|
||||
std::string resp = GetKeyRequestResponse(server_url,
|
||||
client_auth,
|
||||
200);
|
||||
client_auth);
|
||||
EXPECT_EQ(cdm_engine_->RenewKey(session_id_, resp), wvcdm::KEY_ADDED);
|
||||
}
|
||||
|
||||
@@ -201,13 +192,13 @@ TEST(WvCdmProvisioningTest, ProvisioningTest) {
|
||||
|
||||
TEST_F(WvCdmEngineTest, BaseMessageTest) {
|
||||
GenerateKeyRequest(g_key_system, g_key_id);
|
||||
GetKeyRequestResponse(g_license_server, g_client_auth, 200);
|
||||
GetKeyRequestResponse(g_license_server, g_client_auth);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmEngineTest, WrongMessageTest) {
|
||||
std::string wrong_message = a2bs_hex(g_wrong_key_id);
|
||||
GenerateKeyRequest(g_key_system, wrong_message);
|
||||
GetKeyRequestResponse(g_license_server, g_client_auth, 500);
|
||||
GetKeyRequestResponse(g_license_server, g_client_auth);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmEngineTest, NormalDecryption) {
|
||||
|
||||
@@ -24,7 +24,7 @@ const std::string kYtKeyId =
|
||||
|
||||
// Google Play license server data
|
||||
const std::string kGpLicenseServer =
|
||||
"https://jmt17.google.com/video-dev/license/GetCencLicense";
|
||||
"https://jmt17.google.com/video/license/GetCencLicense";
|
||||
|
||||
// NOTE: Append a userdata attribute to place a unique marker that the
|
||||
// server team can use to track down specific requests during debugging
|
||||
|
||||
@@ -209,7 +209,7 @@ LicenseInfo license_test_data[] = {
|
||||
"0112001A16200342120A106B63746C0000000000ECDCBE0000000020DBDF"
|
||||
"A68F051A20182F029E35047A3841FA176C74E5B387350E8D58DEA6878FF0"
|
||||
"BEA6CABACA1C2C"),
|
||||
"https://jmt17.google.com/video-dev/license/GetCencLicense",
|
||||
"https://jmt17.google.com/video/license/GetCencLicense",
|
||||
wvcdm::a2bs_hex(
|
||||
"0AAF150802100122A8150801121408011210303132333435363738394142"
|
||||
"434445461A9D0E080112950C0AD70B080112EF090AB002080212103E560E"
|
||||
|
||||
@@ -57,7 +57,7 @@ class PolicyEngineTest : public ::testing::Test {
|
||||
policy->set_renewal_recovery_duration_seconds(license_duration_ -
|
||||
license_renewal_delay_); // 10 minutes
|
||||
policy->set_renewal_server_url(
|
||||
"https://jmt17.google.com/video-dev/license/GetCencLicense");
|
||||
"https://jmt17.google.com/video/license/GetCencLicense");
|
||||
policy->set_renewal_delay_seconds(license_renewal_delay_);
|
||||
policy->set_renewal_retry_interval_seconds(
|
||||
license_renewal_retry_interval_);
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
#include "log.h"
|
||||
#include "string_conversions.h"
|
||||
|
||||
namespace {
|
||||
const int kMaxReadAttempts = 4;
|
||||
const int kSingleReadAttempt = 1;
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
UrlRequest::UrlRequest(const std::string& url, const std::string& port,
|
||||
@@ -104,16 +109,17 @@ int UrlRequest::GetResponse(std::string* message) {
|
||||
std::string response;
|
||||
const int kTimeoutInMs = 3000;
|
||||
int bytes = 0;
|
||||
do {
|
||||
for (int attempts = kMaxReadAttempts; attempts > 0; --attempts) {
|
||||
memset(buffer_, 0, kHttpBufferSize);
|
||||
bytes = socket_.Read(buffer_, kHttpBufferSize, kTimeoutInMs);
|
||||
if (bytes > 0) {
|
||||
response.append(buffer_, bytes);
|
||||
attempts = kSingleReadAttempt;
|
||||
} else {
|
||||
if (bytes < 0) LOGE("read error = ", errno);
|
||||
// bytes == 0 indicates nothing to read
|
||||
}
|
||||
} while (bytes > 0);
|
||||
};
|
||||
|
||||
ConcatenateChunkedResponse(response, message);
|
||||
LOGD("HTTP response: (%d): %s", message->size(), b2a_hex(*message).c_str());
|
||||
|
||||
Reference in New Issue
Block a user