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

Side by Side Diff: chrome/browser/password_manager/credential_manager_browsertest.cc

Issue 2759353004: Enable CredentialManagerBrowserTest.ObsoleteHttpCredentialMovedOnMigrationToHstsSite (Closed)
Patch Set: PasswordManagerBrowserTestBase.VerifyPasswordGenerationUpload 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 unified diff | Download patch
OLDNEW
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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/password_manager/password_manager_test_base.h" 8 #include "chrome/browser/password_manager/password_manager_test_base.h"
9 #include "chrome/browser/password_manager/password_store_factory.h" 9 #include "chrome/browser/password_manager/password_store_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 // There should be an entry for both psl.example.com and www.example.com. 156 // There should be an entry for both psl.example.com and www.example.com.
157 password_manager::TestPasswordStore::PasswordMap passwords = 157 password_manager::TestPasswordStore::PasswordMap passwords =
158 password_store->stored_passwords(); 158 password_store->stored_passwords();
159 GURL www_url = https_test_server().GetURL("www.example.com", "/"); 159 GURL www_url = https_test_server().GetURL("www.example.com", "/");
160 EXPECT_EQ(2U, passwords.size()); 160 EXPECT_EQ(2U, passwords.size());
161 EXPECT_TRUE(base::ContainsKey(passwords, psl_url.spec())); 161 EXPECT_TRUE(base::ContainsKey(passwords, psl_url.spec()));
162 EXPECT_TRUE(base::ContainsKey(passwords, www_url.spec())); 162 EXPECT_TRUE(base::ContainsKey(passwords, www_url.spec()));
163 } 163 }
164 164
165 // Flaky. See crbug.com/703305
166 IN_PROC_BROWSER_TEST_F(CredentialManagerBrowserTest, 165 IN_PROC_BROWSER_TEST_F(CredentialManagerBrowserTest,
167 DISABLED_ObsoleteHttpCredentialMovedOnMigrationToHstsSite) { 166 ObsoleteHttpCredentialMovedOnMigrationToHstsSite) {
168 // Add an http credential to the password store. 167 // Add an http credential to the password store.
169 GURL https_origin = https_test_server().base_url(); 168 GURL https_origin = https_test_server().base_url();
170 ASSERT_TRUE(https_origin.SchemeIs(url::kHttpsScheme)); 169 ASSERT_TRUE(https_origin.SchemeIs(url::kHttpsScheme));
171 GURL::Replacements rep; 170 GURL::Replacements rep;
172 rep.SetSchemeStr(url::kHttpScheme); 171 rep.SetSchemeStr(url::kHttpScheme);
173 GURL http_origin = https_origin.ReplaceComponents(rep); 172 GURL http_origin = https_origin.ReplaceComponents(rep);
174 autofill::PasswordForm http_form; 173 autofill::PasswordForm http_form;
175 http_form.signon_realm = http_origin.spec(); 174 http_form.signon_realm = http_origin.spec();
176 http_form.origin = http_origin; 175 http_form.origin = http_origin;
177 http_form.username_value = base::ASCIIToUTF16("user"); 176 http_form.username_value = base::ASCIIToUTF16("user");
178 http_form.password_value = base::ASCIIToUTF16("12345"); 177 http_form.password_value = base::ASCIIToUTF16("12345");
179 scoped_refptr<password_manager::TestPasswordStore> password_store = 178 scoped_refptr<password_manager::TestPasswordStore> password_store =
180 static_cast<password_manager::TestPasswordStore*>( 179 static_cast<password_manager::TestPasswordStore*>(
181 PasswordStoreFactory::GetForProfile( 180 PasswordStoreFactory::GetForProfile(
182 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) 181 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
183 .get()); 182 .get());
184 password_store->AddLogin(http_form); 183 password_store->AddLogin(http_form);
185 WaitForPasswordStore(); 184 WaitForPasswordStore();
186 185
187 // Treat the host of the HTTPS test server as HSTS. 186 // Treat the host of the HTTPS test server as HSTS.
188 AddHSTSHost(https_test_server().host_port_pair().host()); 187 AddHSTSHost(https_test_server().host_port_pair().host());
189 188
190 // Navigate to HTTPS page and trigger the migration. 189 // Navigate to HTTPS page and trigger the migration.
191 ui_test_utils::NavigateToURL( 190 ui_test_utils::NavigateToURL(
192 browser(), https_test_server().GetURL("/password/done.html")); 191 browser(), https_test_server().GetURL("/password/done.html"));
193 192
194 // Call the API to trigger |get| and |store| and redirect. 193 // Call the API to trigger the account chooser.
195 ASSERT_TRUE(content::ExecuteScript( 194 ASSERT_TRUE(content::ExecuteScript(
196 RenderViewHost(), "navigator.credentials.get({password: true})")); 195 RenderViewHost(), "navigator.credentials.get({password: true})"));
196 BubbleObserver(WebContents()).WaitForAccountChooser();
197 197
198 // Issue the query for HTTPS credentials.
199 WaitForPasswordStore(); 198 WaitForPasswordStore();
vabr (Chromium) 2017/03/21 18:46:51 It would still be helpful to comment (in the code)
vasilii 2017/03/22 09:28:58 Done.
200
201 // Realize there are no HTTPS credentials and issue the query for HTTP
202 // credentials instead.
203 WaitForPasswordStore();
204
205 // Sync with IO thread before continuing. This is necessary, because the
206 // credential migration triggers a query for the HSTS state which gets
207 // executed on the IO thread. The actual task is empty, because only the reply
208 // is relevant. By the time the reply is executed it is guaranteed that the
209 // migration is completed.
210 const auto empty_lambda = []() {};
211 base::RunLoop run_loop;
212 content::BrowserThread::PostTaskAndReply(content::BrowserThread::IO,
213 FROM_HERE, base::Bind(empty_lambda),
214 run_loop.QuitClosure());
215 run_loop.Run();
216
217 // Only HTTPS passwords should be present. 199 // Only HTTPS passwords should be present.
218 EXPECT_TRUE( 200 EXPECT_TRUE(
219 password_store->stored_passwords().at(http_origin.spec()).empty()); 201 password_store->stored_passwords().at(http_origin.spec()).empty());
220 EXPECT_FALSE( 202 EXPECT_FALSE(
221 password_store->stored_passwords().at(https_origin.spec()).empty()); 203 password_store->stored_passwords().at(https_origin.spec()).empty());
222 } 204 }
223 205
224 IN_PROC_BROWSER_TEST_F(CredentialManagerBrowserTest, 206 IN_PROC_BROWSER_TEST_F(CredentialManagerBrowserTest,
225 AutoSigninOldCredentialAndNavigation) { 207 AutoSigninOldCredentialAndNavigation) {
226 // Save credentials with 'skip_zero_click' false. 208 // Save credentials with 'skip_zero_click' false.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 signin_form.skip_zero_click = false; 329 signin_form.skip_zero_click = false;
348 signin_form.times_used = 1; 330 signin_form.times_used = 1;
349 signin_form.password_value = base::ASCIIToUTF16("API"); 331 signin_form.password_value = base::ASCIIToUTF16("API");
350 password_manager::TestPasswordStore::PasswordMap stored = 332 password_manager::TestPasswordStore::PasswordMap stored =
351 password_store->stored_passwords(); 333 password_store->stored_passwords();
352 ASSERT_EQ(1u, stored.size()); 334 ASSERT_EQ(1u, stored.size());
353 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); 335 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]);
354 } 336 }
355 337
356 } // namespace 338 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698