| Index: components/password_manager/core/browser/password_store_unittest.cc
|
| diff --git a/components/password_manager/core/browser/password_store_unittest.cc b/components/password_manager/core/browser/password_store_unittest.cc
|
| index c47de36416f424e801517330dbc33d1750378122..2d79704e2ff06343e72b4d72235c4c286505a0b9 100644
|
| --- a/components/password_manager/core/browser/password_store_unittest.cc
|
| +++ b/components/password_manager/core/browser/password_store_unittest.cc
|
| @@ -59,6 +59,9 @@ const char kTestPSLMatchingWebRealm[] = "https://psl.example.com/";
|
| const char kTestPSLMatchingWebOrigin[] = "https://psl.example.com/origin";
|
| const char kTestUnrelatedWebRealm[] = "https://notexample.com/";
|
| const char kTestUnrelatedWebOrigin[] = "https:/notexample.com/origin";
|
| +const char kTestSameOrganizationNameWebRealm[] = "https://example.appspot.com/";
|
| +const char kTestSameOrganizationNameWebOrigin[] =
|
| + "https://example.appspot.com/origin";
|
| const char kTestInsecureWebRealm[] = "http://one.example.com/";
|
| const char kTestInsecureWebOrigin[] = "http://one.example.com/origin";
|
| const char kTestAndroidRealm1[] = "android://hash@com.example.android/";
|
| @@ -851,6 +854,61 @@ TEST_F(PasswordStoreTest, GetLoginsWithAffiliatedRealms) {
|
| }
|
| }
|
|
|
| +TEST_F(PasswordStoreTest, GetLoginsForSameOrganizationName) {
|
| + static const PasswordFormData kSameOrganizationCredentials[] = {
|
| + // Credential that is an exact match of the observed form.
|
| + {PasswordForm::SCHEME_HTML, kTestWebRealm1, kTestWebOrigin1, "", L"", L"",
|
| + L"", L"username_value_1", L"", true, 1},
|
| + // Credential that is a PSL match of the observed form.
|
| + {PasswordForm::SCHEME_HTML, kTestPSLMatchingWebRealm,
|
| + kTestPSLMatchingWebOrigin, "", L"", L"", L"", L"username_value_2", L"",
|
| + true, 1},
|
| + // Credential for the HTTP version of the observed form. (Should not be
|
| + // filled, but returned as part of same-organization-name matches).
|
| + {PasswordForm::SCHEME_HTML, kTestInsecureWebRealm, kTestInsecureWebOrigin,
|
| + "", L"", L"", L"", L"username_value_3", L"", true, 1},
|
| + // Credential for a signon realm with a different TLD, but same
|
| + // organization identifying name.
|
| + {PasswordForm::SCHEME_HTML, kTestSameOrganizationNameWebRealm,
|
| + kTestSameOrganizationNameWebOrigin, "", L"", L"", L"",
|
| + L"username_value_4", L"", true, 1},
|
| + };
|
| +
|
| + static const PasswordFormData kNotSameOrganizationCredentials[] = {
|
| + // Unrelated Web credential.
|
| + {PasswordForm::SCHEME_HTML, kTestUnrelatedWebRealm,
|
| + kTestUnrelatedWebOrigin, "", L"", L"", L"", L"username_value_5", L"",
|
| + true, 1},
|
| + // Credential for an affiliated Android application.
|
| + {PasswordForm::SCHEME_HTML, kTestAndroidRealm1, "", "", L"", L"", L"",
|
| + L"username_value_6", L"", true, 1}};
|
| +
|
| + scoped_refptr<PasswordStoreDefault> store(new PasswordStoreDefault(
|
| + base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
|
| + base::MakeUnique<LoginDatabase>(test_login_db_file_path())));
|
| + store->Init(syncer::SyncableService::StartSyncFlare(), nullptr);
|
| +
|
| + std::vector<std::unique_ptr<PasswordForm>> expected_results;
|
| + for (const auto& form_data : kSameOrganizationCredentials) {
|
| + expected_results.push_back(CreatePasswordFormFromDataForTesting(form_data));
|
| + store->AddLogin(*expected_results.back());
|
| + }
|
| +
|
| + for (const auto& form_data : kNotSameOrganizationCredentials) {
|
| + store->AddLogin(*CreatePasswordFormFromDataForTesting(form_data));
|
| + }
|
| +
|
| + const std::string observed_form_realm = kTestWebRealm1;
|
| + MockPasswordStoreConsumer mock_consumer;
|
| + EXPECT_CALL(mock_consumer,
|
| + OnGetPasswordStoreResultsConstRef(
|
| + UnorderedPasswordFormElementsAre(&expected_results)));
|
| + store->GetLoginsForSameOrganizationName(observed_form_realm, &mock_consumer);
|
| + base::RunLoop().RunUntilIdle();
|
| + store->ShutdownOnUIThread();
|
| + base::RunLoop().RunUntilIdle();
|
| +}
|
| +
|
| // TODO(crbug.com/706392): Fix password reuse detection for Android.
|
| #if !defined(OS_ANDROID) && !defined(OS_IOS)
|
| TEST_F(PasswordStoreTest, CheckPasswordReuse) {
|
|
|