Refactored ProvisioningHolder to separate operations.

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

An upcoming provisioning test requires the ability to perform
generate, fetch and load operations separately (similar to the
current behavior of LicenseHolder).

This CL separates the 3 operations into different methods and
documents the pre/post conditions of each.  The original API
is maintained for backwards compatibility.

VIC-specific: Excludes Golden-data refactoring and merges main
change (216510) and typo fix (216570).

Bug: 391469176
Test: run_x86_64_tests
Change-Id: Iec83dfce9d235eedf04ed32d98f7700de4bade12
This commit is contained in:
Alex Dale
2025-04-18 12:29:00 -07:00
parent 3d5bdaeb77
commit ca7be366df
2 changed files with 124 additions and 62 deletions

View File

@@ -19,20 +19,58 @@ class ProvisioningHolder {
provisioning_server_url_(config.provisioning_server()),
provisioning_service_certificate_(
config.provisioning_service_certificate()) {}
// Generates requests, fetches response, and loads response.
void Provision(CdmCertificateType cert_type, bool binary_provisioning);
void Provision(bool binary_provisioning) {
Provision(kCertificateWidevine, binary_provisioning);
}
std::string response() const { return response_; }
std::string certificate() const { return certificate_; }
std::string wrapped_key() const { return wrapped_key_; }
// Generates a provisioning request from the |cdm_engine_|.
// If successful, the request the stored in |request_|.
// The result of |request_| should always be the URL-Safe-Base64
// encoded value of the request.
void GenerateRequest(CdmCertificateType cert_type, bool binary_provisioning);
void GenerateRequest(bool binary_provisioning) {
GenerateRequest(kCertificateWidevine, binary_provisioning);
}
// Fetch the provisioning response from the server.
// Uses |request_| as the source of the request, and stores
// JSON message of the response to |response_|.
void FetchResponse();
void LoadResponse(bool binary_provisioning);
const std::string& request() const { return request_; }
// Sets the request to be used on next call to FetchResponse().
// The provided |request| must be a URL-Safe-Base64 encoding
// of the provisioning request.
void set_request(const std::string& request) { request_ = request; }
const std::string& response() const { return response_; }
const std::string& certificate() const { return certificate_; }
const std::string& wrapped_key() const { return wrapped_key_; }
void ClearProvisioningData() {
cert_type_ = kCertificateWidevine;
request_.clear();
response_.clear();
certificate_.clear();
wrapped_key_.clear();
}
protected:
TestCdmEngine* cdm_engine_;
// Config variables.
const ConfigTestEnv& config_;
std::string provisioning_server_url_;
std::string provisioning_service_certificate_;
std::string response_;
// Request variables.
CdmCertificateType cert_type_;
std::string request_; // URL-Safe-Base64 encoding of request.
// Response variables.
std::string response_; // JSON message containing response.
// Post-provisioning variables.
std::string certificate_;
std::string wrapped_key_;
@@ -42,11 +80,12 @@ class ProvisioningHolder {
// entire string represents a serialized protobuf mesaage and return true with
// the entire string. If the end_substring match fails, return false with an
// empty *result.
bool ExtractSignedMessage(const std::string& response, std::string* result);
static bool ExtractSignedMessage(const std::string& response,
std::string* result);
// Dump request and response information for use in a debug or failure log.
std::string DumpProvAttempt(const std::string& request,
const std::string& response,
CdmCertificateType cert_type);
CdmCertificateType cert_type) const;
};
} // namespace wvcdm