Index: components/safe_browsing/password_protection/password_protection_service_unittest.cc |
diff --git a/components/safe_browsing/password_protection/password_protection_service_unittest.cc b/components/safe_browsing/password_protection/password_protection_service_unittest.cc |
index 547f23ceb98afa52e9009b37672e39f46e1c9119..89995be2c8a723120060a2a615b91d21ecbea308 100644 |
--- a/components/safe_browsing/password_protection/password_protection_service_unittest.cc |
+++ b/components/safe_browsing/password_protection/password_protection_service_unittest.cc |
@@ -367,7 +367,7 @@ TEST_F(PasswordProtectionServiceTest, TestGetCachedVerdicts) { |
GURL("http://test.com/def/ghi/index.html"), &actual_verdict)); |
} |
-TEST_F(PasswordProtectionServiceTest, TestCleanUpCachedVerdicts) { |
+TEST_F(PasswordProtectionServiceTest, TestRemoveCachedVerdictOnURLsDeleted) { |
ASSERT_EQ(0U, GetStoredVerdictCount()); |
// Prepare 2 verdicts. One is for origin "http://foo.com", and the other is |
// for "http://bar.com". |
@@ -403,6 +403,7 @@ TEST_F(PasswordProtectionServiceTest, TestCleanUpCachedVerdicts) { |
true /* all_history */, history::URLRows()); |
EXPECT_EQ(0U, GetStoredVerdictCount()); |
} |
+ |
TEST_F(PasswordProtectionServiceTest, |
TestNoRequestCreatedIfMainFrameURLIsNotValid) { |
ASSERT_EQ(0u, password_protection_service_->GetPendingRequestsCount()); |
@@ -538,4 +539,43 @@ TEST_F(PasswordProtectionServiceTest, TestTearDownWithPendingRequests) { |
EXPECT_THAT(histograms_.GetAllSamples(kRequestOutcomeHistogramName), |
testing::ElementsAre(base::Bucket(2 /* CANCELED */, 1))); |
} |
+ |
+TEST_F(PasswordProtectionServiceTest, TestCleanUpExpiredVerdict) { |
+ ASSERT_EQ(0U, GetStoredVerdictCount()); |
+ // Prepare 4 verdicts: |
+ // (1) "foo.com/abc" valid |
+ // (2) "foo.com/def" expired |
+ // (3) "bar.com/abc" expired |
+ // (4) "bar.com/def" expired |
+ base::Time now = base::Time::Now(); |
+ CacheVerdict(GURL("https://foo.com/abc/index.jsp"), |
+ LoginReputationClientResponse::LOW_REPUTATION, 10 * 60, |
+ "foo.com/abc", now); |
+ CacheVerdict(GURL("https://foo.com/def/index.jsp"), |
+ LoginReputationClientResponse::LOW_REPUTATION, 0, "foo.com/def", |
+ now); |
+ CacheVerdict(GURL("https://bar.com/abc/index.jsp"), |
+ LoginReputationClientResponse::PHISHING, 0, "bar.com/abc", now); |
+ CacheVerdict(GURL("https://bar.com/def/index.jsp"), |
+ LoginReputationClientResponse::PHISHING, 0, "bar.com/def", now); |
+ ASSERT_EQ(4U, GetStoredVerdictCount()); |
+ |
+ password_protection_service_->CleanUpExpiredVerdicts(); |
+ |
+ ASSERT_EQ(1U, GetStoredVerdictCount()); |
+ LoginReputationClientResponse actual_verdict; |
+ // Has cached verdict for foo.com/abc. |
+ EXPECT_EQ(LoginReputationClientResponse::LOW_REPUTATION, |
+ password_protection_service_->GetCachedVerdict( |
+ GURL("https://foo.com/abc/test.jsp"), &actual_verdict)); |
+ // No cached verdict for foo.com/def. |
+ EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, |
+ password_protection_service_->GetCachedVerdict( |
+ GURL("https://foo.com/def/index.jsp"), &actual_verdict)); |
+ // Nothing in content setting for bar.com. |
+ EXPECT_EQ(nullptr, content_setting_map_->GetWebsiteSetting( |
+ GURL("https://bar.com"), GURL(), |
+ CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, |
+ std::string(), nullptr)); |
+} |
} // namespace safe_browsing |