From 0aaf1df125642d7988534054b626e069cf722dd8 Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Thu, 18 Jun 2020 21:25:21 -0700 Subject: [PATCH] Test CDM sessions prevent multiple usage entries. [ Merge of http://go/wvgerrit/102068 ] CDM sessions should not be able to load multiple usage entries. OEMCrypto already prevents multiple entries from being loaded by the same OEMCrypto session; however, restoring a key typically creates a new OEMCrypto session, which should not be allowed twice within the same CDM session. This test verifies that CDM returns an error if restore key is called multiple times within the same session. Bug: 136143733 Test: Android integration test Change-Id: I594c91250217fd958837328162f909bc931d373f --- .../cdm/test/request_license_test.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libwvdrmengine/cdm/test/request_license_test.cpp b/libwvdrmengine/cdm/test/request_license_test.cpp index e7b03eb3..98089883 100644 --- a/libwvdrmengine/cdm/test/request_license_test.cpp +++ b/libwvdrmengine/cdm/test/request_license_test.cpp @@ -2672,6 +2672,30 @@ TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) { decryptor_->CloseSession(session_id_); } +TEST_F(WvCdmRequestLicenseTest, DisallowMultipleRestoreOfflineKeyTest) { + Unprovision(); + Provision(); + + std::string key_id; + std::string client_auth; + GetOfflineConfiguration(&key_id, &client_auth); + + decryptor_->OpenSession(config_.key_system(), nullptr, kDefaultCdmIdentifier, + nullptr, &session_id_); + GenerateKeyRequest(key_id, kLicenseTypeOffline); + VerifyKeyRequestResponse(config_.license_server(), client_auth); + + CdmKeySetId key_set_id = key_set_id_; + decryptor_->CloseSession(session_id_); + + decryptor_->OpenSession(config_.key_system(), nullptr, kDefaultCdmIdentifier, + nullptr, &session_id_); + EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_->RestoreKey(session_id_, key_set_id)); + // Restoring a key twice should result in a failure. + EXPECT_NE(wvcdm::KEY_ADDED, decryptor_->RestoreKey(session_id_, key_set_id)); + decryptor_->CloseSession(session_id_); +} + TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) { Unprovision(); Provision();