Set renewal server on command line for tests

[ Merge of http://go/wvgerrit/110903 ]

This CL adds the ability to set the renewal server on the command
line, and adds some comments to the build scripts' README file to
explain how to test a server rollout.

Bug: 173031207
Test: WV unit/integration tests
Change-Id: Ibe71e77469c94601627fb85a1ad4654553d3eb1a

Change-Id: I7e9bfc873c78e26c0cece113dc8a3d08cd9163db
This commit is contained in:
Rahul Frias
2021-03-07 00:16:20 -08:00
parent 24e4c33262
commit 50efa73e34
4 changed files with 41 additions and 21 deletions

View File

@@ -225,7 +225,9 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
int status_code = url_request.GetStatusCode(response);
if (expect_success)
EXPECT_EQ(kHttpOk, status_code) << "Error response: " << response;
EXPECT_EQ(kHttpOk, status_code)
<< "Error response from " << server_url << ":\n"
<< response;
if (status_code != kHttpOk) {
return "";
@@ -419,14 +421,14 @@ TEST_F(WvCdmEngineTest, LicenseRenewalSpecifiedServer) {
}
}
// This test generates a renewal and then requests the renewal from the same
// server from which we requested the original license.
TEST_F(WvCdmEngineTest, LicenseRenewalSameServer) {
// This test generates a renewal and then requests it from the server specified
// by the current test configuration.
TEST_F(WvCdmEngineTest, LicenseRenewal) {
GenerateKeyRequest(binary_key_id(), kCencMimeType);
VerifyNewKeyResponse(config_.license_server(), config_.client_auth());
GenerateRenewalRequest();
VerifyRenewalKeyResponse(config_.license_server(), config_.client_auth());
VerifyRenewalKeyResponse(config_.renewal_server(), config_.client_auth());
}
TEST_F(WvCdmEngineTest, ParseDecryptHashStringTest) {

View File

@@ -309,25 +309,13 @@ ConfigTestEnv::ConfigTestEnv(ServerConfigurationId server_id, bool streaming,
}
}
ConfigTestEnv& ConfigTestEnv::operator=(const ConfigTestEnv& other) {
this->server_id_ = other.server_id_;
this->client_auth_ = other.client_auth_;
this->key_id_ = other.key_id_;
this->key_system_ = other.key_system_;
this->license_server_ = other.license_server_;
this->provisioning_server_ = other.provisioning_server_;
this->license_service_certificate_ = other.license_service_certificate_;
this->provisioning_service_certificate_ =
other.provisioning_service_certificate_;
return *this;
}
void ConfigTestEnv::Init(ServerConfigurationId server_id) {
this->server_id_ = server_id;
client_auth_ = license_servers[server_id].client_tag;
key_id_ = license_servers[server_id].key_id;
key_system_ = kWidevineKeySystem;
license_server_ = license_servers[server_id].license_server_url;
renewal_server_.clear();
provisioning_server_ = license_servers[server_id].provisioning_server_url;
license_service_certificate_ =
a2bs_hex(license_servers[server_id].license_service_certificate);

View File

@@ -61,9 +61,12 @@ class ConfigTestEnv {
ConfigTestEnv(ServerConfigurationId server_id, bool streaming);
ConfigTestEnv(ServerConfigurationId server_id, bool streaming, bool renew,
bool release);
// Allow copy and assign. Performance is not an issue in test initialization.
ConfigTestEnv(const ConfigTestEnv &other) { *this = other; };
ConfigTestEnv& operator=(const ConfigTestEnv &other);
// Allow copy, assign, and move. Performance is not an issue in test
// initialization.
ConfigTestEnv(const ConfigTestEnv&) = default;
ConfigTestEnv(ConfigTestEnv&&) = default;
ConfigTestEnv& operator=(const ConfigTestEnv&) = default;
ConfigTestEnv& operator=(ConfigTestEnv&&) = default;
~ConfigTestEnv() {};
@@ -72,6 +75,12 @@ class ConfigTestEnv {
const KeyId& key_id() const { return key_id_; }
const CdmKeySystem& key_system() const { return key_system_; }
const std::string& license_server() const { return license_server_; }
const std::string& renewal_server() const {
if (!renewal_server_.empty())
return renewal_server_;
else
return license_server_;
}
const std::string& provisioning_server() const {
return provisioning_server_;
}
@@ -93,6 +102,9 @@ class ConfigTestEnv {
void set_license_server(const std::string& license_server) {
license_server_.assign(license_server);
}
void set_renewal_server(const std::string& renewal_server) {
renewal_server_.assign(renewal_server);
}
void set_license_service_certificate(
const std::string& license_service_certificate) {
license_service_certificate_.assign(license_service_certificate);
@@ -113,6 +125,7 @@ class ConfigTestEnv {
KeyId key_id_;
CdmKeySystem key_system_;
std::string license_server_;
std::string renewal_server_;
std::string provisioning_server_;
std::string license_service_certificate_;
std::string provisioning_service_certificate_;

View File

@@ -93,6 +93,19 @@ void show_menu(const char* prog_name, const std::string& extra_help_text) {
<< " in the url" << std::endl
<< std::endl;
std::cout << " --renewal_server_url=<url>" << std::endl;
std::cout << " configure the renewal server url, please include http[s] "
"in the url"
<< std::endl
<< " If not set, this defaults to be the same url used by the "
"license server."
<< std::endl
<< " Some tests, such as LicenseRenewalSpecifiedServer, will "
"ignore this setting. "
<< std::endl
<< " See comments in the code for an explanation." << std::endl
<< std::endl;
std::cout << " --provisioning_server_url=<url>" << std::endl;
std::cout
<< " configure the provisioning server url, please include http[s]"
@@ -457,6 +470,8 @@ bool WvCdmTestBase::Initialize(int argc, const char* const argv[],
default_config_.set_provisioning_service_certificate(certificate);
} else if (arg_prefix == "--license_server_url") {
default_config_.set_license_server(arg_value);
} else if (arg_prefix == "--renewal_server_url") {
default_config_.set_renewal_server(arg_value);
} else if (arg_prefix == "--provisioning_server_url") {
default_config_.set_provisioning_server(arg_value);
} else {
@@ -480,6 +495,8 @@ bool WvCdmTestBase::Initialize(int argc, const char* const argv[],
<< default_config_.provisioning_server() << std::endl;
std::cout << "Default License Server: " << default_config_.license_server()
<< std::endl;
std::cout << "Default Renewal Server: " << default_config_.renewal_server()
<< std::endl;
std::cout << "Default KeyID: " << default_config_.key_id() << std::endl
<< std::endl;