OLD | NEW |
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 <utility> |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
7 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
8 #include "chromeos/attestation/mock_attestation_flow.h" | 10 #include "chromeos/attestation/mock_attestation_flow.h" |
9 #include "chromeos/cryptohome/mock_async_method_caller.h" | 11 #include "chromeos/cryptohome/mock_async_method_caller.h" |
10 #include "chromeos/dbus/mock_cryptohome_client.h" | 12 #include "chromeos/dbus/mock_cryptohome_client.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 | 15 |
14 using testing::_; | 16 using testing::_; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_CALL(observer, MockCertificateCallback( | 134 EXPECT_CALL(observer, MockCertificateCallback( |
133 true, | 135 true, |
134 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)) | 136 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)) |
135 .Times(1) | 137 .Times(1) |
136 .InSequence(flow_order); | 138 .InSequence(flow_order); |
137 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 139 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
138 &MockObserver::MockCertificateCallback, | 140 &MockObserver::MockCertificateCallback, |
139 base::Unretained(&observer)); | 141 base::Unretained(&observer)); |
140 | 142 |
141 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 143 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
142 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 144 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
143 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "fake@test.com", | 145 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "fake@test.com", |
144 "fake_origin", true, mock_callback); | 146 "fake_origin", true, mock_callback); |
145 Run(); | 147 Run(); |
146 } | 148 } |
147 | 149 |
148 TEST_F(AttestationFlowTest, GetCertificate_NoEK) { | 150 TEST_F(AttestationFlowTest, GetCertificate_NoEK) { |
149 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 151 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
150 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); | 152 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); |
151 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) | 153 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) |
152 .Times(1); | 154 .Times(1); |
153 | 155 |
154 chromeos::MockCryptohomeClient client; | 156 chromeos::MockCryptohomeClient client; |
155 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) | 157 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
156 .WillRepeatedly(Invoke(DBusCallbackFalse)); | 158 .WillRepeatedly(Invoke(DBusCallbackFalse)); |
157 | 159 |
158 // We're not expecting any server calls in this case; StrictMock will verify. | 160 // We're not expecting any server calls in this case; StrictMock will verify. |
159 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); | 161 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); |
160 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); | 162 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); |
161 | 163 |
162 StrictMock<MockObserver> observer; | 164 StrictMock<MockObserver> observer; |
163 EXPECT_CALL(observer, MockCertificateCallback(false, "")) | 165 EXPECT_CALL(observer, MockCertificateCallback(false, "")) |
164 .Times(1); | 166 .Times(1); |
165 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 167 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
166 &MockObserver::MockCertificateCallback, | 168 &MockObserver::MockCertificateCallback, |
167 base::Unretained(&observer)); | 169 base::Unretained(&observer)); |
168 | 170 |
169 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 171 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
170 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 172 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
171 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, | 173 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
172 mock_callback); | 174 mock_callback); |
173 Run(); | 175 Run(); |
174 } | 176 } |
175 | 177 |
176 TEST_F(AttestationFlowTest, GetCertificate_EKRejected) { | 178 TEST_F(AttestationFlowTest, GetCertificate_EKRejected) { |
177 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 179 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
178 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 180 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
179 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) | 181 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) |
180 .Times(1); | 182 .Times(1); |
(...skipping 10 matching lines...) Expand all Loading... |
191 _)).Times(1); | 193 _)).Times(1); |
192 | 194 |
193 StrictMock<MockObserver> observer; | 195 StrictMock<MockObserver> observer; |
194 EXPECT_CALL(observer, MockCertificateCallback(false, "")) | 196 EXPECT_CALL(observer, MockCertificateCallback(false, "")) |
195 .Times(1); | 197 .Times(1); |
196 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 198 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
197 &MockObserver::MockCertificateCallback, | 199 &MockObserver::MockCertificateCallback, |
198 base::Unretained(&observer)); | 200 base::Unretained(&observer)); |
199 | 201 |
200 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 202 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
201 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 203 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
202 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, | 204 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
203 mock_callback); | 205 mock_callback); |
204 Run(); | 206 Run(); |
205 } | 207 } |
206 | 208 |
207 TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) { | 209 TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) { |
208 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 210 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
209 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 211 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
210 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) | 212 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) |
211 .Times(1); | 213 .Times(1); |
(...skipping 15 matching lines...) Expand all Loading... |
227 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, | 229 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, |
228 _)).Times(1); | 230 _)).Times(1); |
229 | 231 |
230 StrictMock<MockObserver> observer; | 232 StrictMock<MockObserver> observer; |
231 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); | 233 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); |
232 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 234 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
233 &MockObserver::MockCertificateCallback, | 235 &MockObserver::MockCertificateCallback, |
234 base::Unretained(&observer)); | 236 base::Unretained(&observer)); |
235 | 237 |
236 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 238 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
237 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 239 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
238 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, | 240 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
239 mock_callback); | 241 mock_callback); |
240 Run(); | 242 Run(); |
241 } | 243 } |
242 | 244 |
243 TEST_F(AttestationFlowTest, GetMachineCertificateAlreadyEnrolled) { | 245 TEST_F(AttestationFlowTest, GetMachineCertificateAlreadyEnrolled) { |
244 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 246 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
245 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 247 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
246 EXPECT_CALL(async_caller, | 248 EXPECT_CALL(async_caller, |
247 AsyncTpmAttestationCreateCertRequest( | 249 AsyncTpmAttestationCreateCertRequest( |
(...skipping 23 matching lines...) Expand all Loading... |
271 | 273 |
272 StrictMock<MockObserver> observer; | 274 StrictMock<MockObserver> observer; |
273 EXPECT_CALL(observer, MockCertificateCallback( | 275 EXPECT_CALL(observer, MockCertificateCallback( |
274 true, | 276 true, |
275 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)).Times(1); | 277 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)).Times(1); |
276 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 278 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
277 &MockObserver::MockCertificateCallback, | 279 &MockObserver::MockCertificateCallback, |
278 base::Unretained(&observer)); | 280 base::Unretained(&observer)); |
279 | 281 |
280 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 282 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
281 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 283 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
282 flow.GetCertificate(PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, "", "", true, | 284 flow.GetCertificate(PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, "", "", true, |
283 mock_callback); | 285 mock_callback); |
284 Run(); | 286 Run(); |
285 } | 287 } |
286 | 288 |
287 TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) { | 289 TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) { |
288 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 290 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
289 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); | 291 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); |
290 EXPECT_CALL(async_caller, | 292 EXPECT_CALL(async_caller, |
291 AsyncTpmAttestationCreateCertRequest( | 293 AsyncTpmAttestationCreateCertRequest( |
292 _, PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _)) | 294 _, PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _)) |
293 .Times(1); | 295 .Times(1); |
294 | 296 |
295 chromeos::MockCryptohomeClient client; | 297 chromeos::MockCryptohomeClient client; |
296 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) | 298 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
297 .WillRepeatedly(Invoke(DBusCallbackTrue)); | 299 .WillRepeatedly(Invoke(DBusCallbackTrue)); |
298 | 300 |
299 // We're not expecting any server calls in this case; StrictMock will verify. | 301 // We're not expecting any server calls in this case; StrictMock will verify. |
300 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); | 302 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); |
301 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); | 303 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); |
302 | 304 |
303 StrictMock<MockObserver> observer; | 305 StrictMock<MockObserver> observer; |
304 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); | 306 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); |
305 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 307 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
306 &MockObserver::MockCertificateCallback, | 308 &MockObserver::MockCertificateCallback, |
307 base::Unretained(&observer)); | 309 base::Unretained(&observer)); |
308 | 310 |
309 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 311 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
310 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 312 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
311 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, | 313 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
312 mock_callback); | 314 mock_callback); |
313 Run(); | 315 Run(); |
314 } | 316 } |
315 | 317 |
316 TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) { | 318 TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) { |
317 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 319 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
318 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 320 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
319 EXPECT_CALL(async_caller, | 321 EXPECT_CALL(async_caller, |
320 AsyncTpmAttestationCreateCertRequest( | 322 AsyncTpmAttestationCreateCertRequest( |
(...skipping 11 matching lines...) Expand all Loading... |
332 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, | 334 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, |
333 _)).Times(1); | 335 _)).Times(1); |
334 | 336 |
335 StrictMock<MockObserver> observer; | 337 StrictMock<MockObserver> observer; |
336 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); | 338 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); |
337 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 339 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
338 &MockObserver::MockCertificateCallback, | 340 &MockObserver::MockCertificateCallback, |
339 base::Unretained(&observer)); | 341 base::Unretained(&observer)); |
340 | 342 |
341 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 343 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
342 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 344 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
343 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, | 345 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
344 mock_callback); | 346 mock_callback); |
345 Run(); | 347 Run(); |
346 } | 348 } |
347 | 349 |
348 TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) { | 350 TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) { |
349 // We're not expecting any async calls in this case; StrictMock will verify. | 351 // We're not expecting any async calls in this case; StrictMock will verify. |
350 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 352 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
351 | 353 |
352 chromeos::MockCryptohomeClient client; | 354 chromeos::MockCryptohomeClient client; |
353 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) | 355 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
354 .WillRepeatedly(Invoke(DBusCallbackFail)); | 356 .WillRepeatedly(Invoke(DBusCallbackFail)); |
355 | 357 |
356 // We're not expecting any server calls in this case; StrictMock will verify. | 358 // We're not expecting any server calls in this case; StrictMock will verify. |
357 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); | 359 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); |
358 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); | 360 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); |
359 | 361 |
360 StrictMock<MockObserver> observer; | 362 StrictMock<MockObserver> observer; |
361 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); | 363 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); |
362 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 364 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
363 &MockObserver::MockCertificateCallback, | 365 &MockObserver::MockCertificateCallback, |
364 base::Unretained(&observer)); | 366 base::Unretained(&observer)); |
365 | 367 |
366 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 368 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
367 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 369 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
368 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, | 370 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
369 mock_callback); | 371 mock_callback); |
370 Run(); | 372 Run(); |
371 } | 373 } |
372 | 374 |
373 TEST_F(AttestationFlowTest, GetCertificate_CheckExisting) { | 375 TEST_F(AttestationFlowTest, GetCertificate_CheckExisting) { |
374 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 376 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
375 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); | 377 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); |
376 EXPECT_CALL(async_caller, | 378 EXPECT_CALL(async_caller, |
377 AsyncTpmAttestationCreateCertRequest( | 379 AsyncTpmAttestationCreateCertRequest( |
(...skipping 26 matching lines...) Expand all Loading... |
404 | 406 |
405 StrictMock<MockObserver> observer; | 407 StrictMock<MockObserver> observer; |
406 EXPECT_CALL(observer, MockCertificateCallback( | 408 EXPECT_CALL(observer, MockCertificateCallback( |
407 true, | 409 true, |
408 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)).Times(1); | 410 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)).Times(1); |
409 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 411 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
410 &MockObserver::MockCertificateCallback, | 412 &MockObserver::MockCertificateCallback, |
411 base::Unretained(&observer)); | 413 base::Unretained(&observer)); |
412 | 414 |
413 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 415 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
414 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 416 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
415 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", false, | 417 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", false, |
416 mock_callback); | 418 mock_callback); |
417 Run(); | 419 Run(); |
418 } | 420 } |
419 | 421 |
420 TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) { | 422 TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) { |
421 // We're not expecting any async calls in this case; StrictMock will verify. | 423 // We're not expecting any async calls in this case; StrictMock will verify. |
422 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; | 424 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; |
423 | 425 |
424 chromeos::MockCryptohomeClient client; | 426 chromeos::MockCryptohomeClient client; |
(...skipping 10 matching lines...) Expand all Loading... |
435 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); | 437 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); |
436 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); | 438 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); |
437 | 439 |
438 StrictMock<MockObserver> observer; | 440 StrictMock<MockObserver> observer; |
439 EXPECT_CALL(observer, MockCertificateCallback(true, "fake_cert")).Times(1); | 441 EXPECT_CALL(observer, MockCertificateCallback(true, "fake_cert")).Times(1); |
440 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 442 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
441 &MockObserver::MockCertificateCallback, | 443 &MockObserver::MockCertificateCallback, |
442 base::Unretained(&observer)); | 444 base::Unretained(&observer)); |
443 | 445 |
444 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 446 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
445 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 447 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
446 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", false, | 448 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", false, |
447 mock_callback); | 449 mock_callback); |
448 Run(); | 450 Run(); |
449 } | 451 } |
450 | 452 |
451 TEST_F(AttestationFlowTest, AlternatePCA) { | 453 TEST_F(AttestationFlowTest, AlternatePCA) { |
452 // Strategy: Create a ServerProxy mock which reports ALTERNATE_PCA and check | 454 // Strategy: Create a ServerProxy mock which reports ALTERNATE_PCA and check |
453 // that all calls to the AsyncMethodCaller reflect this PCA type. | 455 // that all calls to the AsyncMethodCaller reflect this PCA type. |
454 scoped_ptr<MockServerProxy> proxy(new NiceMock<MockServerProxy>()); | 456 scoped_ptr<MockServerProxy> proxy(new NiceMock<MockServerProxy>()); |
455 proxy->DeferToFake(true); | 457 proxy->DeferToFake(true); |
(...skipping 14 matching lines...) Expand all Loading... |
470 EXPECT_CALL(async_caller, | 472 EXPECT_CALL(async_caller, |
471 AsyncTpmAttestationCreateCertRequest(ALTERNATE_PCA, _, _, _, _)) | 473 AsyncTpmAttestationCreateCertRequest(ALTERNATE_PCA, _, _, _, _)) |
472 .Times(AtLeast(1)); | 474 .Times(AtLeast(1)); |
473 | 475 |
474 NiceMock<MockObserver> observer; | 476 NiceMock<MockObserver> observer; |
475 AttestationFlow::CertificateCallback mock_callback = base::Bind( | 477 AttestationFlow::CertificateCallback mock_callback = base::Bind( |
476 &MockObserver::MockCertificateCallback, | 478 &MockObserver::MockCertificateCallback, |
477 base::Unretained(&observer)); | 479 base::Unretained(&observer)); |
478 | 480 |
479 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); | 481 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); |
480 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); | 482 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
481 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, | 483 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", true, |
482 mock_callback); | 484 mock_callback); |
483 Run(); | 485 Run(); |
484 } | 486 } |
485 | 487 |
486 } // namespace attestation | 488 } // namespace attestation |
487 } // namespace chromeos | 489 } // namespace chromeos |
OLD | NEW |