Removed provisioning loop in unittests.
[ Merge of http://go/wvgerrit/98467 ] The issue with intermediate provisioning request failures with the development provisioning server has been resolved in b/139206968. This change removes the provisioning retry loop which was a workaround for the CDM unit tests. Should the issue re-arise, it would be useful to detect it in our unit tests. Bug: 139361531 Test: Linux unit tests Change-Id: Ib44c56c740efea562803d3f8f93ffd62bd95e485
This commit is contained in:
@@ -329,32 +329,18 @@ void WvCdmTestBase::Provision() {
|
|||||||
// for test vs. production server.
|
// for test vs. production server.
|
||||||
provisioning_server_url.assign(config_.provisioning_server());
|
provisioning_server_url.assign(config_.provisioning_server());
|
||||||
|
|
||||||
// TODO(b/139361531): Remove loop once provisioning service is stable.
|
|
||||||
std::string http_message;
|
|
||||||
size_t attempt_num = 0;
|
|
||||||
bool provision_success = false;
|
|
||||||
do {
|
|
||||||
if (attempt_num > 0) {
|
|
||||||
// Sleep between attempts.
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
||||||
}
|
|
||||||
++attempt_num;
|
|
||||||
|
|
||||||
// Make request.
|
// Make request.
|
||||||
UrlRequest url_request(provisioning_server_url);
|
UrlRequest url_request(provisioning_server_url);
|
||||||
if (!url_request.is_connected()) {
|
if (!url_request.is_connected()) {
|
||||||
LOGE("Failed to connect to provisioning server: url = %s",
|
LOGE("Failed to connect to provisioning server: url = %s",
|
||||||
provisioning_server_url.c_str());
|
provisioning_server_url.c_str());
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
url_request.PostCertRequestInQueryString(prov_request);
|
url_request.PostCertRequestInQueryString(prov_request);
|
||||||
|
|
||||||
// Receive and parse response.
|
// Receive and parse response.
|
||||||
if (!url_request.GetResponse(&http_message)) {
|
std::string http_message;
|
||||||
LOGE("Failed to get provisioning response");
|
ASSERT_TRUE(url_request.GetResponse(&http_message))
|
||||||
continue;
|
<< "Failed to get provisioning response";
|
||||||
}
|
|
||||||
|
|
||||||
LOGV("http_message: \n%s\n", http_message.c_str());
|
LOGV("http_message: \n%s\n", http_message.c_str());
|
||||||
|
|
||||||
if (binary_provisioning_) {
|
if (binary_provisioning_) {
|
||||||
@@ -364,50 +350,32 @@ void WvCdmTestBase::Provision() {
|
|||||||
static const std::string kMessageStart = "\"signedResponse\": \"";
|
static const std::string kMessageStart = "\"signedResponse\": \"";
|
||||||
static const std::string kMessageEnd = "\"";
|
static const std::string kMessageEnd = "\"";
|
||||||
std::string protobuf_response;
|
std::string protobuf_response;
|
||||||
if (!ExtractSignedMessage(http_message, kMessageStart, kMessageEnd,
|
const bool extract_ok = ExtractSignedMessage(
|
||||||
&protobuf_response)) {
|
http_message, kMessageStart, kMessageEnd, &protobuf_response);
|
||||||
LOGE(
|
ASSERT_TRUE(extract_ok) << "Failed to extract signed serialized "
|
||||||
"Failed to extract signed serialized response from JSON "
|
"response from JSON response";
|
||||||
"response");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGV("Extracted response message: \n%s\n", protobuf_response.c_str());
|
LOGV("Extracted response message: \n%s\n", protobuf_response.c_str());
|
||||||
|
|
||||||
// base64 decode response to yield binary protobuf
|
ASSERT_FALSE(protobuf_response.empty())
|
||||||
std::vector<uint8_t> response_vec(Base64SafeDecode(protobuf_response));
|
<< "Protobuf response is unexpectedly empty";
|
||||||
if (response_vec.empty() && !protobuf_response.empty()) {
|
|
||||||
LOGE("Failed to decode base64 of response: response = %s",
|
|
||||||
protobuf_response.c_str());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string binary_protobuf_response(response_vec.begin(),
|
// base64 decode response to yield binary protobuf
|
||||||
|
const std::vector<uint8_t> response_vec(
|
||||||
|
Base64SafeDecode(protobuf_response));
|
||||||
|
ASSERT_FALSE(response_vec.empty())
|
||||||
|
<< "Failed to decode base64 of response: response = "
|
||||||
|
<< protobuf_response;
|
||||||
|
|
||||||
|
const std::string binary_protobuf_response(response_vec.begin(),
|
||||||
response_vec.end());
|
response_vec.end());
|
||||||
|
|
||||||
if (cdm_engine.HandleProvisioningResponse(
|
ASSERT_EQ(NO_ERROR, cdm_engine.HandleProvisioningResponse(
|
||||||
binary_protobuf_response, &cert, &wrapped_key) != NO_ERROR) {
|
binary_protobuf_response, &cert, &wrapped_key));
|
||||||
LOGE("Failed to handle provisioning response");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (cdm_engine.HandleProvisioningResponse(http_message, &cert,
|
ASSERT_EQ(NO_ERROR, cdm_engine.HandleProvisioningResponse(
|
||||||
&wrapped_key) != NO_ERROR) {
|
http_message, &cert, &wrapped_key));
|
||||||
LOGE("Failed to handle binary provisioning response");
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
provision_success = true;
|
|
||||||
} while (attempt_num <= kDefaultMaxProvisioningAttempts &&
|
|
||||||
!provision_success);
|
|
||||||
|
|
||||||
if (attempt_num > 1) {
|
|
||||||
LOGW("Provisioning request failed at least once: attempts = %zu",
|
|
||||||
attempt_num);
|
|
||||||
}
|
|
||||||
ASSERT_TRUE(provision_success)
|
|
||||||
<< "Failed to provision: message = " << http_message;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(fredgc): Replace this with a pre-defined DRM certificate. We could do
|
// TODO(fredgc): Replace this with a pre-defined DRM certificate. We could do
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ namespace wvcdm {
|
|||||||
// to configure OEMCrypto to use a test keybox.
|
// to configure OEMCrypto to use a test keybox.
|
||||||
class WvCdmTestBase : public ::testing::Test {
|
class WvCdmTestBase : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
// Default number of provisioning try attempts.
|
|
||||||
constexpr static size_t kDefaultMaxProvisioningAttempts = 10;
|
|
||||||
|
|
||||||
WvCdmTestBase();
|
WvCdmTestBase();
|
||||||
~WvCdmTestBase() override {}
|
~WvCdmTestBase() override {}
|
||||||
void SetUp() override;
|
void SetUp() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user