Commit 74eadd7c authored by Leo Lai's avatar Leo Lai Committed by Commit Bot

fake attestation flow

The introduced new class is meant to replace the current fake objects
used in various browser tests.

BUG=b:158955123

Change-Id: I743bd605321e7f384eb22a9ecac4fb40ae93e980
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2297062
Commit-Queue: Leo Lai <cylai@google.com>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789383}
parent fc663b9e
......@@ -35,10 +35,13 @@ source_set("test_support") {
deps = [
"//base/test:test_support",
"//chromeos/dbus/attestation:attestation_proto",
"//chromeos/dbus/constants:constants",
"//components/account_id",
"//testing/gmock",
]
sources = [
"fake_attestation_flow.cc",
"fake_attestation_flow.h",
"mock_attestation_flow.cc",
"mock_attestation_flow.h",
]
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/attestation/fake_attestation_flow.h"
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chromeos/dbus/constants/attestation_constants.h"
#include "components/account_id/account_id.h"
namespace chromeos {
namespace attestation {
namespace {
constexpr char kFakeCert[] = "cert";
} // namespace
// This constructor passes |nullptr|s to the base class
// |AttestationFlow| because we don't use cryptohome client and server
// proxy in |AttestationFlowIntegrated|.
//
// TOOD(b/158955123): Remove this transitional state along with the removal of
// |AttestationFlow|.
FakeAttestationFlow::FakeAttestationFlow()
: AttestationFlow(nullptr, nullptr, nullptr) {}
FakeAttestationFlow::~FakeAttestationFlow() = default;
void FakeAttestationFlow::GetCertificate(
AttestationCertificateProfile /*certificate_profile*/,
const AccountId& /*account_id*/,
const std::string& /*request_origin*/,
bool /*force_new_key*/,
const std::string& /*key_name*/,
CertificateCallback callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(callback),
AttestationStatus::ATTESTATION_SUCCESS, kFakeCert));
}
} // namespace attestation
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_ATTESTATION_FAKE_ATTESTATION_FLOW_H_
#define CHROMEOS_ATTESTATION_FAKE_ATTESTATION_FLOW_H_
#include <string>
#include "chromeos/attestation/attestation_flow.h"
class AccountId;
namespace chromeos {
namespace attestation {
// This fake class always returns a fake certificate.
class FakeAttestationFlow : public AttestationFlow {
public:
FakeAttestationFlow();
~FakeAttestationFlow() override;
void GetCertificate(AttestationCertificateProfile certificate_profile,
const AccountId& account_id,
const std::string& request_origin,
bool force_new_key,
const std::string& key_name,
CertificateCallback callback) override;
};
} // namespace attestation
} // namespace chromeos
#endif // CHROMEOS_ATTESTATION_FAKE_ATTESTATION_FLOW_H_
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