Update tests for license release
Merge from Widevine repo of http://go/wvgerrit/95403 This updates the test code CreateDefaultResponse to make sure that license releases do not have a core message, and that the key control block is correctly set for renewals. Also, the unit test OEMCryptoUsageTableTest.TimingTest is changed to only a license release when the license is inactive. If the license is still active, then the license is loaded before generating a usage report. Test: Ran full unit tests Bug: 151092673 Change-Id: I7c01fd17f9b66e88ab3c57aa0f3d40740f13507c
This commit is contained in:
@@ -844,7 +844,7 @@ void RenewalRoundTrip::FillAndVerifyCoreRequest(
|
||||
}
|
||||
|
||||
void RenewalRoundTrip::CreateDefaultResponse() {
|
||||
if (license_messages_->api_version() < kCoreMessagesAPI) {
|
||||
if (license_messages_->api_version() < kCoreMessagesAPI || is_release_) {
|
||||
uint32_t control = 0;
|
||||
uint32_t nonce = 0;
|
||||
// If this is a v15 device, and a v15 license, and the license used a nonce,
|
||||
@@ -859,12 +859,9 @@ void RenewalRoundTrip::CreateDefaultResponse() {
|
||||
constexpr size_t index = 0;
|
||||
response_data_.keys[index].key_id_length = 0;
|
||||
response_data_.keys[index].key_id[0] = '\0';
|
||||
std::string kcVersion =
|
||||
"kc" + std::to_string(core_request_.api_major_version);
|
||||
if (global_features.api_version < kCoreMessagesAPI) {
|
||||
// For v15 or earlier devices, we use the api of the device.
|
||||
kcVersion = "kc" + std::to_string(global_features.api_version);
|
||||
}
|
||||
const uint32_t renewal_api =
|
||||
std::max<uint32_t>(core_request_.api_major_version, 15u);
|
||||
std::string kcVersion = "kc" + std::to_string(renewal_api);
|
||||
memcpy(response_data_.keys[index].control.verification, kcVersion.c_str(),
|
||||
4);
|
||||
const uint32_t duration = static_cast<uint32_t>(
|
||||
|
||||
@@ -1694,15 +1694,15 @@ class OEMCryptoSessionTestDecryptWithHDCP : public OEMCryptoSessionTests,
|
||||
// reported if OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION is expected.
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.TestDecryptCTR(true, OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION))
|
||||
<< "Failed when current HDCP = " << HDCPCapabilityAsString(current)
|
||||
<< ", maximum HDCP = " << HDCPCapabilityAsString(maximum)
|
||||
<< ", license HDCP = " << HDCPCapabilityAsString(version);
|
||||
<< "Failed when current HDCP = " << HDCPCapabilityAsString(current)
|
||||
<< ", maximum HDCP = " << HDCPCapabilityAsString(maximum)
|
||||
<< ", license HDCP = " << HDCPCapabilityAsString(version);
|
||||
} else {
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.TestDecryptCTR(true, OEMCrypto_ERROR_INSUFFICIENT_HDCP))
|
||||
<< "Failed when current HDCP = " << HDCPCapabilityAsString(current)
|
||||
<< ", maximum HDCP = " << HDCPCapabilityAsString(maximum)
|
||||
<< ", license HDCP = " << HDCPCapabilityAsString(version);
|
||||
<< "Failed when current HDCP = " << HDCPCapabilityAsString(current)
|
||||
<< ", maximum HDCP = " << HDCPCapabilityAsString(maximum)
|
||||
<< ", license HDCP = " << HDCPCapabilityAsString(version);
|
||||
}
|
||||
} else {
|
||||
ASSERT_NO_FATAL_FAILURE(s.TestDecryptCTR(true, OEMCrypto_SUCCESS))
|
||||
@@ -2804,7 +2804,8 @@ TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRSAKey) {
|
||||
|
||||
// Test that RewrapDeviceRSAKey verifies the RSA key is valid.
|
||||
// TODO(b/144186970): This test should also run on Prov 3.0 devices.
|
||||
TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRSAKeyKeyboxTestAPI16) {
|
||||
TEST_F(OEMCryptoLoadsCertificate,
|
||||
CertificateProvisionBadRSAKeyKeyboxTestAPI16) {
|
||||
Session s;
|
||||
ProvisioningRoundTrip provisioning_messages(&s, encoded_rsa_key_);
|
||||
provisioning_messages.PrepareSession(keybox_);
|
||||
@@ -6065,17 +6066,10 @@ TEST_P(OEMCryptoUsageTableTest, TimingTest) {
|
||||
ASSERT_NO_FATAL_FAILURE(s2.close());
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(s1.open());
|
||||
ASSERT_NO_FATAL_FAILURE(s2.open());
|
||||
ASSERT_NO_FATAL_FAILURE(s3.open());
|
||||
ASSERT_NO_FATAL_FAILURE(entry1.ReloadUsageEntry());
|
||||
ASSERT_NO_FATAL_FAILURE(entry2.ReloadUsageEntry());
|
||||
ASSERT_NO_FATAL_FAILURE(entry3.ReloadUsageEntry());
|
||||
// Sending a release from an offline license that has been deactivate will
|
||||
// only work if the license server can handle v16 licenses. This is a rare
|
||||
// condition, so it is OK to break it during the transition months.
|
||||
entry1.license_messages().set_api_version(global_features.api_version);
|
||||
entry2.license_messages().set_api_version(global_features.api_version);
|
||||
entry3.license_messages().set_api_version(global_features.api_version);
|
||||
ASSERT_NO_FATAL_FAILURE(entry2.OpenAndReload(this));
|
||||
ASSERT_NO_FATAL_FAILURE(entry3.OpenAndReload(this));
|
||||
|
||||
wvcdm::TestSleep::Sleep(kLongSleep);
|
||||
ASSERT_NO_FATAL_FAILURE(s1.UpdateUsageEntry(&encrypted_usage_header_));
|
||||
ASSERT_NO_FATAL_FAILURE(entry1.GenerateVerifyReport(kInactiveUsed));
|
||||
|
||||
Reference in New Issue
Block a user