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

Side by Side Diff: chrome/browser/chromeos/attestation/platform_verification_flow_unittest.cc

Issue 23765004: Added prefs for content protection attestation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/testing_pref_service.h"
9 #include "base/run_loop.h" 11 #include "base/run_loop.h"
10 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" 12 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
11 #include "chrome/browser/chromeos/login/mock_user_manager.h" 13 #include "chrome/browser/chromeos/login/mock_user_manager.h"
14 #include "chrome/browser/chromeos/settings/cros_settings.h"
15 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
16 #include "chrome/browser/chromeos/settings/device_settings_service.h"
17 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
12 #include "chrome/browser/chromeos/system/mock_statistics_provider.h" 18 #include "chrome/browser/chromeos/system/mock_statistics_provider.h"
19 #include "chrome/common/pref_names.h"
13 #include "chromeos/attestation/mock_attestation_flow.h" 20 #include "chromeos/attestation/mock_attestation_flow.h"
14 #include "chromeos/cryptohome/mock_async_method_caller.h" 21 #include "chromeos/cryptohome/mock_async_method_caller.h"
15 #include "chromeos/dbus/fake_cryptohome_client.h" 22 #include "chromeos/dbus/fake_cryptohome_client.h"
16 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
17 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
18 25
19 using testing::_; 26 using testing::_;
20 using testing::DoAll; 27 using testing::DoAll;
21 using testing::Invoke; 28 using testing::Invoke;
22 using testing::Return; 29 using testing::Return;
23 using testing::SetArgumentPointee; 30 using testing::SetArgumentPointee;
24 using testing::StrictMock; 31 using testing::StrictMock;
25 using testing::WithArgs; 32 using testing::WithArgs;
26 33
27 namespace chromeos { 34 namespace chromeos {
28 namespace attestation { 35 namespace attestation {
29 36
30 namespace { 37 namespace {
31 38
32 const char kTestID[] = "test_id"; 39 const char kTestID[] = "test_id";
33 const char kTestChallenge[] = "test_challenge"; 40 const char kTestChallenge[] = "test_challenge";
34 const char kTestResponse[] = "test_challenge_response"; 41 const char kTestResponse[] = "test_challenge_response";
35 const char kTestCertificate[] = "test_certificate"; 42 const char kTestCertificate[] = "test_certificate";
36 const char kTestEmail[] = "test_email@chromium.org"; 43 const char kTestEmail[] = "test_email@chromium.org";
44 const char kTestURL[] = "http://mytestdomain/test";
45 const char kTestDomain[] = "mytestdomain";
37 46
38 class FakeDelegate : public PlatformVerificationFlow::Delegate { 47 class FakeDelegate : public PlatformVerificationFlow::Delegate {
39 public: 48 public:
40 FakeDelegate() : response_(PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW), 49 FakeDelegate() : response_(PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW),
41 num_consent_calls_(0), 50 num_consent_calls_(0) {}
42 attestation_disabled_(false),
43 origin_consent_required_(false),
44 always_ask_required_(false),
45 update_settings_result_(true) {}
46 virtual ~FakeDelegate() {} 51 virtual ~FakeDelegate() {}
47 52
48 virtual void ShowConsentPrompt( 53 virtual void ShowConsentPrompt(
49 PlatformVerificationFlow::ConsentType type, 54 PlatformVerificationFlow::ConsentType type,
50 content::WebContents* web_contents, 55 content::WebContents* web_contents,
51 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) 56 const PlatformVerificationFlow::Delegate::ConsentCallback& callback)
52 OVERRIDE { 57 OVERRIDE {
53 num_consent_calls_++; 58 num_consent_calls_++;
54 callback.Run(response_); 59 callback.Run(response_);
55 } 60 }
56 61
57 virtual bool IsAttestationDisabled() OVERRIDE {
58 return attestation_disabled_;
59 }
60
61 virtual bool IsOriginConsentRequired(
62 content::WebContents* web_contents) OVERRIDE {
63 return origin_consent_required_;
64 }
65
66 virtual bool IsAlwaysAskRequired(
67 content::WebContents* web_contents) OVERRIDE {
68 return always_ask_required_;
69 }
70
71 virtual bool UpdateSettings(
72 content::WebContents* web_contents,
73 PlatformVerificationFlow::ConsentType consent_type,
74 PlatformVerificationFlow::ConsentResponse consent_response) OVERRIDE {
75 return update_settings_result_;
76 }
77
78 void set_response(PlatformVerificationFlow::ConsentResponse response) { 62 void set_response(PlatformVerificationFlow::ConsentResponse response) {
79 response_ = response; 63 response_ = response;
80 } 64 }
81 65
82 int num_consent_calls() { 66 int num_consent_calls() {
83 return num_consent_calls_; 67 return num_consent_calls_;
84 } 68 }
85 69
86 void set_attestation_disabled(bool attestation_disabled) {
87 attestation_disabled_ = attestation_disabled;
88 }
89
90 void set_origin_consent_required(bool origin_consent_required) {
91 origin_consent_required_ = origin_consent_required;
92 }
93
94 void set_always_ask_required(bool always_ask_required) {
95 always_ask_required_ = always_ask_required;
96 }
97
98 void set_update_settings_result(bool update_settings_result) {
99 update_settings_result_ = update_settings_result;
100 }
101
102 private: 70 private:
103 PlatformVerificationFlow::ConsentResponse response_; 71 PlatformVerificationFlow::ConsentResponse response_;
104 int num_consent_calls_; 72 int num_consent_calls_;
105 bool attestation_disabled_;
106 bool origin_consent_required_;
107 bool always_ask_required_;
108 bool update_settings_result_;
109 73
110 DISALLOW_COPY_AND_ASSIGN(FakeDelegate); 74 DISALLOW_COPY_AND_ASSIGN(FakeDelegate);
111 }; 75 };
112 76
113 class CustomFakeCryptohomeClient : public FakeCryptohomeClient { 77 class CustomFakeCryptohomeClient : public FakeCryptohomeClient {
114 public: 78 public:
115 CustomFakeCryptohomeClient() : call_status_(DBUS_METHOD_CALL_SUCCESS), 79 CustomFakeCryptohomeClient() : call_status_(DBUS_METHOD_CALL_SUCCESS),
116 attestation_enrolled_(true), 80 attestation_enrolled_(true),
117 attestation_prepared_(true) {} 81 attestation_prepared_(true) {}
118 virtual void TpmAttestationIsEnrolled( 82 virtual void TpmAttestationIsEnrolled(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 &mock_user_manager_, 142 &mock_user_manager_,
179 &mock_statistics_provider_, 143 &mock_statistics_provider_,
180 &fake_delegate_)); 144 &fake_delegate_));
181 145
182 // Create callbacks for tests to use with verifier_. 146 // Create callbacks for tests to use with verifier_.
183 callback_ = base::Bind(&PlatformVerificationFlowTest::FakeChallengeCallback, 147 callback_ = base::Bind(&PlatformVerificationFlowTest::FakeChallengeCallback,
184 base::Unretained(this)); 148 base::Unretained(this));
185 check_state_callback_ = base::Bind( 149 check_state_callback_ = base::Bind(
186 &PlatformVerificationFlowTest::FakeCheckStateCallback, 150 &PlatformVerificationFlowTest::FakeCheckStateCallback,
187 base::Unretained(this)); 151 base::Unretained(this));
152
153 // Configure the test pref service.
154 pref_service_.registry()->RegisterBooleanPref(prefs::kEnableDRM, true);
155 pref_service_.registry()->RegisterBooleanPref(prefs::kRAConsentFirstTime,
156 true);
157 pref_service_.registry()->RegisterBooleanPref(prefs::kRAConsentAlways,
158 false);
159 pref_service_.registry()->RegisterDictionaryPref(prefs::kRAConsentDomains);
160 verifier_->set_testing_prefs(&pref_service_);
161
162 // Configure the global cros_settings.
163 CrosSettings* cros_settings = CrosSettings::Get();
164 device_settings_provider_ =
165 cros_settings->GetProvider(kAttestationForContentProtectionEnabled);
166 cros_settings->RemoveSettingsProvider(device_settings_provider_);
167 cros_settings->AddSettingsProvider(&stub_settings_provider_);
168 cros_settings->SetBoolean(kAttestationForContentProtectionEnabled, true);
169
170 // Configure a test URL to shortcut the dependency on WebContents.
171 verifier_->set_testing_url(GURL(kTestURL));
188 } 172 }
189 173
190 void TearDown() { 174 void TearDown() {
191 verifier_.reset(); 175 verifier_.reset();
176 // Restore the real DeviceSettingsProvider.
177 CrosSettings* cros_settings = CrosSettings::Get();
178 cros_settings->RemoveSettingsProvider(&stub_settings_provider_);
179 cros_settings->AddSettingsProvider(device_settings_provider_);
192 } 180 }
193 181
194 void ExpectAttestationFlow() { 182 void ExpectAttestationFlow() {
195 // When consent is not given or the feature is disabled, it is important 183 // When consent is not given or the feature is disabled, it is important
196 // that there are no calls to the attestation service. Thus, a test must 184 // that there are no calls to the attestation service. Thus, a test must
197 // explicitly expect these calls or the mocks will fail the test. 185 // explicitly expect these calls or the mocks will fail the test.
198 186
199 // Configure the mock AttestationFlow to call FakeGetCertificate. 187 // Configure the mock AttestationFlow to call FakeGetCertificate.
200 EXPECT_CALL(mock_attestation_flow_, 188 EXPECT_CALL(mock_attestation_flow_,
201 GetCertificate(PROFILE_CONTENT_PROTECTION_CERTIFICATE, 189 GetCertificate(PROFILE_CONTENT_PROTECTION_CERTIFICATE,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 231
244 protected: 232 protected:
245 base::MessageLoop message_loop_; 233 base::MessageLoop message_loop_;
246 content::TestBrowserThread ui_thread_; 234 content::TestBrowserThread ui_thread_;
247 StrictMock<MockAttestationFlow> mock_attestation_flow_; 235 StrictMock<MockAttestationFlow> mock_attestation_flow_;
248 cryptohome::MockAsyncMethodCaller mock_async_caller_; 236 cryptohome::MockAsyncMethodCaller mock_async_caller_;
249 CustomFakeCryptohomeClient fake_cryptohome_client_; 237 CustomFakeCryptohomeClient fake_cryptohome_client_;
250 MockUserManager mock_user_manager_; 238 MockUserManager mock_user_manager_;
251 system::MockStatisticsProvider mock_statistics_provider_; 239 system::MockStatisticsProvider mock_statistics_provider_;
252 FakeDelegate fake_delegate_; 240 FakeDelegate fake_delegate_;
241 TestingPrefServiceSimple pref_service_;
242 CrosSettingsProvider* device_settings_provider_;
243 StubCrosSettingsProvider stub_settings_provider_;
244 ScopedTestDeviceSettingsService test_device_settings_service_;
245 ScopedTestCrosSettings test_cros_settings_;
253 scoped_ptr<PlatformVerificationFlow> verifier_; 246 scoped_ptr<PlatformVerificationFlow> verifier_;
254 247
255 // Controls result of FakeGetCertificate. 248 // Controls result of FakeGetCertificate.
256 bool certificate_success_; 249 bool certificate_success_;
257 250
258 // Controls result of FakeSignChallenge. 251 // Controls result of FakeSignChallenge.
259 bool sign_challenge_success_; 252 bool sign_challenge_success_;
260 253
261 // Callback functions and data. 254 // Callback functions and data.
262 PlatformVerificationFlow::ChallengeCallback callback_; 255 PlatformVerificationFlow::ChallengeCallback callback_;
263 PlatformVerificationFlow::Result result_; 256 PlatformVerificationFlow::Result result_;
264 std::string challenge_response_; 257 std::string challenge_response_;
265 std::string certificate_; 258 std::string certificate_;
266 base::Callback<void(bool result)> check_state_callback_; 259 base::Callback<void(bool result)> check_state_callback_;
267 bool check_state_result_; 260 bool check_state_result_;
268 }; 261 };
269 262
270 TEST_F(PlatformVerificationFlowTest, SuccessNoConsent) { 263 TEST_F(PlatformVerificationFlowTest, SuccessNoConsent) {
271 // Make sure the call will fail if consent is requested. 264 // Make sure the call will fail if consent is requested.
272 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY); 265 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY);
273 ExpectAttestationFlow(); 266 ExpectAttestationFlow();
274 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 267 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
275 base::RunLoop().RunUntilIdle(); 268 base::RunLoop().RunUntilIdle();
276 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); 269 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_);
277 EXPECT_EQ(kTestResponse, challenge_response_); 270 EXPECT_EQ(kTestResponse, challenge_response_);
278 EXPECT_EQ(kTestCertificate, certificate_); 271 EXPECT_EQ(kTestCertificate, certificate_);
279 EXPECT_EQ(0, fake_delegate_.num_consent_calls()); 272 EXPECT_EQ(0, fake_delegate_.num_consent_calls());
280 } 273 }
281 274
282 TEST_F(PlatformVerificationFlowTest, SuccessWithOriginConsent) { 275 TEST_F(PlatformVerificationFlowTest, SuccessWithAlwaysAskConsent) {
283 // Enable two conditions and make sure consent is not requested twice. 276 pref_service_.SetUserPref(prefs::kRAConsentAlways,
284 fake_delegate_.set_origin_consent_required(true); 277 new base::FundamentalValue(true));
285 fake_delegate_.set_always_ask_required(true);
286 ExpectAttestationFlow(); 278 ExpectAttestationFlow();
287 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 279 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
288 base::RunLoop().RunUntilIdle(); 280 base::RunLoop().RunUntilIdle();
289 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); 281 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_);
290 EXPECT_EQ(kTestResponse, challenge_response_); 282 EXPECT_EQ(kTestResponse, challenge_response_);
291 EXPECT_EQ(kTestCertificate, certificate_); 283 EXPECT_EQ(kTestCertificate, certificate_);
292 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); 284 EXPECT_EQ(1, fake_delegate_.num_consent_calls());
293 } 285 }
294 286
295 TEST_F(PlatformVerificationFlowTest, SuccessWithAlwaysAskConsent) { 287 TEST_F(PlatformVerificationFlowTest, SuccessWithAttestationConsent) {
296 fake_delegate_.set_always_ask_required(true); 288 fake_cryptohome_client_.set_attestation_enrolled(false);
297 ExpectAttestationFlow(); 289 ExpectAttestationFlow();
298 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 290 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
299 base::RunLoop().RunUntilIdle(); 291 base::RunLoop().RunUntilIdle();
300 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); 292 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_);
301 EXPECT_EQ(kTestResponse, challenge_response_); 293 EXPECT_EQ(kTestResponse, challenge_response_);
302 EXPECT_EQ(kTestCertificate, certificate_); 294 EXPECT_EQ(kTestCertificate, certificate_);
303 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); 295 EXPECT_EQ(1, fake_delegate_.num_consent_calls());
304 } 296 }
305 297
306 TEST_F(PlatformVerificationFlowTest, SuccessWithAttestationConsent) { 298 TEST_F(PlatformVerificationFlowTest, SuccessWithFirstTimeConsent) {
307 fake_cryptohome_client_.set_attestation_enrolled(false); 299 pref_service_.SetUserPref(prefs::kRAConsentFirstTime,
300 new base::FundamentalValue(false));
308 ExpectAttestationFlow(); 301 ExpectAttestationFlow();
309 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 302 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
310 base::RunLoop().RunUntilIdle(); 303 base::RunLoop().RunUntilIdle();
311 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); 304 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_);
312 EXPECT_EQ(kTestResponse, challenge_response_); 305 EXPECT_EQ(kTestResponse, challenge_response_);
313 EXPECT_EQ(kTestCertificate, certificate_); 306 EXPECT_EQ(kTestCertificate, certificate_);
314 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); 307 EXPECT_EQ(1, fake_delegate_.num_consent_calls());
315 } 308 }
316 309
317 TEST_F(PlatformVerificationFlowTest, ConsentRejected) { 310 TEST_F(PlatformVerificationFlowTest, ConsentRejected) {
318 fake_delegate_.set_always_ask_required(true); 311 pref_service_.SetUserPref(prefs::kRAConsentAlways,
312 new base::FundamentalValue(true));
319 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY); 313 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY);
320 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 314 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
321 base::RunLoop().RunUntilIdle(); 315 base::RunLoop().RunUntilIdle();
322 EXPECT_EQ(PlatformVerificationFlow::USER_REJECTED, result_); 316 EXPECT_EQ(PlatformVerificationFlow::USER_REJECTED, result_);
323 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); 317 EXPECT_EQ(1, fake_delegate_.num_consent_calls());
324 } 318 }
325 319
326 TEST_F(PlatformVerificationFlowTest, FeatureDisabled) { 320 TEST_F(PlatformVerificationFlowTest, FeatureDisabled) {
327 fake_delegate_.set_attestation_disabled(true); 321 CrosSettings::Get()->SetBoolean(kAttestationForContentProtectionEnabled,
322 false);
328 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 323 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
329 base::RunLoop().RunUntilIdle(); 324 base::RunLoop().RunUntilIdle();
330 EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_); 325 EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_);
326 EXPECT_EQ(0, fake_delegate_.num_consent_calls());
327 }
328
329 TEST_F(PlatformVerificationFlowTest, FeatureDisabledByUser) {
330 pref_service_.SetUserPref(prefs::kEnableDRM,
331 new base::FundamentalValue(false));
332 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
333 base::RunLoop().RunUntilIdle();
334 EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_);
335 EXPECT_EQ(0, fake_delegate_.num_consent_calls());
336 }
337
338 TEST_F(PlatformVerificationFlowTest, FeatureDisabledByUserForDomain) {
339 base::DictionaryValue* domains = new base::DictionaryValue();
340 domains->SetBoolean(kTestDomain, false);
341 pref_service_.SetUserPref(prefs::kRAConsentDomains, domains);
342 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
343 base::RunLoop().RunUntilIdle();
344 EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_);
331 EXPECT_EQ(0, fake_delegate_.num_consent_calls()); 345 EXPECT_EQ(0, fake_delegate_.num_consent_calls());
332 } 346 }
333 347
334 TEST_F(PlatformVerificationFlowTest, NotVerified) { 348 TEST_F(PlatformVerificationFlowTest, NotVerified) {
335 certificate_success_ = false; 349 certificate_success_ = false;
336 ExpectAttestationFlow(); 350 ExpectAttestationFlow();
337 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 351 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
338 base::RunLoop().RunUntilIdle(); 352 base::RunLoop().RunUntilIdle();
339 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_); 353 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_);
340 } 354 }
341 355
342 TEST_F(PlatformVerificationFlowTest, ChallengeSigningError) { 356 TEST_F(PlatformVerificationFlowTest, ChallengeSigningError) {
343 sign_challenge_success_ = false; 357 sign_challenge_success_ = false;
344 ExpectAttestationFlow(); 358 ExpectAttestationFlow();
345 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 359 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
346 base::RunLoop().RunUntilIdle(); 360 base::RunLoop().RunUntilIdle();
347 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_); 361 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_);
348 } 362 }
349 363
350 TEST_F(PlatformVerificationFlowTest, DBusFailure) { 364 TEST_F(PlatformVerificationFlowTest, DBusFailure) {
351 fake_cryptohome_client_.set_call_status(DBUS_METHOD_CALL_FAILURE); 365 fake_cryptohome_client_.set_call_status(DBUS_METHOD_CALL_FAILURE);
352 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 366 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
353 base::RunLoop().RunUntilIdle(); 367 base::RunLoop().RunUntilIdle();
354 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_); 368 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_);
355 } 369 }
356 370
357 TEST_F(PlatformVerificationFlowTest, UpdateSettingsFailure) {
358 fake_delegate_.set_origin_consent_required(true);
359 fake_delegate_.set_update_settings_result(false);
360 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
361 base::RunLoop().RunUntilIdle();
362 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_);
363 }
364
365 TEST_F(PlatformVerificationFlowTest, ConsentNoResponse) { 371 TEST_F(PlatformVerificationFlowTest, ConsentNoResponse) {
366 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_NONE); 372 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_NONE);
367 fake_delegate_.set_origin_consent_required(true); 373 pref_service_.SetUserPref(prefs::kRAConsentAlways,
374 new base::FundamentalValue(true));
368 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 375 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
369 base::RunLoop().RunUntilIdle(); 376 base::RunLoop().RunUntilIdle();
370 EXPECT_EQ(PlatformVerificationFlow::USER_REJECTED, result_); 377 EXPECT_EQ(PlatformVerificationFlow::USER_REJECTED, result_);
371 } 378 }
372 379
373 TEST_F(PlatformVerificationFlowTest, FastCheck) { 380 TEST_F(PlatformVerificationFlowTest, FastCheck) {
374 verifier_->CheckPlatformState(check_state_callback_); 381 verifier_->CheckPlatformState(check_state_callback_);
375 base::RunLoop().RunUntilIdle(); 382 base::RunLoop().RunUntilIdle();
376 EXPECT_TRUE(check_state_result_); 383 EXPECT_TRUE(check_state_result_);
377 } 384 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 427
421 TEST_F(PlatformVerificationFlowTest, FastCheckDBusFailure) { 428 TEST_F(PlatformVerificationFlowTest, FastCheckDBusFailure) {
422 fake_cryptohome_client_.set_call_status(DBUS_METHOD_CALL_FAILURE); 429 fake_cryptohome_client_.set_call_status(DBUS_METHOD_CALL_FAILURE);
423 verifier_->CheckPlatformState(check_state_callback_); 430 verifier_->CheckPlatformState(check_state_callback_);
424 base::RunLoop().RunUntilIdle(); 431 base::RunLoop().RunUntilIdle();
425 EXPECT_FALSE(check_state_result_); 432 EXPECT_FALSE(check_state_result_);
426 } 433 }
427 434
428 } // namespace attestation 435 } // namespace attestation
429 } // namespace chromeos 436 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/attestation/platform_verification_flow.cc ('k') | chrome/browser/chromeos/preferences.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698