Integration tests for renew on license load

Merged from https://widevine-internal-review.googlesource.com/164468

We need to add integration tests in the form of duration license tests
in order to test that this feature works with licenses from a real
server.

Bug: 253513745
Test: WV unit/integration tests
Change-Id: I926d8309ed24183ae117e3f66fb92fec2d95c310
This commit is contained in:
Rahul Frias
2023-02-22 13:58:23 -08:00
parent 7c5f53f861
commit ca79034a3d

View File

@@ -80,6 +80,8 @@ const RenewalPolicy kLDLRenewal = {"CDM_LimitedDurationLicense_renewal", 0, 0};
const RenewalPolicy kInfiniteRenewal = {"CDM_InfiniteRenewal_renewal", 0, 0};
const RenewalPolicy kLicenseDurationWithRenewal = {
"CDM_LicenseDurationWithRenewal_renewal", 10, 0};
const RenewalPolicy kRenewOnLicenseLoad = {"CDM_RenewOnLicenseLoad_renewal", 0,
0};
const RenewalPolicy kHeartbeatRenewal = {"CDM_Heartbeat_renewal", 10, 30};
// Key ID in all duration tests.
@@ -1549,10 +1551,121 @@ class CdmUseCase_RenewOnLicenseLoad : public RenewalTest {
uint64_t renewal_recovery_;
};
// TODO(b/253513745): Replace this with some real tests.
TEST_P(CdmUseCase_RenewOnLicenseLoad, FakeTest) {
FAIL() << "This test will fail on a v18 server, but "
<< "should be skipped on all existing servers.";
// License loaded within rental duration window and playback continues.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case1S) {
start_of_playback_ = 10;
SleepUntil(start_of_playback_);
LoadLicense();
SleepUntilRenewalNeeded();
const uint64_t start = 15; // time of first decrypt
const uint64_t load_renewal = 20;
const uint64_t stop = 45;
RenewAndContinue(start, load_renewal, stop, kRenewOnLicenseLoad);
}
// License loaded within rental duration window and playback continues.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case1M) {
start_of_playback_ = 10;
SleepUntil(start_of_playback_);
LoadLicense();
SleepUntilRenewalNeeded();
const uint64_t start = 20; // time of first decrypt
const uint64_t load_renewal = 20;
const uint64_t stop = 45; // end of decrypt
RenewAndContinue(start, load_renewal, stop, kRenewOnLicenseLoad);
}
// License loaded within rental duration window and playback continues.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case1L) {
start_of_playback_ = 10;
SleepUntil(start_of_playback_);
LoadLicense();
SleepUntilRenewalNeeded();
RequestRenewal(kRenewOnLicenseLoad);
const uint64_t load_renewal = 20;
const uint64_t start = 25; // time of first decrypt
const uint64_t stop = 45; // end of decrypt
LoadRenewal(load_renewal, kRenewOnLicenseLoad);
AllowPlayback(start, stop);
}
// License loaded after rental duration window and playback should fail.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case2) {
start_of_playback_ = EndOfRentalWindow() + 1;
ForbidPlayback(start_of_playback_);
}
// License loaded within rental duration window but renewal not received.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case3S) {
start_of_playback_ = 10;
SleepUntil(start_of_playback_);
LoadLicense();
const uint64_t start = 15; // time of first decrypt
// Allow playback within the initial renewal window.
const uint64_t cutoff =
start_of_playback_ + renewal_delay_ + renewal_recovery_;
TerminatePlayback(start, cutoff);
}
// License loaded within rental duration window but renewal not received.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case3M) {
start_of_playback_ = 10;
SleepUntil(start_of_playback_);
LoadLicense();
const uint64_t start = 25; // time of first decrypt
// Allow playback within the initial renewal window.
const uint64_t cutoff =
start_of_playback_ + renewal_delay_ + renewal_recovery_;
TerminatePlayback(start, cutoff);
}
// License loaded within rental duration window but renewal not received.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case3L) {
start_of_playback_ = 10;
SleepUntil(start_of_playback_);
LoadLicense();
const uint64_t start = 35; // time of first decrypt
SleepUntil(start);
// No playback at all.
FailDecrypt();
}
// Playback is started within the rental duration window and the renewal is
// received, but playback exceeds the playback duration.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case4) {
start_of_playback_ = 10;
SleepUntil(start_of_playback_);
LoadLicense();
SleepUntilRenewalNeeded();
const uint64_t start = 20; // time of first decrypt
const uint64_t load_renewal = 20;
const uint64_t stop = 45; // end of decrypt
const uint64_t cutoff = EndOfPlaybackWindow();
RenewAndContinue(start, load_renewal, stop, kRenewOnLicenseLoad);
TerminatePlayback(stop, cutoff);
}
// Playback is able to be restarted.
TEST_P(CdmUseCase_RenewOnLicenseLoad, Case5) {
start_of_playback_ = 10;
const uint64_t load_renewal = 20;
SleepUntil(start_of_playback_);
LoadLicense();
SleepUntilRenewalNeeded();
RequestRenewal(kRenewOnLicenseLoad);
const uint64_t start = 20;
const uint64_t end = 35;
RenewAndContinue(start, load_renewal, end, kRenewOnLicenseLoad);
UnloadLicense();
// Simulate reloading the license, and then reloading the renewal, and then
// restarting playback. That is allowed, and playback shall be terminated at
// the end of the original playback window.
const uint64_t reload_time = 45;
ReloadAndAllowPlayback(reload_time, EndOfPlaybackWindow(),
kRenewOnLicenseLoad);
// But not beyond playback window.
SleepUntil(EndOfPlaybackWindow() + 3 * kFudge);
FailDecrypt();
}
// Heartbeat Playback Window License. (See above for notes on Use Case tests).