summaryrefslogtreecommitdiffstats
path: root/chromeos/attestation/mock_attestation_flow.cc
blob: 72be8285543a4fa9e1e52b65df8d2e268469e5c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2012 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/mock_attestation_flow.h"

#include "base/memory/scoped_ptr.h"
#include "components/signin/core/account_id/account_id.h"

using testing::_;
using testing::DefaultValue;
using testing::Invoke;

namespace chromeos {
namespace attestation {

FakeServerProxy::FakeServerProxy() : result_(true) {}

FakeServerProxy::~FakeServerProxy() {}

void FakeServerProxy::SendEnrollRequest(const std::string& request,
                                        const DataCallback& callback) {
  callback.Run(result_, request + "_response");
}

void FakeServerProxy::SendCertificateRequest(const std::string& request,
                                             const DataCallback& callback) {
  callback.Run(result_, request + "_response");
}

MockServerProxy::MockServerProxy() {
  DefaultValue<PrivacyCAType>::Set(DEFAULT_PCA);
}

MockServerProxy::~MockServerProxy() {}

void MockServerProxy::DeferToFake(bool success) {
  fake_.set_result(success);
  ON_CALL(*this, SendEnrollRequest(_, _))
      .WillByDefault(Invoke(&fake_, &FakeServerProxy::SendEnrollRequest));
  ON_CALL(*this, SendCertificateRequest(_, _))
      .WillByDefault(Invoke(&fake_, &FakeServerProxy::SendCertificateRequest));
}

MockObserver::MockObserver() {}

MockObserver::~MockObserver() {}

MockAttestationFlow::MockAttestationFlow()
    : AttestationFlow(NULL, NULL, scoped_ptr<ServerProxy>()) {}

MockAttestationFlow::~MockAttestationFlow() {}

}  // namespace attestation
}  // namespace chromeos