Commit b04d04f1 authored by Leo Lai's avatar Leo Lai Committed by Commit Bot

Revert "remove cryptohome client from EnrollmentCertificateUploaderImpl"

This reverts commit 6ab3c894.

Reason for revert: the project dependency, platform-side proxy, is
currently only enabled with device policy and not universally available
until M88.

Original change's description:
> remove cryptohome client from EnrollmentCertificateUploaderImpl
>
> The new attestation flow doesn't rely on cryptohome client anymore.
>
> as for testing, EnrollmentCertificateUploaderTest.* are passed.
>
> Change-Id: Id289cdc1b2e2d4a27179f048c0d6e3d4d968cd88
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2303743
> Commit-Queue: Leo Lai <cylai@google.com>
> Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#789865}

TBR=emaxx@chromium.org,cylai@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ief64848511e08db9b9b6385c03d15f227a6cd2d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425685Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Reviewed-by: default avatarAndreea-Elena Costinas <acostinas@google.com>
Commit-Queue: Leo Lai <cylai@google.com>
Cr-Commit-Position: refs/heads/master@{#810119}
parent a47abfc8
......@@ -12,6 +12,9 @@
#include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
#include "chromeos/attestation/attestation_flow.h"
#include "chromeos/attestation/attestation_flow_integrated.h"
#include "chromeos/cryptohome/async_method_caller.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/dbus_method_call_status.h"
#include "components/account_id/account_id.h"
#include "components/policy/core/common/cloud/cloud_policy_client.h"
......@@ -35,8 +38,8 @@ void DBusPrivacyCACallback(
on_success.Run(data);
return;
}
LOG(ERROR) << "Attestation DBus method failed with status: " << status << ": "
<< from_here.ToString();
LOG(ERROR) << "Cryptohome DBus method or server called failed with status: "
<< status << ": " << from_here.ToString();
if (!on_failure.is_null())
on_failure.Run(status);
}
......@@ -49,12 +52,15 @@ namespace attestation {
EnrollmentCertificateUploaderImpl::EnrollmentCertificateUploaderImpl(
policy::CloudPolicyClient* policy_client)
: EnrollmentCertificateUploaderImpl(policy_client,
nullptr, /* cryptohome_client */
nullptr /* attestation_flow */) {}
EnrollmentCertificateUploaderImpl::EnrollmentCertificateUploaderImpl(
policy::CloudPolicyClient* policy_client,
CryptohomeClient* cryptohome_client,
AttestationFlow* attestation_flow)
: policy_client_(policy_client),
cryptohome_client_(cryptohome_client),
attestation_flow_(attestation_flow),
retry_limit_(kRetryLimit),
retry_delay_(kRetryDelay) {
......@@ -85,6 +91,9 @@ void EnrollmentCertificateUploaderImpl::Start() {
return;
}
if (!cryptohome_client_)
cryptohome_client_ = CryptohomeClient::Get();
if (!attestation_flow_) {
default_attestation_flow_ = std::make_unique<AttestationFlowIntegrated>();
attestation_flow_ = default_attestation_flow_.get();
......
......@@ -22,6 +22,8 @@ class CloudPolicyClient;
namespace chromeos {
class CryptohomeClient;
namespace attestation {
class AttestationFlow;
......@@ -32,9 +34,10 @@ class EnrollmentCertificateUploaderImpl : public EnrollmentCertificateUploader {
explicit EnrollmentCertificateUploaderImpl(
policy::CloudPolicyClient* policy_client);
// A constructor which allows custom AttestationFlow implementation. Useful
// for testing.
// A constructor which allows custom CryptohomeClient and AttestationFlow
// implementations. Useful for testing.
EnrollmentCertificateUploaderImpl(policy::CloudPolicyClient* policy_client,
CryptohomeClient* cryptohome_client,
AttestationFlow* attestation_flow);
~EnrollmentCertificateUploaderImpl() override;
......@@ -75,6 +78,7 @@ class EnrollmentCertificateUploaderImpl : public EnrollmentCertificateUploader {
void Reschedule();
policy::CloudPolicyClient* policy_client_;
CryptohomeClient* cryptohome_client_;
AttestationFlow* attestation_flow_;
std::unique_ptr<AttestationFlow> default_attestation_flow_;
// Callbacks to run when a certificate is uploaded (or we fail to).
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/attestation/enrollment_certificate_uploader_impl.h"
#include <stdint.h>
#include <string>
......@@ -16,9 +14,11 @@
#include "base/test/bind_test_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/attestation/attestation_key_payload.pb.h"
#include "chrome/browser/chromeos/attestation/enrollment_certificate_uploader_impl.h"
#include "chrome/browser/chromeos/attestation/fake_certificate.h"
#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chromeos/attestation/mock_attestation_flow.h"
#include "chromeos/dbus/cryptohome/fake_cryptohome_client.h"
#include "chromeos/settings/cros_settings_names.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "content/public/test/browser_task_environment.h"
......@@ -86,8 +86,8 @@ class EnrollmentCertificateUploaderTest : public ::testing::Test {
}
void Run(bool expected_status) {
EnrollmentCertificateUploaderImpl uploader(&policy_client_,
&attestation_flow_);
EnrollmentCertificateUploaderImpl uploader(
&policy_client_, &cryptohome_client_, &attestation_flow_);
uploader.set_retry_limit(3);
uploader.set_retry_delay(base::TimeDelta());
......@@ -101,6 +101,7 @@ class EnrollmentCertificateUploaderTest : public ::testing::Test {
content::BrowserTaskEnvironment task_environment_;
ScopedCrosSettingsTestHelper settings_helper_;
FakeCryptohomeClient cryptohome_client_;
StrictMock<MockAttestationFlow> attestation_flow_;
StrictMock<policy::MockCloudPolicyClient> policy_client_;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment