Source release 14.1.0
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
// These tests are for the cdm engine, and code below it in the stack. In
|
||||
// particular, we assume that the OEMCrypo layer works, and has a valid keybox.
|
||||
// This is because we need a valid RSA certificate, and will attempt to connect
|
||||
@@ -11,10 +13,12 @@
|
||||
|
||||
#include "cdm_engine.h"
|
||||
#include "config_test_env.h"
|
||||
#include "device_files.h"
|
||||
#include "initialization_data.h"
|
||||
#include "file_store.h"
|
||||
#include "license_request.h"
|
||||
#include "log.h"
|
||||
#include "metrics.pb.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "properties.h"
|
||||
#include "scoped_ptr.h"
|
||||
@@ -26,6 +30,9 @@
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
using drm_metrics::WvCdmMetrics;
|
||||
using drm_metrics::DistributionMetric;
|
||||
|
||||
namespace {
|
||||
|
||||
// Http OK response code.
|
||||
@@ -185,13 +192,11 @@ class WvCdmEnginePreProvTest : public testing::Test {
|
||||
// try to provision. This is needed for testing nonce floods.
|
||||
CryptoSession keep_alive(cdm_engine_.GetMetrics()->GetCryptoMetrics());
|
||||
|
||||
ASSERT_EQ(NO_ERROR, cdm_engine_.SetProvisioningServiceCertificate(
|
||||
g_provisioning_service_certificate));
|
||||
CdmResponseType result = NO_ERROR;
|
||||
for(int i = 0; i < 2; ++i) { // Retry once if there is a nonce problem.
|
||||
result = cdm_engine_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &prov_request,
|
||||
&provisioning_server_url);
|
||||
cert_type, cert_authority, g_provisioning_service_certificate,
|
||||
&prov_request, &provisioning_server_url);
|
||||
if (result == CERT_PROVISIONING_NONCE_GENERATION_ERROR) {
|
||||
LOGW("Woops. Nonce problem. Try again?");
|
||||
sleep(1);
|
||||
@@ -287,11 +292,9 @@ class WvCdmEnginePreProvTestUatBinary : public WvCdmEnginePreProvTest {
|
||||
CdmCertificateType cert_type = kCertificateWidevine;
|
||||
std::string cert_authority;
|
||||
std::string cert, wrapped_key;
|
||||
ASSERT_EQ(NO_ERROR, cdm_engine_.SetProvisioningServiceCertificate(
|
||||
g_provisioning_service_certificate));
|
||||
ASSERT_EQ(NO_ERROR, cdm_engine_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, &binary_prov_request,
|
||||
&provisioning_server_url));
|
||||
cert_type, cert_authority, g_provisioning_service_certificate,
|
||||
&binary_prov_request, &provisioning_server_url));
|
||||
|
||||
// prov_request is binary - base64 encode it
|
||||
std::string prov_request(Base64SafeEncodeNoPad(
|
||||
@@ -458,29 +461,62 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
|
||||
CdmKeySetId key_set_id;
|
||||
EXPECT_EQ(KEY_ADDED,
|
||||
cdm_engine_.AddKey(session_id_, resp, &key_set_id));
|
||||
VerifyLicenseRequestLatency(kKeyRequestTypeInitial,
|
||||
*cdm_engine_.GetMetrics());
|
||||
}
|
||||
|
||||
void VerifyRenewalKeyResponse(const std::string& server_url,
|
||||
const std::string& client_auth) {
|
||||
std::string resp = GetKeyRequestResponse(server_url, client_auth);
|
||||
EXPECT_EQ(KEY_ADDED, cdm_engine_.RenewKey(session_id_, resp));
|
||||
VerifyLicenseRequestLatency(kKeyRequestTypeRenewal,
|
||||
*cdm_engine_.GetMetrics());
|
||||
}
|
||||
|
||||
void VerifyLicenseRequestLatency(
|
||||
CdmKeyRequestType key_request_type,
|
||||
const metrics::EngineMetrics& engine_metrics) {
|
||||
WvCdmMetrics metrics_proto;
|
||||
engine_metrics.Serialize(&metrics_proto);
|
||||
bool has_request_type = false;
|
||||
for (int i = 0; i < metrics_proto.session_metrics_size(); i++) {
|
||||
WvCdmMetrics::SessionMetrics session_metrics =
|
||||
metrics_proto.session_metrics(i);
|
||||
for (int j = 0;
|
||||
j < session_metrics.cdm_session_license_request_latency_ms_size();
|
||||
j++) {
|
||||
DistributionMetric latency_distribution =
|
||||
session_metrics.cdm_session_license_request_latency_ms(j);
|
||||
if (latency_distribution.attributes().key_request_type()
|
||||
== key_request_type && latency_distribution.operation_count() > 0) {
|
||||
has_request_type = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string serialized_metrics;
|
||||
ASSERT_TRUE(metrics_proto.SerializeToString(&serialized_metrics));
|
||||
EXPECT_TRUE(has_request_type)
|
||||
<< "Expected request type " << key_request_type << " was not found. "
|
||||
<< "metrics: " << wvcdm::b2a_hex(serialized_metrics);
|
||||
}
|
||||
|
||||
std::string server_url_;
|
||||
};
|
||||
|
||||
// Test that service certificate is initially absent.
|
||||
TEST_F(WvCdmEnginePreProvTestStaging,
|
||||
ProvisioningServiceCertificateInitialNoneTest) {
|
||||
ASSERT_FALSE(cdm_engine_.HasProvisioningServiceCertificate());
|
||||
// Tests to validate service certificate
|
||||
TEST_F(WvCdmEnginePreProvTestUat, ProvisioningServiceCertificateValidTest) {
|
||||
ASSERT_EQ(
|
||||
cdm_engine_.ValidateServiceCertificate(
|
||||
g_provisioning_service_certificate),
|
||||
NO_ERROR);
|
||||
};
|
||||
|
||||
// Test that service certificate can be properly installed.
|
||||
TEST_F(WvCdmEnginePreProvTestStaging, ProvisioningServiceCertificateGoodTest) {
|
||||
ASSERT_EQ(cdm_engine_.SetProvisioningServiceCertificate(
|
||||
g_license_service_certificate),
|
||||
NO_ERROR);
|
||||
ASSERT_TRUE(cdm_engine_.HasProvisioningServiceCertificate());
|
||||
TEST_F(WvCdmEnginePreProvTestUat, ProvisioningServiceCertificateInvalidTest) {
|
||||
std::string certificate = g_provisioning_service_certificate;
|
||||
// Add four nulls to the beginning of the cert to invalidate it
|
||||
certificate.insert(0, 4, '\0');
|
||||
|
||||
ASSERT_NE(cdm_engine_.ValidateServiceCertificate(certificate), NO_ERROR);
|
||||
};
|
||||
|
||||
// Test that provisioning works, even if device is already provisioned.
|
||||
|
||||
Reference in New Issue
Block a user