| 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/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h" | 10 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h" |
| 11 #include "chrome/browser/chromeos/attestation/fake_certificate.h" | 11 #include "chrome/browser/chromeos/attestation/fake_certificate.h" |
| 12 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" | 12 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" |
| 13 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 13 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
| 14 #include "chrome/browser/chromeos/settings/cros_settings.h" | 14 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 15 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 15 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 16 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" | 16 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" |
| 17 #include "chrome/browser/content_settings/host_content_settings_map.h" | 17 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 18 #include "chrome/browser/profiles/profile_impl.h" | 18 #include "chrome/browser/profiles/profile_impl.h" |
| 19 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h" | 19 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h" |
| 20 #include "chrome/common/content_settings_component.h" |
| 20 #include "chrome/common/content_settings_pattern.h" | 21 #include "chrome/common/content_settings_pattern.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/test/base/testing_pref_service_syncable.h" | 23 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 23 #include "chromeos/attestation/mock_attestation_flow.h" | 24 #include "chromeos/attestation/mock_attestation_flow.h" |
| 24 #include "chromeos/cryptohome/mock_async_method_caller.h" | 25 #include "chromeos/cryptohome/mock_async_method_caller.h" |
| 25 #include "chromeos/dbus/fake_cryptohome_client.h" | 26 #include "chromeos/dbus/fake_cryptohome_client.h" |
| 26 #include "chromeos/settings/cros_settings_names.h" | 27 #include "chromeos/settings/cros_settings_names.h" |
| 27 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 30 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 class PlatformVerificationFlowTest : public ::testing::Test { | 180 class PlatformVerificationFlowTest : public ::testing::Test { |
| 180 public: | 181 public: |
| 181 PlatformVerificationFlowTest() | 182 PlatformVerificationFlowTest() |
| 182 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 183 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 183 certificate_success_(true), | 184 certificate_success_(true), |
| 184 fake_certificate_index_(0), | 185 fake_certificate_index_(0), |
| 185 sign_challenge_success_(true), | 186 sign_challenge_success_(true), |
| 186 result_(PlatformVerificationFlow::INTERNAL_ERROR) {} | 187 result_(PlatformVerificationFlow::INTERNAL_ERROR) {} |
| 187 | 188 |
| 188 void SetUp() { | 189 void SetUp() { |
| 190 InitContentSettingsComponent(); |
| 189 fake_delegate_.SetUp(); | 191 fake_delegate_.SetUp(); |
| 190 | 192 |
| 191 // Create a verifier for tests to call. | 193 // Create a verifier for tests to call. |
| 192 verifier_ = new PlatformVerificationFlow(&mock_attestation_flow_, | 194 verifier_ = new PlatformVerificationFlow(&mock_attestation_flow_, |
| 193 &mock_async_caller_, | 195 &mock_async_caller_, |
| 194 &fake_cryptohome_client_, | 196 &fake_cryptohome_client_, |
| 195 &fake_delegate_); | 197 &fake_delegate_); |
| 196 | 198 |
| 197 // Create callbacks for tests to use with verifier_. | 199 // Create callbacks for tests to use with verifier_. |
| 198 callback_ = base::Bind(&PlatformVerificationFlowTest::FakeChallengeCallback, | 200 callback_ = base::Bind(&PlatformVerificationFlowTest::FakeChallengeCallback, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 474 |
| 473 TEST_F(PlatformVerificationFlowTest, IncognitoMode) { | 475 TEST_F(PlatformVerificationFlowTest, IncognitoMode) { |
| 474 fake_delegate_.set_is_incognito(true); | 476 fake_delegate_.set_is_incognito(true); |
| 475 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); | 477 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); |
| 476 base::RunLoop().RunUntilIdle(); | 478 base::RunLoop().RunUntilIdle(); |
| 477 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_); | 479 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_); |
| 478 } | 480 } |
| 479 | 481 |
| 480 } // namespace attestation | 482 } // namespace attestation |
| 481 } // namespace chromeos | 483 } // namespace chromeos |
| OLD | NEW |