OLD | NEW |
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" |
| 18 #include "chrome/common/pref_names.h" |
12 #include "chromeos/attestation/mock_attestation_flow.h" | 19 #include "chromeos/attestation/mock_attestation_flow.h" |
13 #include "chromeos/cryptohome/mock_async_method_caller.h" | 20 #include "chromeos/cryptohome/mock_async_method_caller.h" |
14 #include "chromeos/dbus/fake_cryptohome_client.h" | 21 #include "chromeos/dbus/fake_cryptohome_client.h" |
15 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
17 | 24 |
18 using testing::_; | 25 using testing::_; |
19 using testing::Invoke; | 26 using testing::Invoke; |
20 using testing::StrictMock; | 27 using testing::StrictMock; |
21 using testing::WithArgs; | 28 using testing::WithArgs; |
22 | 29 |
23 namespace chromeos { | 30 namespace chromeos { |
24 namespace attestation { | 31 namespace attestation { |
25 | 32 |
26 namespace { | 33 namespace { |
27 | 34 |
28 const char kTestID[] = "test_id"; | 35 const char kTestID[] = "test_id"; |
29 const char kTestChallenge[] = "test_challenge"; | 36 const char kTestChallenge[] = "test_challenge"; |
30 const char kTestResponse[] = "test_challenge_response"; | 37 const char kTestResponse[] = "test_challenge_response"; |
31 const char kTestCertificate[] = "test_certificate"; | 38 const char kTestCertificate[] = "test_certificate"; |
32 const char kTestEmail[] = "test_email@chromium.org"; | 39 const char kTestEmail[] = "test_email@chromium.org"; |
| 40 const char kTestURL[] = "http://mytestdomain/test"; |
| 41 const char kTestDomain[] = "mytestdomain"; |
33 | 42 |
34 class FakeDelegate : public PlatformVerificationFlow::Delegate { | 43 class FakeDelegate : public PlatformVerificationFlow::Delegate { |
35 public: | 44 public: |
36 FakeDelegate() : response_(PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW), | 45 FakeDelegate() : response_(PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW), |
37 num_consent_calls_(0), | 46 num_consent_calls_(0) {} |
38 attestation_disabled_(false), | |
39 origin_consent_required_(false), | |
40 always_ask_required_(false), | |
41 update_settings_result_(true) {} | |
42 virtual ~FakeDelegate() {} | 47 virtual ~FakeDelegate() {} |
43 | 48 |
44 virtual void ShowConsentPrompt( | 49 virtual void ShowConsentPrompt( |
45 PlatformVerificationFlow::ConsentType type, | 50 PlatformVerificationFlow::ConsentType type, |
46 content::WebContents* web_contents, | 51 content::WebContents* web_contents, |
47 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) | 52 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) |
48 OVERRIDE { | 53 OVERRIDE { |
49 num_consent_calls_++; | 54 num_consent_calls_++; |
50 callback.Run(response_); | 55 callback.Run(response_); |
51 } | 56 } |
52 | 57 |
53 virtual bool IsAttestationDisabled() OVERRIDE { | |
54 return attestation_disabled_; | |
55 } | |
56 | |
57 virtual bool IsOriginConsentRequired( | |
58 content::WebContents* web_contents) OVERRIDE { | |
59 return origin_consent_required_; | |
60 } | |
61 | |
62 virtual bool IsAlwaysAskRequired( | |
63 content::WebContents* web_contents) OVERRIDE { | |
64 return always_ask_required_; | |
65 } | |
66 | |
67 virtual bool UpdateSettings( | |
68 content::WebContents* web_contents, | |
69 PlatformVerificationFlow::ConsentType consent_type, | |
70 PlatformVerificationFlow::ConsentResponse consent_response) OVERRIDE { | |
71 return update_settings_result_; | |
72 } | |
73 | |
74 void set_response(PlatformVerificationFlow::ConsentResponse response) { | 58 void set_response(PlatformVerificationFlow::ConsentResponse response) { |
75 response_ = response; | 59 response_ = response; |
76 } | 60 } |
77 | 61 |
78 int num_consent_calls() { | 62 int num_consent_calls() { |
79 return num_consent_calls_; | 63 return num_consent_calls_; |
80 } | 64 } |
81 | 65 |
82 void set_attestation_disabled(bool attestation_disabled) { | |
83 attestation_disabled_ = attestation_disabled; | |
84 } | |
85 | |
86 void set_origin_consent_required(bool origin_consent_required) { | |
87 origin_consent_required_ = origin_consent_required; | |
88 } | |
89 | |
90 void set_always_ask_required(bool always_ask_required) { | |
91 always_ask_required_ = always_ask_required; | |
92 } | |
93 | |
94 void set_update_settings_result(bool update_settings_result) { | |
95 update_settings_result_ = update_settings_result; | |
96 } | |
97 | |
98 private: | 66 private: |
99 PlatformVerificationFlow::ConsentResponse response_; | 67 PlatformVerificationFlow::ConsentResponse response_; |
100 int num_consent_calls_; | 68 int num_consent_calls_; |
101 bool attestation_disabled_; | |
102 bool origin_consent_required_; | |
103 bool always_ask_required_; | |
104 bool update_settings_result_; | |
105 | |
106 | 69 |
107 DISALLOW_COPY_AND_ASSIGN(FakeDelegate); | 70 DISALLOW_COPY_AND_ASSIGN(FakeDelegate); |
108 }; | 71 }; |
109 | 72 |
110 class CustomFakeCryptohomeClient : public FakeCryptohomeClient { | 73 class CustomFakeCryptohomeClient : public FakeCryptohomeClient { |
111 public: | 74 public: |
112 CustomFakeCryptohomeClient() : call_status_(DBUS_METHOD_CALL_SUCCESS), | 75 CustomFakeCryptohomeClient() : call_status_(DBUS_METHOD_CALL_SUCCESS), |
113 attestation_enrolled_(true) {} | 76 attestation_enrolled_(true) {} |
114 virtual void TpmAttestationIsEnrolled( | 77 virtual void TpmAttestationIsEnrolled( |
115 const BoolDBusMethodCallback& callback) OVERRIDE { | 78 const BoolDBusMethodCallback& callback) OVERRIDE { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // Create a verifier for tests to call. | 113 // Create a verifier for tests to call. |
151 verifier_.reset(new PlatformVerificationFlow(&mock_attestation_flow_, | 114 verifier_.reset(new PlatformVerificationFlow(&mock_attestation_flow_, |
152 &mock_async_caller_, | 115 &mock_async_caller_, |
153 &fake_cryptohome_client_, | 116 &fake_cryptohome_client_, |
154 &mock_user_manager_, | 117 &mock_user_manager_, |
155 &fake_delegate_)); | 118 &fake_delegate_)); |
156 | 119 |
157 // Create a callback for tests to use with verifier_. | 120 // Create a callback for tests to use with verifier_. |
158 callback_ = base::Bind(&PlatformVerificationFlowTest::FakeChallengeCallback, | 121 callback_ = base::Bind(&PlatformVerificationFlowTest::FakeChallengeCallback, |
159 base::Unretained(this)); | 122 base::Unretained(this)); |
| 123 |
| 124 // Configure the test pref service. |
| 125 pref_service_.registry()->RegisterBooleanPref(prefs::kEnableDRM, true); |
| 126 pref_service_.registry()->RegisterBooleanPref(prefs::kRAConsentFirstTime, |
| 127 true); |
| 128 pref_service_.registry()->RegisterBooleanPref(prefs::kRAConsentAlways, |
| 129 false); |
| 130 pref_service_.registry()->RegisterDictionaryPref(prefs::kRAConsentDomains); |
| 131 verifier_->set_testing_prefs(&pref_service_); |
| 132 |
| 133 // Configure the global cros_settings. |
| 134 CrosSettings* cros_settings = CrosSettings::Get(); |
| 135 device_settings_provider_ = |
| 136 cros_settings->GetProvider(kAttestationForContentProtectionEnabled); |
| 137 cros_settings->RemoveSettingsProvider(device_settings_provider_); |
| 138 cros_settings->AddSettingsProvider(&stub_settings_provider_); |
| 139 cros_settings->SetBoolean(kAttestationForContentProtectionEnabled, true); |
| 140 |
| 141 // Configure a test URL to shortcut the dependency on WebContents. |
| 142 verifier_->set_testing_url(GURL(kTestURL)); |
160 } | 143 } |
161 | 144 |
162 void TearDown() { | 145 void TearDown() { |
163 verifier_.reset(); | 146 verifier_.reset(); |
| 147 // Restore the real DeviceSettingsProvider. |
| 148 CrosSettings* cros_settings = CrosSettings::Get(); |
| 149 cros_settings->RemoveSettingsProvider(&stub_settings_provider_); |
| 150 cros_settings->AddSettingsProvider(device_settings_provider_); |
164 } | 151 } |
165 | 152 |
166 void ExpectAttestationFlow() { | 153 void ExpectAttestationFlow() { |
167 // When consent is not given or the feature is disabled, it is important | 154 // When consent is not given or the feature is disabled, it is important |
168 // that there are no calls to the attestation service. Thus, a test must | 155 // that there are no calls to the attestation service. Thus, a test must |
169 // explicitly expect these calls or the mocks will fail the test. | 156 // explicitly expect these calls or the mocks will fail the test. |
170 | 157 |
171 // Configure the mock AttestationFlow to call FakeGetCertificate. | 158 // Configure the mock AttestationFlow to call FakeGetCertificate. |
172 EXPECT_CALL(mock_attestation_flow_, | 159 EXPECT_CALL(mock_attestation_flow_, |
173 GetCertificate(PROFILE_CONTENT_PROTECTION_CERTIFICATE, | 160 GetCertificate(PROFILE_CONTENT_PROTECTION_CERTIFICATE, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 197 } |
211 | 198 |
212 protected: | 199 protected: |
213 base::MessageLoop message_loop_; | 200 base::MessageLoop message_loop_; |
214 content::TestBrowserThread ui_thread_; | 201 content::TestBrowserThread ui_thread_; |
215 StrictMock<MockAttestationFlow> mock_attestation_flow_; | 202 StrictMock<MockAttestationFlow> mock_attestation_flow_; |
216 cryptohome::MockAsyncMethodCaller mock_async_caller_; | 203 cryptohome::MockAsyncMethodCaller mock_async_caller_; |
217 CustomFakeCryptohomeClient fake_cryptohome_client_; | 204 CustomFakeCryptohomeClient fake_cryptohome_client_; |
218 MockUserManager mock_user_manager_; | 205 MockUserManager mock_user_manager_; |
219 FakeDelegate fake_delegate_; | 206 FakeDelegate fake_delegate_; |
| 207 TestingPrefServiceSimple pref_service_; |
| 208 CrosSettingsProvider* device_settings_provider_; |
| 209 StubCrosSettingsProvider stub_settings_provider_; |
| 210 ScopedTestDeviceSettingsService test_device_settings_service_; |
| 211 ScopedTestCrosSettings test_cros_settings_; |
220 scoped_ptr<PlatformVerificationFlow> verifier_; | 212 scoped_ptr<PlatformVerificationFlow> verifier_; |
221 | 213 |
222 // Controls result of FakeGetCertificate. | 214 // Controls result of FakeGetCertificate. |
223 bool certificate_success_; | 215 bool certificate_success_; |
224 | 216 |
225 // Controls result of FakeSignChallenge. | 217 // Controls result of FakeSignChallenge. |
226 bool sign_challenge_success_; | 218 bool sign_challenge_success_; |
227 | 219 |
228 // Callback function and data. | 220 // Callback function and data. |
229 PlatformVerificationFlow::ChallengeCallback callback_; | 221 PlatformVerificationFlow::ChallengeCallback callback_; |
230 PlatformVerificationFlow::Result result_; | 222 PlatformVerificationFlow::Result result_; |
231 std::string challenge_response_; | 223 std::string challenge_response_; |
232 std::string certificate_; | 224 std::string certificate_; |
233 }; | 225 }; |
234 | 226 |
235 TEST_F(PlatformVerificationFlowTest, SuccessNoConsent) { | 227 TEST_F(PlatformVerificationFlowTest, SuccessNoConsent) { |
236 // Make sure the call will fail if consent is requested. | 228 // Make sure the call will fail if consent is requested. |
237 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY); | 229 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY); |
238 ExpectAttestationFlow(); | 230 ExpectAttestationFlow(); |
239 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 231 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
240 base::RunLoop().RunUntilIdle(); | 232 base::RunLoop().RunUntilIdle(); |
241 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); | 233 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); |
242 EXPECT_EQ(kTestResponse, challenge_response_); | 234 EXPECT_EQ(kTestResponse, challenge_response_); |
243 EXPECT_EQ(kTestCertificate, certificate_); | 235 EXPECT_EQ(kTestCertificate, certificate_); |
244 EXPECT_EQ(0, fake_delegate_.num_consent_calls()); | 236 EXPECT_EQ(0, fake_delegate_.num_consent_calls()); |
245 } | 237 } |
246 | 238 |
247 TEST_F(PlatformVerificationFlowTest, SuccessWithOriginConsent) { | 239 TEST_F(PlatformVerificationFlowTest, SuccessWithAlwaysAskConsent) { |
248 // Enable two conditions and make sure consent is not requested twice. | 240 pref_service_.SetUserPref(prefs::kRAConsentAlways, |
249 fake_delegate_.set_origin_consent_required(true); | 241 new base::FundamentalValue(true)); |
250 fake_delegate_.set_always_ask_required(true); | |
251 ExpectAttestationFlow(); | 242 ExpectAttestationFlow(); |
252 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 243 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
253 base::RunLoop().RunUntilIdle(); | 244 base::RunLoop().RunUntilIdle(); |
254 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); | 245 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); |
255 EXPECT_EQ(kTestResponse, challenge_response_); | 246 EXPECT_EQ(kTestResponse, challenge_response_); |
256 EXPECT_EQ(kTestCertificate, certificate_); | 247 EXPECT_EQ(kTestCertificate, certificate_); |
257 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); | 248 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); |
258 } | 249 } |
259 | 250 |
260 TEST_F(PlatformVerificationFlowTest, SuccessWithAlwaysAskConsent) { | 251 TEST_F(PlatformVerificationFlowTest, SuccessWithAttestationConsent) { |
261 fake_delegate_.set_always_ask_required(true); | 252 fake_cryptohome_client_.set_attestation_enrolled(false); |
262 ExpectAttestationFlow(); | 253 ExpectAttestationFlow(); |
263 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 254 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
264 base::RunLoop().RunUntilIdle(); | 255 base::RunLoop().RunUntilIdle(); |
265 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); | 256 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); |
266 EXPECT_EQ(kTestResponse, challenge_response_); | 257 EXPECT_EQ(kTestResponse, challenge_response_); |
267 EXPECT_EQ(kTestCertificate, certificate_); | 258 EXPECT_EQ(kTestCertificate, certificate_); |
268 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); | 259 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); |
269 } | 260 } |
270 | 261 |
271 TEST_F(PlatformVerificationFlowTest, SuccessWithAttestationConsent) { | 262 TEST_F(PlatformVerificationFlowTest, SuccessWithFirstTimeConsent) { |
272 fake_cryptohome_client_.set_attestation_enrolled(false); | 263 pref_service_.SetUserPref(prefs::kRAConsentFirstTime, |
| 264 new base::FundamentalValue(false)); |
273 ExpectAttestationFlow(); | 265 ExpectAttestationFlow(); |
274 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 266 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
275 base::RunLoop().RunUntilIdle(); | 267 base::RunLoop().RunUntilIdle(); |
276 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); | 268 EXPECT_EQ(PlatformVerificationFlow::SUCCESS, result_); |
277 EXPECT_EQ(kTestResponse, challenge_response_); | 269 EXPECT_EQ(kTestResponse, challenge_response_); |
278 EXPECT_EQ(kTestCertificate, certificate_); | 270 EXPECT_EQ(kTestCertificate, certificate_); |
279 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); | 271 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); |
280 } | 272 } |
281 | 273 |
282 TEST_F(PlatformVerificationFlowTest, ConsentRejected) { | 274 TEST_F(PlatformVerificationFlowTest, ConsentRejected) { |
283 fake_delegate_.set_always_ask_required(true); | 275 pref_service_.SetUserPref(prefs::kRAConsentAlways, |
| 276 new base::FundamentalValue(true)); |
284 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY); | 277 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_DENY); |
285 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 278 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
286 base::RunLoop().RunUntilIdle(); | 279 base::RunLoop().RunUntilIdle(); |
287 EXPECT_EQ(PlatformVerificationFlow::USER_REJECTED, result_); | 280 EXPECT_EQ(PlatformVerificationFlow::USER_REJECTED, result_); |
288 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); | 281 EXPECT_EQ(1, fake_delegate_.num_consent_calls()); |
289 } | 282 } |
290 | 283 |
291 TEST_F(PlatformVerificationFlowTest, FeatureDisabled) { | 284 TEST_F(PlatformVerificationFlowTest, FeatureDisabled) { |
292 fake_delegate_.set_attestation_disabled(true); | 285 CrosSettings::Get()->SetBoolean(kAttestationForContentProtectionEnabled, |
| 286 false); |
293 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 287 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
294 base::RunLoop().RunUntilIdle(); | 288 base::RunLoop().RunUntilIdle(); |
295 EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_); | 289 EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_); |
| 290 EXPECT_EQ(0, fake_delegate_.num_consent_calls()); |
| 291 } |
| 292 |
| 293 TEST_F(PlatformVerificationFlowTest, FeatureDisabledByUser) { |
| 294 pref_service_.SetUserPref(prefs::kEnableDRM, |
| 295 new base::FundamentalValue(false)); |
| 296 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
| 297 base::RunLoop().RunUntilIdle(); |
| 298 EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_); |
| 299 EXPECT_EQ(0, fake_delegate_.num_consent_calls()); |
| 300 } |
| 301 |
| 302 TEST_F(PlatformVerificationFlowTest, FeatureDisabledByUserForDomain) { |
| 303 base::DictionaryValue* domains = new base::DictionaryValue(); |
| 304 domains->SetBoolean(kTestDomain, false); |
| 305 pref_service_.SetUserPref(prefs::kRAConsentDomains, domains); |
| 306 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
| 307 base::RunLoop().RunUntilIdle(); |
| 308 EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_); |
296 EXPECT_EQ(0, fake_delegate_.num_consent_calls()); | 309 EXPECT_EQ(0, fake_delegate_.num_consent_calls()); |
297 } | 310 } |
298 | 311 |
299 TEST_F(PlatformVerificationFlowTest, NotVerified) { | 312 TEST_F(PlatformVerificationFlowTest, NotVerified) { |
300 certificate_success_ = false; | 313 certificate_success_ = false; |
301 ExpectAttestationFlow(); | 314 ExpectAttestationFlow(); |
302 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 315 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
303 base::RunLoop().RunUntilIdle(); | 316 base::RunLoop().RunUntilIdle(); |
304 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_); | 317 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_); |
305 } | 318 } |
306 | 319 |
307 TEST_F(PlatformVerificationFlowTest, ChallengeSigningError) { | 320 TEST_F(PlatformVerificationFlowTest, ChallengeSigningError) { |
308 sign_challenge_success_ = false; | 321 sign_challenge_success_ = false; |
309 ExpectAttestationFlow(); | 322 ExpectAttestationFlow(); |
310 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 323 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
311 base::RunLoop().RunUntilIdle(); | 324 base::RunLoop().RunUntilIdle(); |
312 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_); | 325 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_); |
313 } | 326 } |
314 | 327 |
315 TEST_F(PlatformVerificationFlowTest, DBusFailure) { | 328 TEST_F(PlatformVerificationFlowTest, DBusFailure) { |
316 fake_cryptohome_client_.set_call_status(DBUS_METHOD_CALL_FAILURE); | 329 fake_cryptohome_client_.set_call_status(DBUS_METHOD_CALL_FAILURE); |
317 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 330 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
318 base::RunLoop().RunUntilIdle(); | 331 base::RunLoop().RunUntilIdle(); |
319 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_); | 332 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_); |
320 } | 333 } |
321 | 334 |
322 TEST_F(PlatformVerificationFlowTest, UpdateSettingsFailure) { | |
323 fake_delegate_.set_origin_consent_required(true); | |
324 fake_delegate_.set_update_settings_result(false); | |
325 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | |
326 base::RunLoop().RunUntilIdle(); | |
327 EXPECT_EQ(PlatformVerificationFlow::INTERNAL_ERROR, result_); | |
328 } | |
329 | |
330 TEST_F(PlatformVerificationFlowTest, ConsentNoResponse) { | 335 TEST_F(PlatformVerificationFlowTest, ConsentNoResponse) { |
331 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_NONE); | 336 fake_delegate_.set_response(PlatformVerificationFlow::CONSENT_RESPONSE_NONE); |
332 fake_delegate_.set_origin_consent_required(true); | 337 pref_service_.SetUserPref(prefs::kRAConsentAlways, |
| 338 new base::FundamentalValue(true)); |
333 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 339 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
334 base::RunLoop().RunUntilIdle(); | 340 base::RunLoop().RunUntilIdle(); |
335 EXPECT_EQ(PlatformVerificationFlow::USER_REJECTED, result_); | 341 EXPECT_EQ(PlatformVerificationFlow::USER_REJECTED, result_); |
336 } | 342 } |
337 | 343 |
338 } // namespace attestation | 344 } // namespace attestation |
339 } // namespace chromeos | 345 } // namespace chromeos |
OLD | NEW |