OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/safe_browsing/certificate_reporting_service.h" | 5 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
11 #include "base/test/simple_test_clock.h" | 11 #include "base/test/simple_test_clock.h" |
12 #include "base/test/thread_test_helper.h" | 12 #include "base/test/thread_test_helper.h" |
13 #include "base/time/clock.h" | 13 #include "base/time/clock.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" | 17 #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" |
18 #include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils.
h" | 18 #include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils.
h" |
| 19 #include "chrome/browser/ssl/cert_report_helper.h" |
19 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" | 20 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
25 #include "components/certificate_reporting/error_report.h" | 26 #include "components/certificate_reporting/error_report.h" |
26 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
27 #include "components/variations/variations_switches.h" | 28 #include "components/variations/variations_switches.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
(...skipping 29 matching lines...) Expand all Loading... |
58 // reports. Each test triggers reports by visiting broken SSL pages. The reports | 59 // reports. Each test triggers reports by visiting broken SSL pages. The reports |
59 // succeed, fail or hang indefinitely: | 60 // succeed, fail or hang indefinitely: |
60 // - If a report is expected to fail or succeed, the test waits for the | 61 // - If a report is expected to fail or succeed, the test waits for the |
61 // corresponding URL request jobs to be destroyed. | 62 // corresponding URL request jobs to be destroyed. |
62 // - If a report is expected to hang, the test waits for the corresponding URL | 63 // - If a report is expected to hang, the test waits for the corresponding URL |
63 // request job to be created. Only after resuming the hung request job the | 64 // request job to be created. Only after resuming the hung request job the |
64 // test waits for the request to be destroyed. | 65 // test waits for the request to be destroyed. |
65 class CertificateReportingServiceBrowserTest : public InProcessBrowserTest { | 66 class CertificateReportingServiceBrowserTest : public InProcessBrowserTest { |
66 public: | 67 public: |
67 CertificateReportingServiceBrowserTest() | 68 CertificateReportingServiceBrowserTest() |
68 : https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} | 69 : https_server_(net::EmbeddedTestServer::TYPE_HTTPS) { |
| 70 CertReportHelper::SetFakeOfficialBuildForTesting(); |
| 71 } |
69 | 72 |
70 void SetUpOnMainThread() override { | 73 void SetUpOnMainThread() override { |
71 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 74 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
72 host_resolver()->AddRule("*", "127.0.0.1"); | 75 host_resolver()->AddRule("*", "127.0.0.1"); |
73 | 76 |
74 https_server_.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); | 77 https_server_.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); |
75 https_server_.ServeFilesFromSourceDirectory("chrome/test/data"); | 78 https_server_.ServeFilesFromSourceDirectory("chrome/test/data"); |
76 ASSERT_TRUE(https_server_.Start()); | 79 ASSERT_TRUE(https_server_.Start()); |
77 | 80 |
78 test_helper()->SetUpInterceptor(); | 81 test_helper()->SetUpInterceptor(); |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 test_helper()->WaitForRequestsCreated( | 613 test_helper()->WaitForRequestsCreated( |
611 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); | 614 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); |
612 | 615 |
613 // Resume the delayed report and wait for it to complete. | 616 // Resume the delayed report and wait for it to complete. |
614 test_helper()->ResumeDelayedRequest(); | 617 test_helper()->ResumeDelayedRequest(); |
615 test_helper()->WaitForRequestsDestroyed( | 618 test_helper()->WaitForRequestsDestroyed( |
616 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); | 619 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); |
617 } | 620 } |
618 | 621 |
619 } // namespace safe_browsing | 622 } // namespace safe_browsing |
OLD | NEW |