| 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 "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" | 17 #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" |
| 17 #include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils.
h" | 18 #include "chrome/browser/safe_browsing/certificate_reporting_service_test_utils.
h" |
| 18 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" | 19 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 24 #include "components/certificate_reporting/error_report.h" | 25 #include "components/certificate_reporting/error_report.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 ReportExpectation::Failed({{"report1", RetryStatus::NOT_RETRIED}})); | 378 ReportExpectation::Failed({{"report1", RetryStatus::NOT_RETRIED}})); |
| 378 | 379 |
| 379 // Queued report should now be successfully sent. | 380 // Queued report should now be successfully sent. |
| 380 test_helper()->SetFailureMode(certificate_reporting_test_utils:: | 381 test_helper()->SetFailureMode(certificate_reporting_test_utils:: |
| 381 ReportSendingResult::REPORTS_SUCCESSFUL); | 382 ReportSendingResult::REPORTS_SUCCESSFUL); |
| 382 SendPendingReports(); | 383 SendPendingReports(); |
| 383 test_helper()->WaitForRequestsDestroyed( | 384 test_helper()->WaitForRequestsDestroyed( |
| 384 ReportExpectation::Successful({{"report1", RetryStatus::RETRIED}})); | 385 ReportExpectation::Successful({{"report1", RetryStatus::RETRIED}})); |
| 385 } | 386 } |
| 386 | 387 |
| 388 // Failing on some Win and Mac buildbots. See crbug.com/719138. |
| 389 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 390 #define MAYBE_DontSendOldReports DISABLED_DontSendOldReports |
| 391 #else |
| 392 #define MAYBE_DontSendOldReports DontSendOldReports |
| 393 #endif |
| 387 // CertificateReportingService should ignore reports older than the report TTL. | 394 // CertificateReportingService should ignore reports older than the report TTL. |
| 388 IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, | 395 IN_PROC_BROWSER_TEST_F(CertificateReportingServiceBrowserTest, |
| 389 DontSendOldReports) { | 396 MAYBE_DontSendOldReports) { |
| 390 SetExpectedHistogramCountOnTeardown(5); | 397 SetExpectedHistogramCountOnTeardown(5); |
| 391 | 398 |
| 392 base::SimpleTestClock* clock = new base::SimpleTestClock(); | 399 base::SimpleTestClock* clock = new base::SimpleTestClock(); |
| 393 base::Time reference_time = base::Time::Now(); | 400 base::Time reference_time = base::Time::Now(); |
| 394 clock->SetNow(reference_time); | 401 clock->SetNow(reference_time); |
| 395 factory()->SetClockForTesting(std::unique_ptr<base::Clock>(clock)); | 402 factory()->SetClockForTesting(std::unique_ptr<base::Clock>(clock)); |
| 396 | 403 |
| 397 // The service should ignore reports older than 24 hours. | 404 // The service should ignore reports older than 24 hours. |
| 398 factory()->SetQueuedReportTTLForTesting(base::TimeDelta::FromHours(24)); | 405 factory()->SetQueuedReportTTLForTesting(base::TimeDelta::FromHours(24)); |
| 399 | 406 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 test_helper()->WaitForRequestsCreated( | 610 test_helper()->WaitForRequestsCreated( |
| 604 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); | 611 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); |
| 605 | 612 |
| 606 // Resume the delayed report and wait for it to complete. | 613 // Resume the delayed report and wait for it to complete. |
| 607 test_helper()->ResumeDelayedRequest(); | 614 test_helper()->ResumeDelayedRequest(); |
| 608 test_helper()->WaitForRequestsDestroyed( | 615 test_helper()->WaitForRequestsDestroyed( |
| 609 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); | 616 ReportExpectation::Delayed({{"report1", RetryStatus::NOT_RETRIED}})); |
| 610 } | 617 } |
| 611 | 618 |
| 612 } // namespace safe_browsing | 619 } // namespace safe_browsing |
| OLD | NEW |