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

Side by Side Diff: components/password_manager/content/browser/credential_manager_impl_unittest.cc

Issue 2127533003: Remove PasswordForm::ssl_valid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust //ios Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/password_manager/content/browser/credential_manager_impl.h" 5 #include "components/password_manager/content/browser/credential_manager_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 NavigateAndCommit(GURL("https://example.com/test.html")); 217 NavigateAndCommit(GURL("https://example.com/test.html"));
218 218
219 form_.username_value = base::ASCIIToUTF16("Username"); 219 form_.username_value = base::ASCIIToUTF16("Username");
220 form_.display_name = base::ASCIIToUTF16("Display Name"); 220 form_.display_name = base::ASCIIToUTF16("Display Name");
221 form_.icon_url = GURL("https://example.com/icon.png"); 221 form_.icon_url = GURL("https://example.com/icon.png");
222 form_.password_value = base::ASCIIToUTF16("Password"); 222 form_.password_value = base::ASCIIToUTF16("Password");
223 form_.origin = web_contents()->GetLastCommittedURL().GetOrigin(); 223 form_.origin = web_contents()->GetLastCommittedURL().GetOrigin();
224 form_.signon_realm = form_.origin.spec(); 224 form_.signon_realm = form_.origin.spec();
225 form_.scheme = autofill::PasswordForm::SCHEME_HTML; 225 form_.scheme = autofill::PasswordForm::SCHEME_HTML;
226 form_.skip_zero_click = false; 226 form_.skip_zero_click = false;
227 form_.ssl_valid = true;
228 227
229 affiliated_form1_.username_value = base::ASCIIToUTF16("Affiliated 1"); 228 affiliated_form1_.username_value = base::ASCIIToUTF16("Affiliated 1");
230 affiliated_form1_.display_name = base::ASCIIToUTF16("Display Name"); 229 affiliated_form1_.display_name = base::ASCIIToUTF16("Display Name");
231 affiliated_form1_.password_value = base::ASCIIToUTF16("Password"); 230 affiliated_form1_.password_value = base::ASCIIToUTF16("Password");
232 affiliated_form1_.origin = GURL(); 231 affiliated_form1_.origin = GURL();
233 affiliated_form1_.signon_realm = kTestAndroidRealm1; 232 affiliated_form1_.signon_realm = kTestAndroidRealm1;
234 affiliated_form1_.scheme = autofill::PasswordForm::SCHEME_HTML; 233 affiliated_form1_.scheme = autofill::PasswordForm::SCHEME_HTML;
235 affiliated_form1_.skip_zero_click = false; 234 affiliated_form1_.skip_zero_click = false;
236 affiliated_form1_.ssl_valid = true;
237 235
238 affiliated_form2_.username_value = base::ASCIIToUTF16("Affiliated 2"); 236 affiliated_form2_.username_value = base::ASCIIToUTF16("Affiliated 2");
239 affiliated_form2_.display_name = base::ASCIIToUTF16("Display Name"); 237 affiliated_form2_.display_name = base::ASCIIToUTF16("Display Name");
240 affiliated_form2_.password_value = base::ASCIIToUTF16("Password"); 238 affiliated_form2_.password_value = base::ASCIIToUTF16("Password");
241 affiliated_form2_.origin = GURL(); 239 affiliated_form2_.origin = GURL();
242 affiliated_form2_.signon_realm = kTestAndroidRealm2; 240 affiliated_form2_.signon_realm = kTestAndroidRealm2;
243 affiliated_form2_.scheme = autofill::PasswordForm::SCHEME_HTML; 241 affiliated_form2_.scheme = autofill::PasswordForm::SCHEME_HTML;
244 affiliated_form2_.skip_zero_click = false; 242 affiliated_form2_.skip_zero_click = false;
245 affiliated_form2_.ssl_valid = true;
246 243
247 origin_path_form_.username_value = base::ASCIIToUTF16("Username 2"); 244 origin_path_form_.username_value = base::ASCIIToUTF16("Username 2");
248 origin_path_form_.display_name = base::ASCIIToUTF16("Display Name 2"); 245 origin_path_form_.display_name = base::ASCIIToUTF16("Display Name 2");
249 origin_path_form_.password_value = base::ASCIIToUTF16("Password 2"); 246 origin_path_form_.password_value = base::ASCIIToUTF16("Password 2");
250 origin_path_form_.origin = GURL("https://example.com/path"); 247 origin_path_form_.origin = GURL("https://example.com/path");
251 origin_path_form_.signon_realm = origin_path_form_.origin.spec(); 248 origin_path_form_.signon_realm = origin_path_form_.origin.spec();
252 origin_path_form_.scheme = autofill::PasswordForm::SCHEME_HTML; 249 origin_path_form_.scheme = autofill::PasswordForm::SCHEME_HTML;
253 origin_path_form_.skip_zero_click = false; 250 origin_path_form_.skip_zero_click = false;
254 251
255 subdomain_form_.username_value = base::ASCIIToUTF16("Username 2"); 252 subdomain_form_.username_value = base::ASCIIToUTF16("Username 2");
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 ExpectZeroClickSignInSuccess(true, true, federations, 1214 ExpectZeroClickSignInSuccess(true, true, federations,
1218 mojom::CredentialType::PASSWORD); 1215 mojom::CredentialType::PASSWORD);
1219 } 1216 }
1220 1217
1221 TEST_F(CredentialManagerImplTest, GetSynthesizedFormForOrigin) { 1218 TEST_F(CredentialManagerImplTest, GetSynthesizedFormForOrigin) {
1222 autofill::PasswordForm synthesized = 1219 autofill::PasswordForm synthesized =
1223 cm_service_impl_->GetSynthesizedFormForOrigin(); 1220 cm_service_impl_->GetSynthesizedFormForOrigin();
1224 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec()); 1221 EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec());
1225 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm); 1222 EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm);
1226 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme); 1223 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme);
1227 EXPECT_TRUE(synthesized.ssl_valid);
1228 } 1224 }
1229 1225
1230 TEST_F(CredentialManagerImplTest, BlacklistPasswordCredential) { 1226 TEST_F(CredentialManagerImplTest, BlacklistPasswordCredential) {
1231 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( 1227 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
1232 _, CredentialSourceType::CREDENTIAL_SOURCE_API)); 1228 _, CredentialSourceType::CREDENTIAL_SOURCE_API));
1233 1229
1234 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); 1230 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
1235 bool called = false; 1231 bool called = false;
1236 CallStore(info, base::Bind(&RespondCallback, &called)); 1232 CallStore(info, base::Bind(&RespondCallback, &called));
1237 // Allow the PasswordFormManager to talk to the password store 1233 // Allow the PasswordFormManager to talk to the password store
1238 RunAllPendingTasks(); 1234 RunAllPendingTasks();
1239 1235
1240 ASSERT_TRUE(client_->pending_manager()); 1236 ASSERT_TRUE(client_->pending_manager());
1241 client_->pending_manager()->PermanentlyBlacklist(); 1237 client_->pending_manager()->PermanentlyBlacklist();
1242 // Allow the PasswordFormManager to talk to the password store. 1238 // Allow the PasswordFormManager to talk to the password store.
1243 RunAllPendingTasks(); 1239 RunAllPendingTasks();
1244 1240
1245 // Verify that the site is blacklisted. 1241 // Verify that the site is blacklisted.
1246 autofill::PasswordForm blacklisted; 1242 autofill::PasswordForm blacklisted;
1247 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); 1243 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
1248 blacklisted.blacklisted_by_user = true; 1244 blacklisted.blacklisted_by_user = true;
1249 blacklisted.origin = form_.origin; 1245 blacklisted.origin = form_.origin;
1250 blacklisted.signon_realm = form_.signon_realm; 1246 blacklisted.signon_realm = form_.signon_realm;
1251 blacklisted.type = autofill::PasswordForm::TYPE_API; 1247 blacklisted.type = autofill::PasswordForm::TYPE_API;
1252 blacklisted.ssl_valid = true;
1253 blacklisted.date_created = passwords[form_.signon_realm][0].date_created; 1248 blacklisted.date_created = passwords[form_.signon_realm][0].date_created;
1254 EXPECT_THAT(passwords[form_.signon_realm], testing::ElementsAre(blacklisted)); 1249 EXPECT_THAT(passwords[form_.signon_realm], testing::ElementsAre(blacklisted));
1255 } 1250 }
1256 1251
1257 TEST_F(CredentialManagerImplTest, BlacklistFederatedCredential) { 1252 TEST_F(CredentialManagerImplTest, BlacklistFederatedCredential) {
1258 form_.federation_origin = url::Origin(GURL("https://example.com/")); 1253 form_.federation_origin = url::Origin(GURL("https://example.com/"));
1259 form_.password_value = base::string16(); 1254 form_.password_value = base::string16();
1260 form_.signon_realm = "federation://example.com/example.com"; 1255 form_.signon_realm = "federation://example.com/example.com";
1261 1256
1262 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( 1257 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
(...skipping 10 matching lines...) Expand all
1273 RunAllPendingTasks(); 1268 RunAllPendingTasks();
1274 1269
1275 // Verify that the site is blacklisted. 1270 // Verify that the site is blacklisted.
1276 TestPasswordStore::PasswordMap passwords = store_->stored_passwords(); 1271 TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
1277 ASSERT_TRUE(passwords.count(form_.origin.spec())); 1272 ASSERT_TRUE(passwords.count(form_.origin.spec()));
1278 autofill::PasswordForm blacklisted; 1273 autofill::PasswordForm blacklisted;
1279 blacklisted.blacklisted_by_user = true; 1274 blacklisted.blacklisted_by_user = true;
1280 blacklisted.origin = form_.origin; 1275 blacklisted.origin = form_.origin;
1281 blacklisted.signon_realm = blacklisted.origin.spec(); 1276 blacklisted.signon_realm = blacklisted.origin.spec();
1282 blacklisted.type = autofill::PasswordForm::TYPE_API; 1277 blacklisted.type = autofill::PasswordForm::TYPE_API;
1283 blacklisted.ssl_valid = true;
1284 blacklisted.date_created = 1278 blacklisted.date_created =
1285 passwords[blacklisted.signon_realm][0].date_created; 1279 passwords[blacklisted.signon_realm][0].date_created;
1286 EXPECT_THAT(passwords[blacklisted.signon_realm], 1280 EXPECT_THAT(passwords[blacklisted.signon_realm],
1287 testing::ElementsAre(blacklisted)); 1281 testing::ElementsAre(blacklisted));
1288 } 1282 }
1289 1283
1290 TEST_F(CredentialManagerImplTest, RespectBlacklistingPasswordCredential) { 1284 TEST_F(CredentialManagerImplTest, RespectBlacklistingPasswordCredential) {
1291 autofill::PasswordForm blacklisted; 1285 autofill::PasswordForm blacklisted;
1292 blacklisted.blacklisted_by_user = true; 1286 blacklisted.blacklisted_by_user = true;
1293 blacklisted.origin = form_.origin; 1287 blacklisted.origin = form_.origin;
1294 blacklisted.signon_realm = blacklisted.origin.spec(); 1288 blacklisted.signon_realm = blacklisted.origin.spec();
1295 blacklisted.ssl_valid = true;
1296 store_->AddLogin(blacklisted); 1289 store_->AddLogin(blacklisted);
1297 1290
1298 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD); 1291 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
1299 bool called = false; 1292 bool called = false;
1300 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( 1293 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
1301 _, CredentialSourceType::CREDENTIAL_SOURCE_API)); 1294 _, CredentialSourceType::CREDENTIAL_SOURCE_API));
1302 CallStore(info, base::Bind(&RespondCallback, &called)); 1295 CallStore(info, base::Bind(&RespondCallback, &called));
1303 // Allow the PasswordFormManager to talk to the password store 1296 // Allow the PasswordFormManager to talk to the password store
1304 RunAllPendingTasks(); 1297 RunAllPendingTasks();
1305 1298
1306 ASSERT_TRUE(client_->pending_manager()); 1299 ASSERT_TRUE(client_->pending_manager());
1307 EXPECT_TRUE(client_->pending_manager()->IsBlacklisted()); 1300 EXPECT_TRUE(client_->pending_manager()->IsBlacklisted());
1308 } 1301 }
1309 1302
1310 TEST_F(CredentialManagerImplTest, RespectBlacklistingFederatedCredential) { 1303 TEST_F(CredentialManagerImplTest, RespectBlacklistingFederatedCredential) {
1311 autofill::PasswordForm blacklisted; 1304 autofill::PasswordForm blacklisted;
1312 blacklisted.blacklisted_by_user = true; 1305 blacklisted.blacklisted_by_user = true;
1313 blacklisted.origin = form_.origin; 1306 blacklisted.origin = form_.origin;
1314 blacklisted.signon_realm = blacklisted.origin.spec(); 1307 blacklisted.signon_realm = blacklisted.origin.spec();
1315 blacklisted.ssl_valid = true;
1316 store_->AddLogin(blacklisted); 1308 store_->AddLogin(blacklisted);
1317 1309
1318 form_.federation_origin = url::Origin(GURL("https://example.com/")); 1310 form_.federation_origin = url::Origin(GURL("https://example.com/"));
1319 form_.password_value = base::string16(); 1311 form_.password_value = base::string16();
1320 form_.signon_realm = "federation://example.com/example.com"; 1312 form_.signon_realm = "federation://example.com/example.com";
1321 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_FEDERATED); 1313 CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_FEDERATED);
1322 bool called = false; 1314 bool called = false;
1323 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr( 1315 EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
1324 _, CredentialSourceType::CREDENTIAL_SOURCE_API)); 1316 _, CredentialSourceType::CREDENTIAL_SOURCE_API));
1325 CallStore(info, base::Bind(&RespondCallback, &called)); 1317 CallStore(info, base::Bind(&RespondCallback, &called));
1326 // Allow the PasswordFormManager to talk to the password store 1318 // Allow the PasswordFormManager to talk to the password store
1327 RunAllPendingTasks(); 1319 RunAllPendingTasks();
1328 1320
1329 ASSERT_TRUE(client_->pending_manager()); 1321 ASSERT_TRUE(client_->pending_manager());
1330 EXPECT_TRUE(client_->pending_manager()->IsBlacklisted()); 1322 EXPECT_TRUE(client_->pending_manager()->IsBlacklisted());
1331 } 1323 }
1332 1324
1333 } // namespace password_manager 1325 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698