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

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

Issue 27044004: Added multi-profile support for attestation on chromeos. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added OWNERS Created 7 years, 2 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/memory/scoped_ptr.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chromeos/attestation/mock_attestation_flow.h" 8 #include "chromeos/attestation/mock_attestation_flow.h"
9 #include "chromeos/cryptohome/mock_async_method_caller.h" 9 #include "chromeos/cryptohome/mock_async_method_caller.h"
10 #include "chromeos/dbus/mock_cryptohome_client.h" 10 #include "chromeos/dbus/mock_cryptohome_client.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 108 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
109 _)).Times(1) 109 _)).Times(1)
110 .InSequence(flow_order); 110 .InSequence(flow_order);
111 111
112 std::string fake_cert_response = 112 std::string fake_cert_response =
113 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; 113 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
114 fake_cert_response += "_response"; 114 fake_cert_response += "_response";
115 EXPECT_CALL(async_caller, 115 EXPECT_CALL(async_caller,
116 AsyncTpmAttestationFinishCertRequest(fake_cert_response, 116 AsyncTpmAttestationFinishCertRequest(fake_cert_response,
117 KEY_USER, 117 KEY_USER,
118 "fake_email",
bartfab (slow) 2013/10/13 16:31:35 Could you use something with an @ symbol in it? Th
Darren Krahn 2013/10/15 16:49:06 Done.
118 kEnterpriseUserKey, 119 kEnterpriseUserKey,
119 _)) 120 _))
120 .Times(1) 121 .Times(1)
121 .InSequence(flow_order); 122 .InSequence(flow_order);
122 123
123 StrictMock<MockObserver> observer; 124 StrictMock<MockObserver> observer;
124 EXPECT_CALL(observer, MockCertificateCallback( 125 EXPECT_CALL(observer, MockCertificateCallback(
125 true, 126 true,
126 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)) 127 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert))
127 .Times(1) 128 .Times(1)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXPECT_CALL(async_caller, 235 EXPECT_CALL(async_caller,
235 AsyncTpmAttestationCreateCertRequest( 236 AsyncTpmAttestationCreateCertRequest(
236 PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, "", "", _)) 237 PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, "", "", _))
237 .Times(1); 238 .Times(1);
238 std::string fake_cert_response = 239 std::string fake_cert_response =
239 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; 240 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
240 fake_cert_response += "_response"; 241 fake_cert_response += "_response";
241 EXPECT_CALL(async_caller, 242 EXPECT_CALL(async_caller,
242 AsyncTpmAttestationFinishCertRequest(fake_cert_response, 243 AsyncTpmAttestationFinishCertRequest(fake_cert_response,
243 KEY_DEVICE, 244 KEY_DEVICE,
245 "",
244 kEnterpriseMachineKey, 246 kEnterpriseMachineKey,
245 _)) 247 _))
246 .Times(1); 248 .Times(1);
247 249
248 chromeos::MockCryptohomeClient client; 250 chromeos::MockCryptohomeClient client;
249 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 251 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
250 .WillRepeatedly(Invoke(DBusCallbackTrue)); 252 .WillRepeatedly(Invoke(DBusCallbackTrue));
251 253
252 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); 254 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
253 proxy->DeferToFake(true); 255 proxy->DeferToFake(true);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 EXPECT_CALL(async_caller, 361 EXPECT_CALL(async_caller,
360 AsyncTpmAttestationCreateCertRequest( 362 AsyncTpmAttestationCreateCertRequest(
361 PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _)) 363 PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", _))
362 .Times(1); 364 .Times(1);
363 std::string fake_cert_response = 365 std::string fake_cert_response =
364 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; 366 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
365 fake_cert_response += "_response"; 367 fake_cert_response += "_response";
366 EXPECT_CALL(async_caller, 368 EXPECT_CALL(async_caller,
367 AsyncTpmAttestationFinishCertRequest(fake_cert_response, 369 AsyncTpmAttestationFinishCertRequest(fake_cert_response,
368 KEY_USER, 370 KEY_USER,
371 "",
369 kEnterpriseUserKey, 372 kEnterpriseUserKey,
370 _)) 373 _))
371 .Times(1); 374 .Times(1);
372 375
373 chromeos::MockCryptohomeClient client; 376 chromeos::MockCryptohomeClient client;
374 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 377 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
375 .WillRepeatedly(Invoke(DBusCallbackTrue)); 378 .WillRepeatedly(Invoke(DBusCallbackTrue));
376 EXPECT_CALL(client, 379 EXPECT_CALL(client,
377 TpmAttestationDoesKeyExist(KEY_USER, kEnterpriseUserKey, _)) 380 TpmAttestationDoesKeyExist(KEY_USER, "", kEnterpriseUserKey, _))
378 .WillRepeatedly(WithArgs<2>(Invoke(DBusCallbackFalse))); 381 .WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackFalse)));
379 382
380 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); 383 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
381 proxy->DeferToFake(true); 384 proxy->DeferToFake(true);
382 EXPECT_CALL(*proxy, SendCertificateRequest( 385 EXPECT_CALL(*proxy, SendCertificateRequest(
383 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 386 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
384 _)).Times(1); 387 _)).Times(1);
385 388
386 StrictMock<MockObserver> observer; 389 StrictMock<MockObserver> observer;
387 EXPECT_CALL(observer, MockCertificateCallback( 390 EXPECT_CALL(observer, MockCertificateCallback(
388 true, 391 true,
(...skipping 10 matching lines...) Expand all
399 } 402 }
400 403
401 TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) { 404 TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) {
402 // We're not expecting any async calls in this case; StrictMock will verify. 405 // We're not expecting any async calls in this case; StrictMock will verify.
403 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 406 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
404 407
405 chromeos::MockCryptohomeClient client; 408 chromeos::MockCryptohomeClient client;
406 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 409 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
407 .WillRepeatedly(Invoke(DBusCallbackTrue)); 410 .WillRepeatedly(Invoke(DBusCallbackTrue));
408 EXPECT_CALL(client, 411 EXPECT_CALL(client,
409 TpmAttestationDoesKeyExist(KEY_USER, kEnterpriseUserKey, _)) 412 TpmAttestationDoesKeyExist(KEY_USER, "", kEnterpriseUserKey, _))
410 .WillRepeatedly(WithArgs<2>(Invoke(DBusCallbackTrue))); 413 .WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackTrue)));
411 EXPECT_CALL(client, 414 EXPECT_CALL(client,
412 TpmAttestationGetCertificate(KEY_USER, kEnterpriseUserKey, _)) 415 TpmAttestationGetCertificate(KEY_USER, "", kEnterpriseUserKey, _))
413 .WillRepeatedly(WithArgs<2>(Invoke(FakeDBusData("fake_cert")))); 416 .WillRepeatedly(WithArgs<3>(Invoke(FakeDBusData("fake_cert"))));
414 417
415 // We're not expecting any server calls in this case; StrictMock will verify. 418 // We're not expecting any server calls in this case; StrictMock will verify.
416 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); 419 scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
417 420
418 StrictMock<MockObserver> observer; 421 StrictMock<MockObserver> observer;
419 EXPECT_CALL(observer, MockCertificateCallback(true, "fake_cert")).Times(1); 422 EXPECT_CALL(observer, MockCertificateCallback(true, "fake_cert")).Times(1);
420 AttestationFlow::CertificateCallback mock_callback = base::Bind( 423 AttestationFlow::CertificateCallback mock_callback = base::Bind(
421 &MockObserver::MockCertificateCallback, 424 &MockObserver::MockCertificateCallback,
422 base::Unretained(&observer)); 425 base::Unretained(&observer));
423 426
424 scoped_ptr<ServerProxy> proxy_interface(proxy.release()); 427 scoped_ptr<ServerProxy> proxy_interface(proxy.release());
425 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass()); 428 AttestationFlow flow(&async_caller, &client, proxy_interface.Pass());
426 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", false, 429 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, "", "", false,
427 mock_callback); 430 mock_callback);
428 Run(); 431 Run();
429 } 432 }
430 433
431 } // namespace attestation 434 } // namespace attestation
432 } // namespace chromeos 435 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698