Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: components/safe_browsing/password_protection/password_protection_service_unittest.cc

Issue 2811483002: Ensure password protection service can receive non http/s URLs (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/safe_browsing/password_protection/password_protection_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "components/safe_browsing/password_protection/password_protection_servi ce.h" 4 #include "components/safe_browsing/password_protection/password_protection_servi ce.h"
5 5
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "base/test/null_task_runner.h" 10 #include "base/test/null_task_runner.h"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 "foo.com/abc", false, now); 440 "foo.com/abc", false, now);
441 CacheVerdict(GURL("http://bar.com/index.jsp"), 441 CacheVerdict(GURL("http://bar.com/index.jsp"),
442 LoginReputationClientResponse::PHISHING, 10 * 60, "bar.com", 442 LoginReputationClientResponse::PHISHING, 10 * 60, "bar.com",
443 false, now); 443 false, now);
444 ASSERT_EQ(2U, GetStoredVerdictCount()); 444 ASSERT_EQ(2U, GetStoredVerdictCount());
445 445
446 // Delete a bar.com URL. Corresponding content setting keyed on 446 // Delete a bar.com URL. Corresponding content setting keyed on
447 // origin "http://bar.com" should be removed, 447 // origin "http://bar.com" should be removed,
448 history::URLRows deleted_urls; 448 history::URLRows deleted_urls;
449 deleted_urls.push_back(history::URLRow(GURL("http://bar.com"))); 449 deleted_urls.push_back(history::URLRow(GURL("http://bar.com")));
450
451 // Delete an arbitrary data URL, to ensure the service is robust against
452 // filtering only http/s URLs. See crbug.com/709758.
453 deleted_urls.push_back(history::URLRow(GURL("data:text/html, <p>hellow")));
454
450 password_protection_service_->RemoveContentSettingsOnURLsDeleted( 455 password_protection_service_->RemoveContentSettingsOnURLsDeleted(
451 false /* all_history */, deleted_urls); 456 false /* all_history */, deleted_urls);
452 EXPECT_EQ(1U, GetStoredVerdictCount()); 457 EXPECT_EQ(1U, GetStoredVerdictCount());
453 LoginReputationClientResponse actual_verdict; 458 LoginReputationClientResponse actual_verdict;
454 EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, 459 EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED,
455 password_protection_service_->GetCachedVerdict( 460 password_protection_service_->GetCachedVerdict(
456 GURL("http://bar.com"), &actual_verdict)); 461 GURL("http://bar.com"), &actual_verdict));
457 462
458 // If delete all history. All password protection content settings should be 463 // If delete all history. All password protection content settings should be
459 // gone. 464 // gone.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 target_url, LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); 599 target_url, LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE);
595 600
596 // Destroy password_protection_service_ while there is one request pending. 601 // Destroy password_protection_service_ while there is one request pending.
597 password_protection_service_.reset(); 602 password_protection_service_.reset();
598 base::RunLoop().RunUntilIdle(); 603 base::RunLoop().RunUntilIdle();
599 604
600 EXPECT_THAT(histograms_.GetAllSamples(kRequestOutcomeHistogramName), 605 EXPECT_THAT(histograms_.GetAllSamples(kRequestOutcomeHistogramName),
601 testing::ElementsAre(base::Bucket(2 /* CANCELED */, 1))); 606 testing::ElementsAre(base::Bucket(2 /* CANCELED */, 1)));
602 } 607 }
603 } // namespace safe_browsing 608 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing/password_protection/password_protection_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698