Combine provisioning code for tests and improve logging

Merge from Widevine repo of http://go/wvgerrit/169018

This CL adds a provisioning holder that attempts to
provision and logs the request and response for
failures. The server team can replay the request to debug
problems on their end.

Bug: 276464340
Test: ran cast and ota tests
Change-Id: I6eed117e504ae3287f2ba16c3c507cfdc7456f8d
This commit is contained in:
Fred Gylys-Colwell
2023-05-04 21:22:53 -07:00
committed by Kyle Zhang
parent 65d52908af
commit 836b1a30a6
6 changed files with 254 additions and 245 deletions

View File

@@ -0,0 +1,46 @@
// Copyright 2023 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
#ifndef WVCDM_CORE_TEST_PROVISIONING_HOLDER_H_
#define WVCDM_CORE_TEST_PROVISIONING_HOLDER_H_
#include "test_base.h"
#include <string>
namespace wvcdm {
class ProvisioningHolder {
public:
ProvisioningHolder(TestCdmEngine* cdm_engine,
const std::string& provisioning_server_url,
const std::string& provisioning_service_certificate)
: cdm_engine_(cdm_engine),
provisioning_server_url_(provisioning_server_url),
provisioning_service_certificate_(provisioning_service_certificate) {}
void Provision(CdmCertificateType cert_type, bool binary_provisioning);
protected:
TestCdmEngine* cdm_engine_;
std::string provisioning_server_url_;
std::string provisioning_service_certificate_;
std::string certificate_;
std::string wrapped_key_;
// Locate the portion of the server's provisioning response message that is
// between the strings jason_start_substr and json_end_substr. Returns the
// string through *result. If the start substring match fails, assume the
// 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);
// 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);
};
} // namespace wvcdm
#endif // WVCDM_CORE_TEST_PROVISIONING_HOLDER_H_