Commit 6ab3c894 authored by Leo Lai's avatar Leo Lai Committed by Commit Bot

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: default avatarMaksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789865}
parent 50cb1c9e
......@@ -12,9 +12,6 @@
#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"
......@@ -38,8 +35,8 @@ void DBusPrivacyCACallback(
on_success.Run(data);
return;
}
LOG(ERROR) << "Cryptohome DBus method or server called failed with status: "
<< status << ": " << from_here.ToString();
LOG(ERROR) << "Attestation DBus method failed with status: " << status << ": "
<< from_here.ToString();
if (!on_failure.is_null())
on_failure.Run(status);
}
......@@ -52,15 +49,12 @@ 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) {
......@@ -91,9 +85,6 @@ 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,8 +22,6 @@ class CloudPolicyClient;
namespace chromeos {
class CryptohomeClient;
namespace attestation {
class AttestationFlow;
......@@ -34,10 +32,9 @@ class EnrollmentCertificateUploaderImpl : public EnrollmentCertificateUploader {
explicit EnrollmentCertificateUploaderImpl(
policy::CloudPolicyClient* policy_client);
// A constructor which allows custom CryptohomeClient and AttestationFlow
// implementations. Useful for testing.
// A constructor which allows custom AttestationFlow implementation. Useful
// for testing.
EnrollmentCertificateUploaderImpl(policy::CloudPolicyClient* policy_client,
CryptohomeClient* cryptohome_client,
AttestationFlow* attestation_flow);
~EnrollmentCertificateUploaderImpl() override;
......@@ -78,7 +75,6 @@ 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,6 +2,8 @@
// 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>
......@@ -14,11 +16,9 @@
#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_, &cryptohome_client_, &attestation_flow_);
EnrollmentCertificateUploaderImpl uploader(&policy_client_,
&attestation_flow_);
uploader.set_retry_limit(3);
uploader.set_retry_delay(base::TimeDelta());
......@@ -101,7 +101,6 @@ 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