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

Unified Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 2721663002: Move Credentials when migrating to HSTS page (Closed)
Patch Set: Code Deduplication Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_manager_browsertest.cc
diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc
index 3598b357dac321f4dedaca92508ab9cb630e1f3c..2455723a5d5e7fa66c6820aef1dde3d4b0ee9e86 100644
--- a/chrome/browser/password_manager/password_manager_browsertest.cc
+++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -1511,6 +1511,48 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
CheckElementValue("password_field", "12345");
}
+// Tests that obsolete HTTP credentials are moved when a site migrated to HTTPS
+// and has HSTS enabled.
+IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
+ ObsoleteHttpCredentialMovedOnMigrationToHstsSite) {
+ // Add an http credential to the password store.
+ GURL https_origin = https_test_server().base_url();
+ ASSERT_TRUE(https_origin.SchemeIs(url::kHttpsScheme));
+ GURL::Replacements rep;
+ rep.SetSchemeStr(url::kHttpScheme);
+ GURL http_origin = https_origin.ReplaceComponents(rep);
+ autofill::PasswordForm http_form;
+ http_form.signon_realm = http_origin.spec();
+ http_form.origin = http_origin;
+ // Assume that the previous action was already HTTPS one matching the current
+ // page.
+ http_form.action = https_origin;
+ http_form.username_value = base::ASCIIToUTF16("user");
+ http_form.password_value = base::ASCIIToUTF16("12345");
+ scoped_refptr<password_manager::TestPasswordStore> password_store =
+ static_cast<password_manager::TestPasswordStore*>(
+ PasswordStoreFactory::GetForProfile(
+ browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
+ .get());
+ password_store->AddLogin(http_form);
+
+ // Treat the host of the HTTPS test server as HSTS.
+ AddHSTSHost(https_test_server().host_port_pair().host());
+
+ // Navigate to HTTPS page and trigger the migration.
+ NavigationObserver form_observer(WebContents());
+ ui_test_utils::NavigateToURL(
+ browser(), https_test_server().GetURL("/password/password_form.html"));
+ form_observer.Wait();
+ WaitForPasswordStore();
+
+ // Only HTTPS passwords should be present.
+ EXPECT_TRUE(
+ password_store->stored_passwords().at(http_origin.spec()).empty());
+ EXPECT_FALSE(
+ password_store->stored_passwords().at(https_origin.spec()).empty());
+}
+
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
PromptWhenPasswordFormWithoutUsernameFieldSubmitted) {
scoped_refptr<password_manager::TestPasswordStore> password_store =

Powered by Google App Engine
This is Rietveld 408576698