Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: chromeos/attestation/attestation_flow_unittest.cc

Issue 12556004: Created AttestationPolicyObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h"
6 #include "base/run_loop.h" 7 #include "base/run_loop.h"
7 #include "chromeos/attestation/mock_attestation_flow.h" 8 #include "chromeos/attestation/mock_attestation_flow.h"
8 #include "chromeos/cryptohome/mock_async_method_caller.h" 9 #include "chromeos/cryptohome/mock_async_method_caller.h"
9 #include "chromeos/dbus/mock_cryptohome_client.h" 10 #include "chromeos/dbus/mock_cryptohome_client.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using testing::_; 14 using testing::_;
14 using testing::Invoke; 15 using testing::Invoke;
15 using testing::Sequence; 16 using testing::Sequence;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 .InSequence(flow_order) 62 .InSequence(flow_order)
62 .WillRepeatedly(Invoke(DBusCallbackFalse)); 63 .WillRepeatedly(Invoke(DBusCallbackFalse));
63 64
64 // Use StrictMock when we want to verify invocation frequency. 65 // Use StrictMock when we want to verify invocation frequency.
65 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 66 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
66 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 67 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
67 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_)) 68 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_))
68 .Times(1) 69 .Times(1)
69 .InSequence(flow_order); 70 .InSequence(flow_order);
70 71
71 StrictMock<MockServerProxy> proxy; 72 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
72 proxy.DeferToFake(true); 73 proxy->DeferToFake(true);
73 EXPECT_CALL(proxy, SendEnrollRequest( 74 EXPECT_CALL(*proxy, SendEnrollRequest(
74 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 75 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
75 _)).Times(1) 76 _)).Times(1)
76 .InSequence(flow_order); 77 .InSequence(flow_order);
77 78
78 std::string fake_enroll_response = 79 std::string fake_enroll_response =
79 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest; 80 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest;
80 fake_enroll_response += "_response"; 81 fake_enroll_response += "_response";
81 EXPECT_CALL(async_caller, AsyncTpmAttestationEnroll(fake_enroll_response, _)) 82 EXPECT_CALL(async_caller, AsyncTpmAttestationEnroll(fake_enroll_response, _))
82 .Times(1) 83 .Times(1)
83 .InSequence(flow_order); 84 .InSequence(flow_order);
84 85
85 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(false, _)) 86 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(false, _))
86 .Times(1) 87 .Times(1)
87 .InSequence(flow_order); 88 .InSequence(flow_order);
88 89
89 EXPECT_CALL(proxy, SendCertificateRequest( 90 EXPECT_CALL(*proxy, SendCertificateRequest(
90 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 91 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
91 _)).Times(1) 92 _)).Times(1)
92 .InSequence(flow_order); 93 .InSequence(flow_order);
93 94
94 std::string fake_cert_response = 95 std::string fake_cert_response =
95 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; 96 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
96 fake_cert_response += "_response"; 97 fake_cert_response += "_response";
97 EXPECT_CALL(async_caller, 98 EXPECT_CALL(async_caller,
98 AsyncTpmAttestationFinishCertRequest(fake_cert_response, _)) 99 AsyncTpmAttestationFinishCertRequest(fake_cert_response, _))
99 .Times(1) 100 .Times(1)
100 .InSequence(flow_order); 101 .InSequence(flow_order);
101 102
102 StrictMock<MockObserver> observer; 103 StrictMock<MockObserver> observer;
103 EXPECT_CALL(observer, MockCertificateCallback( 104 EXPECT_CALL(observer, MockCertificateCallback(
104 true, 105 true,
105 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)) 106 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert))
106 .Times(1) 107 .Times(1)
107 .InSequence(flow_order); 108 .InSequence(flow_order);
108 AttestationFlow::CertificateCallback mock_callback = base::Bind( 109 AttestationFlow::CertificateCallback mock_callback = base::Bind(
109 &MockObserver::MockCertificateCallback, 110 &MockObserver::MockCertificateCallback,
110 base::Unretained(&observer)); 111 base::Unretained(&observer));
111 112
112 AttestationFlow flow(&async_caller, &client, &proxy); 113 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
114 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
Mattias Nissler (ping if slow) 2013/04/02 12:49:39 So the following doesn't work here? AttestationFl
dkrahn 2013/04/04 21:27:27 It doesn't work without release().
113 flow.GetCertificate("test", mock_callback); 115 flow.GetCertificate("test", mock_callback);
114 Run(); 116 Run();
115 } 117 }
116 118
117 TEST_F(AttestationFlowTest, GetCertificate_NoEK) { 119 TEST_F(AttestationFlowTest, GetCertificate_NoEK) {
118 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 120 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
119 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); 121 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE);
120 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_)) 122 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_))
121 .Times(1); 123 .Times(1);
122 124
123 chromeos::MockCryptohomeClient client; 125 chromeos::MockCryptohomeClient client;
124 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 126 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
125 .WillRepeatedly(Invoke(DBusCallbackFalse)); 127 .WillRepeatedly(Invoke(DBusCallbackFalse));
126 128
127 // We're not expecting any server calls in this case; StrictMock will verify. 129 // We're not expecting any server calls in this case; StrictMock will verify.
128 StrictMock<MockServerProxy> proxy; 130 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
129 131
130 StrictMock<MockObserver> observer; 132 StrictMock<MockObserver> observer;
131 EXPECT_CALL(observer, MockCertificateCallback(false, "")) 133 EXPECT_CALL(observer, MockCertificateCallback(false, ""))
132 .Times(1); 134 .Times(1);
133 AttestationFlow::CertificateCallback mock_callback = base::Bind( 135 AttestationFlow::CertificateCallback mock_callback = base::Bind(
134 &MockObserver::MockCertificateCallback, 136 &MockObserver::MockCertificateCallback,
135 base::Unretained(&observer)); 137 base::Unretained(&observer));
136 138
137 AttestationFlow flow(&async_caller, &client, &proxy); 139 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
140 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
138 flow.GetCertificate("test", mock_callback); 141 flow.GetCertificate("test", mock_callback);
139 Run(); 142 Run();
140 } 143 }
141 144
142 TEST_F(AttestationFlowTest, GetCertificate_EKRejected) { 145 TEST_F(AttestationFlowTest, GetCertificate_EKRejected) {
143 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 146 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
144 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 147 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
145 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_)) 148 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_))
146 .Times(1); 149 .Times(1);
147 150
148 chromeos::MockCryptohomeClient client; 151 chromeos::MockCryptohomeClient client;
149 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 152 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
150 .WillRepeatedly(Invoke(DBusCallbackFalse)); 153 .WillRepeatedly(Invoke(DBusCallbackFalse));
151 154
152 StrictMock<MockServerProxy> proxy; 155 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
153 proxy.DeferToFake(false); 156 proxy->DeferToFake(false);
154 EXPECT_CALL(proxy, SendEnrollRequest( 157 EXPECT_CALL(*proxy, SendEnrollRequest(
155 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 158 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
156 _)).Times(1); 159 _)).Times(1);
157 160
158 StrictMock<MockObserver> observer; 161 StrictMock<MockObserver> observer;
159 EXPECT_CALL(observer, MockCertificateCallback(false, "")) 162 EXPECT_CALL(observer, MockCertificateCallback(false, ""))
160 .Times(1); 163 .Times(1);
161 AttestationFlow::CertificateCallback mock_callback = base::Bind( 164 AttestationFlow::CertificateCallback mock_callback = base::Bind(
162 &MockObserver::MockCertificateCallback, 165 &MockObserver::MockCertificateCallback,
163 base::Unretained(&observer)); 166 base::Unretained(&observer));
164 167
165 AttestationFlow flow(&async_caller, &client, &proxy); 168 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
169 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
166 flow.GetCertificate("test", mock_callback); 170 flow.GetCertificate("test", mock_callback);
167 Run(); 171 Run();
168 } 172 }
169 173
170 TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) { 174 TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) {
171 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 175 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
172 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 176 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
173 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_)) 177 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_))
174 .Times(1); 178 .Times(1);
175 std::string fake_enroll_response = 179 std::string fake_enroll_response =
176 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest; 180 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest;
177 fake_enroll_response += "_response"; 181 fake_enroll_response += "_response";
178 EXPECT_CALL(async_caller, AsyncTpmAttestationEnroll(fake_enroll_response, _)) 182 EXPECT_CALL(async_caller, AsyncTpmAttestationEnroll(fake_enroll_response, _))
179 .WillOnce(WithArgs<1>(Invoke(AsyncCallbackFalse))); 183 .WillOnce(WithArgs<1>(Invoke(AsyncCallbackFalse)));
180 184
181 chromeos::MockCryptohomeClient client; 185 chromeos::MockCryptohomeClient client;
182 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 186 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
183 .WillRepeatedly(Invoke(DBusCallbackFalse)); 187 .WillRepeatedly(Invoke(DBusCallbackFalse));
184 188
185 StrictMock<MockServerProxy> proxy; 189 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
186 proxy.DeferToFake(true); 190 proxy->DeferToFake(true);
187 EXPECT_CALL(proxy, SendEnrollRequest( 191 EXPECT_CALL(*proxy, SendEnrollRequest(
188 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 192 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
189 _)).Times(1); 193 _)).Times(1);
190 194
191 StrictMock<MockObserver> observer; 195 StrictMock<MockObserver> observer;
192 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 196 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
193 AttestationFlow::CertificateCallback mock_callback = base::Bind( 197 AttestationFlow::CertificateCallback mock_callback = base::Bind(
194 &MockObserver::MockCertificateCallback, 198 &MockObserver::MockCertificateCallback,
195 base::Unretained(&observer)); 199 base::Unretained(&observer));
196 200
197 AttestationFlow flow(&async_caller, &client, &proxy); 201 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
202 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
198 flow.GetCertificate("test", mock_callback); 203 flow.GetCertificate("test", mock_callback);
199 Run(); 204 Run();
200 } 205 }
201 206
202 TEST_F(AttestationFlowTest, GetOwnerCertificateAlreadyEnrolled) { 207 TEST_F(AttestationFlowTest, GetOwnerCertificateAlreadyEnrolled) {
203 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 208 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
204 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 209 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
205 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(true, _)) 210 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(true, _))
206 .Times(1); 211 .Times(1);
207 std::string fake_cert_response = 212 std::string fake_cert_response =
208 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; 213 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
209 fake_cert_response += "_response"; 214 fake_cert_response += "_response";
210 EXPECT_CALL(async_caller, 215 EXPECT_CALL(async_caller,
211 AsyncTpmAttestationFinishCertRequest(fake_cert_response, _)) 216 AsyncTpmAttestationFinishCertRequest(fake_cert_response, _))
212 .Times(1); 217 .Times(1);
213 218
214 chromeos::MockCryptohomeClient client; 219 chromeos::MockCryptohomeClient client;
215 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 220 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
216 .WillRepeatedly(Invoke(DBusCallbackTrue)); 221 .WillRepeatedly(Invoke(DBusCallbackTrue));
217 222
218 StrictMock<MockServerProxy> proxy; 223 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
219 proxy.DeferToFake(true); 224 proxy->DeferToFake(true);
220 EXPECT_CALL(proxy, SendCertificateRequest( 225 EXPECT_CALL(*proxy, SendCertificateRequest(
221 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 226 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
222 _)).Times(1); 227 _)).Times(1);
223 228
224 StrictMock<MockObserver> observer; 229 StrictMock<MockObserver> observer;
225 EXPECT_CALL(observer, MockCertificateCallback( 230 EXPECT_CALL(observer, MockCertificateCallback(
226 true, 231 true,
227 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)).Times(1); 232 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)).Times(1);
228 AttestationFlow::CertificateCallback mock_callback = base::Bind( 233 AttestationFlow::CertificateCallback mock_callback = base::Bind(
229 &MockObserver::MockCertificateCallback, 234 &MockObserver::MockCertificateCallback,
230 base::Unretained(&observer)); 235 base::Unretained(&observer));
231 236
232 AttestationFlow flow(&async_caller, &client, &proxy); 237 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
238 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
233 flow.GetCertificate("attest-ent-machine", mock_callback); 239 flow.GetCertificate("attest-ent-machine", mock_callback);
234 Run(); 240 Run();
235 } 241 }
236 242
237 TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) { 243 TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) {
238 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 244 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
239 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); 245 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE);
240 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(false, _)) 246 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(false, _))
241 .Times(1); 247 .Times(1);
242 248
243 chromeos::MockCryptohomeClient client; 249 chromeos::MockCryptohomeClient client;
244 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 250 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
245 .WillRepeatedly(Invoke(DBusCallbackTrue)); 251 .WillRepeatedly(Invoke(DBusCallbackTrue));
246 252
247 // We're not expecting any server calls in this case; StrictMock will verify. 253 // We're not expecting any server calls in this case; StrictMock will verify.
248 StrictMock<MockServerProxy> proxy; 254 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
249 255
250 StrictMock<MockObserver> observer; 256 StrictMock<MockObserver> observer;
251 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 257 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
252 AttestationFlow::CertificateCallback mock_callback = base::Bind( 258 AttestationFlow::CertificateCallback mock_callback = base::Bind(
253 &MockObserver::MockCertificateCallback, 259 &MockObserver::MockCertificateCallback,
254 base::Unretained(&observer)); 260 base::Unretained(&observer));
255 261
256 AttestationFlow flow(&async_caller, &client, &proxy); 262 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
263 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
257 flow.GetCertificate("test", mock_callback); 264 flow.GetCertificate("test", mock_callback);
258 Run(); 265 Run();
259 } 266 }
260 267
261 TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) { 268 TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) {
262 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 269 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
263 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 270 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
264 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(false, _)) 271 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateCertRequest(false, _))
265 .Times(1); 272 .Times(1);
266 273
267 chromeos::MockCryptohomeClient client; 274 chromeos::MockCryptohomeClient client;
268 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 275 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
269 .WillRepeatedly(Invoke(DBusCallbackTrue)); 276 .WillRepeatedly(Invoke(DBusCallbackTrue));
270 277
271 StrictMock<MockServerProxy> proxy; 278 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
272 proxy.DeferToFake(false); 279 proxy->DeferToFake(false);
273 EXPECT_CALL(proxy, SendCertificateRequest( 280 EXPECT_CALL(*proxy, SendCertificateRequest(
274 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 281 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
275 _)).Times(1); 282 _)).Times(1);
276 283
277 StrictMock<MockObserver> observer; 284 StrictMock<MockObserver> observer;
278 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 285 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
279 AttestationFlow::CertificateCallback mock_callback = base::Bind( 286 AttestationFlow::CertificateCallback mock_callback = base::Bind(
280 &MockObserver::MockCertificateCallback, 287 &MockObserver::MockCertificateCallback,
281 base::Unretained(&observer)); 288 base::Unretained(&observer));
282 289
283 AttestationFlow flow(&async_caller, &client, &proxy); 290 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
291 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
284 flow.GetCertificate("test", mock_callback); 292 flow.GetCertificate("test", mock_callback);
285 Run(); 293 Run();
286 } 294 }
287 295
288 TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) { 296 TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) {
289 // We're not expecting any server calls in this case; StrictMock will verify. 297 // We're not expecting any server calls in this case; StrictMock will verify.
290 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 298 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
291 299
292 chromeos::MockCryptohomeClient client; 300 chromeos::MockCryptohomeClient client;
293 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 301 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
294 .WillRepeatedly(Invoke(DBusCallbackFail)); 302 .WillRepeatedly(Invoke(DBusCallbackFail));
295 303
296 // We're not expecting any server calls in this case; StrictMock will verify. 304 // We're not expecting any server calls in this case; StrictMock will verify.
297 StrictMock<MockServerProxy> proxy; 305 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
298 306
299 StrictMock<MockObserver> observer; 307 StrictMock<MockObserver> observer;
300 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 308 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
301 AttestationFlow::CertificateCallback mock_callback = base::Bind( 309 AttestationFlow::CertificateCallback mock_callback = base::Bind(
302 &MockObserver::MockCertificateCallback, 310 &MockObserver::MockCertificateCallback,
303 base::Unretained(&observer)); 311 base::Unretained(&observer));
304 312
305 AttestationFlow flow(&async_caller, &client, &proxy); 313 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
314 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
306 flow.GetCertificate("test", mock_callback); 315 flow.GetCertificate("test", mock_callback);
307 Run(); 316 Run();
308 } 317 }
309 318
310 } // namespace attestation 319 } // namespace attestation
311 } // namespace chromeos 320 } // namespace chromeos
OLDNEW
« chromeos/attestation/attestation_flow.h ('K') | « chromeos/attestation/attestation_flow.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698