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

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

Issue 2529743002: Wait for the attestation to be ready (TPM being prepared for attestation) before trying to enroll. (Closed)
Patch Set: Hide RetryData as an implementation detail. Created 4 years 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
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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 11 #include "base/run_loop.h"
11 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/test/test_mock_time_task_runner.h"
12 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/time/tick_clock.h"
16 #include "base/timer/timer.h"
13 #include "chromeos/attestation/mock_attestation_flow.h" 17 #include "chromeos/attestation/mock_attestation_flow.h"
14 #include "chromeos/cryptohome/cryptohome_parameters.h" 18 #include "chromeos/cryptohome/cryptohome_parameters.h"
15 #include "chromeos/cryptohome/mock_async_method_caller.h" 19 #include "chromeos/cryptohome/mock_async_method_caller.h"
16 #include "chromeos/dbus/mock_cryptohome_client.h" 20 #include "chromeos/dbus/mock_cryptohome_client.h"
17 #include "components/signin/core/account_id/account_id.h" 21 #include "components/signin/core/account_id/account_id.h"
18 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
20 24
21 using testing::_; 25 using testing::_;
22 using testing::AtLeast; 26 using testing::AtLeast;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 TEST_F(AttestationFlowTest, GetCertificate) { 83 TEST_F(AttestationFlowTest, GetCertificate) {
80 // Verify the order of calls in a sequence. 84 // Verify the order of calls in a sequence.
81 Sequence flow_order; 85 Sequence flow_order;
82 86
83 // Use DBusCallbackFalse so the full enrollment flow is triggered. 87 // Use DBusCallbackFalse so the full enrollment flow is triggered.
84 chromeos::MockCryptohomeClient client; 88 chromeos::MockCryptohomeClient client;
85 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 89 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
86 .InSequence(flow_order) 90 .InSequence(flow_order)
87 .WillRepeatedly(Invoke(DBusCallbackFalse)); 91 .WillRepeatedly(Invoke(DBusCallbackFalse));
88 92
93 EXPECT_CALL(client, TpmAttestationIsPrepared(_))
94 .InSequence(flow_order)
95 .WillOnce(Invoke(DBusCallbackTrue));
96
89 // Use StrictMock when we want to verify invocation frequency. 97 // Use StrictMock when we want to verify invocation frequency.
90 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 98 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
91 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 99 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
100 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _))
101 .Times(1)
102 .InSequence(flow_order);
103
104 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
105 proxy->DeferToFake(true);
106 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
107 EXPECT_CALL(
108 *proxy,
109 SendEnrollRequest(
110 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, _))
111 .Times(1)
112 .InSequence(flow_order);
113
114 std::string fake_enroll_response =
115 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest;
116 fake_enroll_response += "_response";
117 EXPECT_CALL(async_caller,
118 AsyncTpmAttestationEnroll(_, fake_enroll_response, _))
119 .Times(1)
120 .InSequence(flow_order);
121
122 const AccountId account_id = AccountId::FromUserEmail("fake@test.com");
123 EXPECT_CALL(async_caller,
124 AsyncTpmAttestationCreateCertRequest(
125 _, PROFILE_ENTERPRISE_USER_CERTIFICATE,
126 cryptohome::Identification(account_id), "fake_origin", _))
127 .Times(1)
128 .InSequence(flow_order);
129
130 EXPECT_CALL(
131 *proxy,
132 SendCertificateRequest(
133 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, _))
134 .Times(1)
135 .InSequence(flow_order);
136
137 std::string fake_cert_response =
138 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
139 fake_cert_response += "_response";
140 EXPECT_CALL(async_caller, AsyncTpmAttestationFinishCertRequest(
141 fake_cert_response, KEY_USER,
142 cryptohome::Identification(account_id),
143 kEnterpriseUserKey, _))
144 .Times(1)
145 .InSequence(flow_order);
146
147 StrictMock<MockObserver> observer;
148 EXPECT_CALL(
149 observer,
150 MockCertificateCallback(
151 true, cryptohome::MockAsyncMethodCaller::kFakeAttestationCert))
152 .Times(1)
153 .InSequence(flow_order);
154 AttestationFlow::CertificateCallback mock_callback = base::Bind(
155 &MockObserver::MockCertificateCallback, base::Unretained(&observer));
156
157 std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
158 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
159 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, account_id,
160 "fake_origin", true, mock_callback);
161 Run();
162 }
163
164 TEST_F(AttestationFlowTest, GetCertificate_Attestation_Not_Prepared) {
165 // Verify the order of calls in a sequence.
166 Sequence flow_order;
167
168 // Use DBusCallbackFalse so the full enrollment flow is triggered.
169 chromeos::MockCryptohomeClient client;
170 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
171 .InSequence(flow_order)
172 .WillRepeatedly(Invoke(DBusCallbackFalse));
173
174 // It will take a bit for attestation to be prepared.
175 EXPECT_CALL(client, TpmAttestationIsPrepared(_))
176 .InSequence(flow_order)
177 .WillOnce(Invoke(DBusCallbackFalse))
178 .WillOnce(Invoke(DBusCallbackTrue));
179
180 // Use StrictMock when we want to verify invocation frequency.
181 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
182 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
92 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) 183 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _))
93 .Times(1) 184 .Times(1)
94 .InSequence(flow_order); 185 .InSequence(flow_order);
95 186
96 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); 187 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
97 proxy->DeferToFake(true); 188 proxy->DeferToFake(true);
98 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); 189 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
99 EXPECT_CALL(*proxy, SendEnrollRequest( 190 EXPECT_CALL(*proxy, SendEnrollRequest(
100 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 191 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
101 _)).Times(1) 192 _)).Times(1)
(...skipping 19 matching lines...) Expand all
121 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, 212 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest,
122 _)).Times(1) 213 _)).Times(1)
123 .InSequence(flow_order); 214 .InSequence(flow_order);
124 215
125 std::string fake_cert_response = 216 std::string fake_cert_response =
126 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest; 217 cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest;
127 fake_cert_response += "_response"; 218 fake_cert_response += "_response";
128 EXPECT_CALL(async_caller, AsyncTpmAttestationFinishCertRequest( 219 EXPECT_CALL(async_caller, AsyncTpmAttestationFinishCertRequest(
129 fake_cert_response, KEY_USER, 220 fake_cert_response, KEY_USER,
130 cryptohome::Identification(account_id), 221 cryptohome::Identification(account_id),
131 kEnterpriseUserKey, _)) 222 kEnterpriseUserKey, _));
132 .Times(1)
133 .InSequence(flow_order);
134 223
135 StrictMock<MockObserver> observer; 224 StrictMock<MockObserver> observer;
136 EXPECT_CALL(observer, MockCertificateCallback( 225 EXPECT_CALL(observer, MockCertificateCallback(
137 true, 226 true,
138 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert)) 227 cryptohome::MockAsyncMethodCaller::kFakeAttestationCert))
139 .Times(1) 228 .Times(1)
140 .InSequence(flow_order); 229 .InSequence(flow_order);
141 AttestationFlow::CertificateCallback mock_callback = base::Bind( 230 AttestationFlow::CertificateCallback mock_callback = base::Bind(
142 &MockObserver::MockCertificateCallback, 231 &MockObserver::MockCertificateCallback,
143 base::Unretained(&observer)); 232 base::Unretained(&observer));
144 233
234 scoped_refptr<base::TestMockTimeTaskRunner> task_runner(
235 new base::TestMockTimeTaskRunner(base::Time::Now(),
236 base::TimeTicks::Now()));
237 std::unique_ptr<base::TickClock> tick_clock(task_runner->GetMockTickClock());
238 message_loop_.SetTaskRunner(task_runner);
239
145 std::unique_ptr<ServerProxy> proxy_interface(proxy.release()); 240 std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
146 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); 241 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
242 flow.SetTickClockForTest(tick_clock.get());
147 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, account_id, 243 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, account_id,
148 "fake_origin", true, mock_callback); 244 "fake_origin", true, mock_callback);
245
246 task_runner->FastForwardBy(flow.GetPreparednessTimeout());
149 Run(); 247 Run();
150 } 248 }
151 249
250 TEST_F(AttestationFlowTest, GetCertificate_Attestation_Never_Prepared) {
251 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
252 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE);
253
254 chromeos::MockCryptohomeClient client;
255 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
256 .WillRepeatedly(Invoke(DBusCallbackFalse));
257
258 EXPECT_CALL(client, TpmAttestationIsPrepared(_))
259 .WillRepeatedly(Invoke(DBusCallbackFalse));
260
261 // We're not expecting any server calls in this case; StrictMock will verify.
262 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
263 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
264
265 StrictMock<MockObserver> observer;
266 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
267 AttestationFlow::CertificateCallback mock_callback = base::Bind(
268 &MockObserver::MockCertificateCallback, base::Unretained(&observer));
269
270 scoped_refptr<base::TestMockTimeTaskRunner> task_runner(
271 new base::TestMockTimeTaskRunner(base::Time::Now(),
272 base::TimeTicks::Now()));
273 std::unique_ptr<base::TickClock> tick_clock(task_runner->GetMockTickClock());
274 message_loop_.SetTaskRunner(task_runner);
275
276 std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
277 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
278 flow.SetPreparednessTimeout(base::TimeDelta::FromSeconds(35));
279 flow.SetTickClockForTest(tick_clock.get());
280 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(),
281 "fake_origin", true, mock_callback);
282
283 task_runner->FastForwardBy(flow.GetPreparednessTimeout());
284 Run();
285 }
286
287 TEST_F(AttestationFlowTest, CreateRetryData) {
288 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
289 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE);
290
291 chromeos::MockCryptohomeClient client;
292
293 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
294
295 std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
296 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
297
298 // Create as many retry data entries as possible and ensure we stop.
299 while (flow.CreateRetryData() != AttestationFlow::kInvalidRetryId)
300 ;
301 // Now free an entry and check that we can create new data.
302 flow.DoneRetrying(3, base::Closure());
303 EXPECT_EQ(3, flow.CreateRetryData());
304 }
305
152 TEST_F(AttestationFlowTest, GetCertificate_NoEK) { 306 TEST_F(AttestationFlowTest, GetCertificate_NoEK) {
153 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 307 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
154 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE); 308 async_caller.SetUp(false, cryptohome::MOUNT_ERROR_NONE);
155 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) 309 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _))
156 .Times(1); 310 .Times(1);
157 311
158 chromeos::MockCryptohomeClient client; 312 chromeos::MockCryptohomeClient client;
159 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 313 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
160 .WillRepeatedly(Invoke(DBusCallbackFalse)); 314 .WillRepeatedly(Invoke(DBusCallbackFalse));
161 315
316 EXPECT_CALL(client, TpmAttestationIsPrepared(_))
317 .WillOnce(Invoke(DBusCallbackTrue));
318
162 // We're not expecting any server calls in this case; StrictMock will verify. 319 // We're not expecting any server calls in this case; StrictMock will verify.
163 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); 320 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
164 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); 321 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
165 322
166 StrictMock<MockObserver> observer; 323 StrictMock<MockObserver> observer;
167 EXPECT_CALL(observer, MockCertificateCallback(false, "")) 324 EXPECT_CALL(observer, MockCertificateCallback(false, ""))
168 .Times(1); 325 .Times(1);
169 AttestationFlow::CertificateCallback mock_callback = base::Bind( 326 AttestationFlow::CertificateCallback mock_callback = base::Bind(
170 &MockObserver::MockCertificateCallback, 327 &MockObserver::MockCertificateCallback,
171 base::Unretained(&observer)); 328 base::Unretained(&observer));
172 329
173 std::unique_ptr<ServerProxy> proxy_interface(proxy.release()); 330 std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
174 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); 331 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
175 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", 332 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
176 true, mock_callback); 333 true, mock_callback);
177 Run(); 334 Run();
178 } 335 }
179 336
180 TEST_F(AttestationFlowTest, GetCertificate_EKRejected) { 337 TEST_F(AttestationFlowTest, GetCertificate_EKRejected) {
181 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller; 338 StrictMock<cryptohome::MockAsyncMethodCaller> async_caller;
182 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 339 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
183 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _)) 340 EXPECT_CALL(async_caller, AsyncTpmAttestationCreateEnrollRequest(_, _))
184 .Times(1); 341 .Times(1);
185 342
186 chromeos::MockCryptohomeClient client; 343 chromeos::MockCryptohomeClient client;
187 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 344 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
188 .WillRepeatedly(Invoke(DBusCallbackFalse)); 345 .WillRepeatedly(Invoke(DBusCallbackFalse));
189 346
347 EXPECT_CALL(client, TpmAttestationIsPrepared(_))
348 .WillOnce(Invoke(DBusCallbackTrue));
349
190 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); 350 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
191 proxy->DeferToFake(false); 351 proxy->DeferToFake(false);
192 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); 352 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
193 EXPECT_CALL(*proxy, SendEnrollRequest( 353 EXPECT_CALL(*proxy, SendEnrollRequest(
194 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 354 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
195 _)).Times(1); 355 _)).Times(1);
196 356
197 StrictMock<MockObserver> observer; 357 StrictMock<MockObserver> observer;
198 EXPECT_CALL(observer, MockCertificateCallback(false, "")) 358 EXPECT_CALL(observer, MockCertificateCallback(false, ""))
199 .Times(1); 359 .Times(1);
(...skipping 17 matching lines...) Expand all
217 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest; 377 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest;
218 fake_enroll_response += "_response"; 378 fake_enroll_response += "_response";
219 EXPECT_CALL(async_caller, 379 EXPECT_CALL(async_caller,
220 AsyncTpmAttestationEnroll(_, fake_enroll_response, _)) 380 AsyncTpmAttestationEnroll(_, fake_enroll_response, _))
221 .WillOnce(WithArgs<2>(Invoke(AsyncCallbackFalse))); 381 .WillOnce(WithArgs<2>(Invoke(AsyncCallbackFalse)));
222 382
223 chromeos::MockCryptohomeClient client; 383 chromeos::MockCryptohomeClient client;
224 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 384 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
225 .WillRepeatedly(Invoke(DBusCallbackFalse)); 385 .WillRepeatedly(Invoke(DBusCallbackFalse));
226 386
387 EXPECT_CALL(client, TpmAttestationIsPrepared(_))
388 .WillOnce(Invoke(DBusCallbackTrue));
389
227 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>()); 390 std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
228 proxy->DeferToFake(true); 391 proxy->DeferToFake(true);
229 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault()); 392 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
230 EXPECT_CALL(*proxy, SendEnrollRequest( 393 EXPECT_CALL(*proxy, SendEnrollRequest(
231 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, 394 cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest,
232 _)).Times(1); 395 _)).Times(1);
233 396
234 StrictMock<MockObserver> observer; 397 StrictMock<MockObserver> observer;
235 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); 398 EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1);
236 AttestationFlow::CertificateCallback mock_callback = base::Bind( 399 AttestationFlow::CertificateCallback mock_callback = base::Bind(
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // Strategy: Create a ServerProxy mock which reports ALTERNATE_PCA and check 618 // Strategy: Create a ServerProxy mock which reports ALTERNATE_PCA and check
456 // that all calls to the AsyncMethodCaller reflect this PCA type. 619 // that all calls to the AsyncMethodCaller reflect this PCA type.
457 std::unique_ptr<MockServerProxy> proxy(new NiceMock<MockServerProxy>()); 620 std::unique_ptr<MockServerProxy> proxy(new NiceMock<MockServerProxy>());
458 proxy->DeferToFake(true); 621 proxy->DeferToFake(true);
459 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(Return(ALTERNATE_PCA)); 622 EXPECT_CALL(*proxy, GetType()).WillRepeatedly(Return(ALTERNATE_PCA));
460 623
461 chromeos::MockCryptohomeClient client; 624 chromeos::MockCryptohomeClient client;
462 EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) 625 EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
463 .WillRepeatedly(Invoke(DBusCallbackFalse)); 626 .WillRepeatedly(Invoke(DBusCallbackFalse));
464 627
628 EXPECT_CALL(client, TpmAttestationIsPrepared(_))
629 .WillRepeatedly(Invoke(DBusCallbackTrue));
630
465 NiceMock<cryptohome::MockAsyncMethodCaller> async_caller; 631 NiceMock<cryptohome::MockAsyncMethodCaller> async_caller;
466 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE); 632 async_caller.SetUp(true, cryptohome::MOUNT_ERROR_NONE);
467 EXPECT_CALL(async_caller, 633 EXPECT_CALL(async_caller,
468 AsyncTpmAttestationCreateEnrollRequest(ALTERNATE_PCA, _)) 634 AsyncTpmAttestationCreateEnrollRequest(ALTERNATE_PCA, _))
469 .Times(AtLeast(1)); 635 .Times(AtLeast(1));
470 EXPECT_CALL(async_caller, 636 EXPECT_CALL(async_caller,
471 AsyncTpmAttestationEnroll(ALTERNATE_PCA, _, _)) 637 AsyncTpmAttestationEnroll(ALTERNATE_PCA, _, _))
472 .Times(AtLeast(1)); 638 .Times(AtLeast(1));
473 EXPECT_CALL(async_caller, 639 EXPECT_CALL(async_caller,
474 AsyncTpmAttestationCreateCertRequest(ALTERNATE_PCA, _, _, _, _)) 640 AsyncTpmAttestationCreateCertRequest(ALTERNATE_PCA, _, _, _, _))
475 .Times(AtLeast(1)); 641 .Times(AtLeast(1));
476 642
477 NiceMock<MockObserver> observer; 643 NiceMock<MockObserver> observer;
478 AttestationFlow::CertificateCallback mock_callback = base::Bind( 644 AttestationFlow::CertificateCallback mock_callback = base::Bind(
479 &MockObserver::MockCertificateCallback, 645 &MockObserver::MockCertificateCallback,
480 base::Unretained(&observer)); 646 base::Unretained(&observer));
481 647
482 std::unique_ptr<ServerProxy> proxy_interface(proxy.release()); 648 std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
483 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); 649 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
484 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", 650 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
485 true, mock_callback); 651 true, mock_callback);
486 Run(); 652 Run();
487 } 653 }
488 654
489 } // namespace attestation 655 } // namespace attestation
490 } // namespace chromeos 656 } // namespace chromeos
OLDNEW
« chromeos/attestation/attestation_flow.cc ('K') | « chromeos/attestation/attestation_flow.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698