From ca20d3255ef1764463e5598c93ca535d2f6887dc Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Tue, 30 Apr 2024 14:39:22 -0700 Subject: [PATCH 1/3] Fix LicenseRenewalSpecifiedServer for SDK servers The test only needs to verify that the license has a renewal server url. It does not need to fetch a renewal from that url. bug: 338103523 Merged from https://widevine-internal-review.googlesource.com/197955 Change-Id: I1513f8692089c3f51a53ffd6ecb62348702b8fb8 --- .../cdm/core/test/cdm_engine_test.cpp | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/libwvdrmengine/cdm/core/test/cdm_engine_test.cpp b/libwvdrmengine/cdm/core/test/cdm_engine_test.cpp index 8f266bed..0925ff1f 100644 --- a/libwvdrmengine/cdm/core/test/cdm_engine_test.cpp +++ b/libwvdrmengine/cdm/core/test/cdm_engine_test.cpp @@ -191,7 +191,6 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest { EXPECT_EQ(KEY_MESSAGE, result); key_msg_ = request.message; - server_url_ = request.url; } std::string GetKeyRequestResponse(const std::string& server_url, @@ -295,8 +294,6 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest { << "Expected request type " << key_request_type << " was not found. " << "metrics: " << wvutil::b2a_hex(serialized_metrics); } - - std::string server_url_; }; // Tests to validate service certificate @@ -403,22 +400,15 @@ TEST_F(WvCdmEngineTest, LoadKey) { // command line. TEST_F(WvCdmEngineTest, LicenseRenewalSpecifiedServer) { EnsureProvisioned(); - GenerateKeyRequest(binary_key_id(), kCencMimeType); - VerifyNewKeyResponse(config_.license_server(), config_.client_auth()); - - GenerateRenewalRequest(); - if (!server_url_.empty()) { - // If the license server put a URL for the renewal in the license, we should - // be able to verify the renewal against that server. - VerifyRenewalKeyResponse(server_url_, config_.client_auth()); - } else { - // If the license server did not give us a URL, we won't verify it. - LOGE("License server did not set renewal URL. license_url=%s.", - config_.license_server().c_str()); - // This is OK when you are using a local, debug, license server, but it - // should NOT happen if using UAT or UAT nightly. - EXPECT_EQ(std::string::npos, config_.license_server().find("proxy.uat")); - } + LicenseHolder holder("CDM_SpecifyRenewalUrl", &cdm_engine_, config_); + ASSERT_NO_FATAL_FAILURE(holder.OpenSession()); + ASSERT_NO_FATAL_FAILURE(holder.FetchLicense()); + ASSERT_NO_FATAL_FAILURE(holder.LoadLicense()); + CdmKeyRequest request; + const CdmResponseType result = + cdm_engine_.GenerateRenewalRequest(holder.session_id(), &request); + ASSERT_EQ(KEY_MESSAGE, result); + EXPECT_EQ(request.url, "url_as_specified_in_integration_console"); } // This test generates a renewal and then requests it from the server specified From 0971a805f0533cf11e1568ed1592b2bc2e62efa8 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Fri, 2 Feb 2024 14:08:06 -0800 Subject: [PATCH 2/3] Skip RenewOnLicenseLoad test when not viable The feature RenewOnLicenseLoad is not expected to work for an offline license when the device has no usage table. Bug: 310498829 Change-Id: I601c332ed6cd17f9682082ea6acda7e67492b381 --- libwvdrmengine/cdm/core/test/duration_use_case_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libwvdrmengine/cdm/core/test/duration_use_case_test.cpp b/libwvdrmengine/cdm/core/test/duration_use_case_test.cpp index 30ca8825..69beeae1 100644 --- a/libwvdrmengine/cdm/core/test/duration_use_case_test.cpp +++ b/libwvdrmengine/cdm/core/test/duration_use_case_test.cpp @@ -1576,6 +1576,9 @@ class CdmUseCase_RenewOnLicenseLoad : public RenewalTest { GTEST_SKIP() << "Renew on License Load supported on v18+ servers and " "devices only."; } + if (license_holder_.can_persist() && !wvoec::global_features.usage_table) { + GTEST_SKIP() << "Renew on License Load requires a usage table for offline licenses."; + } } uint64_t renewal_cutoff_; From 38dd9897f34f61c7cb1e5e1d36188e372f6c6239 Mon Sep 17 00:00:00 2001 From: Vicky Min Date: Thu, 2 May 2024 23:45:30 +0000 Subject: [PATCH 3/3] Fix clear lead integration tests The original clear lead integration tests weren't following the flow of the original bug because there was only one sample, so DecryptMultipleSamples wasn't being called in the same way. This should fix this. Bug: 320785945 Change-Id: Ia70e3fd78381d8d34261b95931fdb303f77f73fd (cherry picked from commit 4141e271d44c32da88dc0f02a0173fae0b45ead9) --- libwvdrmengine/cdm/core/test/license_holder.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libwvdrmengine/cdm/core/test/license_holder.cpp b/libwvdrmengine/cdm/core/test/license_holder.cpp index ec10860f..b2e3b6f0 100644 --- a/libwvdrmengine/cdm/core/test/license_holder.cpp +++ b/libwvdrmengine/cdm/core/test/license_holder.cpp @@ -121,10 +121,13 @@ CdmResponseType LicenseHolder::DecryptClearLead(const std::string& key_id) { const std::vector iv(KEY_IV_SIZE, 0); CdmDecryptionParametersV16 params(key_id); params.is_secure = false; - CdmDecryptionSample sample(input.data(), output.data(), 0, input.size(), iv); + CdmDecryptionSample sample1(input.data(), output.data(), 0, input.size(), iv); + CdmDecryptionSample sample2(input.data(), output.data(), 0, input.size(), iv); CdmDecryptionSubsample subsample(input.size(), 0); - sample.subsamples.push_back(subsample); - params.samples.push_back(sample); + sample1.subsamples.push_back(subsample); + sample2.subsamples.push_back(subsample); + params.samples.push_back(sample1); + params.samples.push_back(sample2); return cdm_engine_->DecryptV16(session_id_, params); }