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

Side by Side Diff: components/password_manager/core/browser/login_database_unittest.cc

Issue 2909283002: Delete PasswordStoreMac and SimplePasswordStoreMac. (Closed)
Patch Set: test Created 3 years, 6 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/core/browser/login_database.h" 5 #include "components/password_manager/core/browser/login_database.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 testing::ElementsAre(base::Bucket(2, 1), base::Bucket(3, 2))); 1643 testing::ElementsAre(base::Bucket(2, 1), base::Bucket(3, 2)));
1644 EXPECT_THAT(histogram_tester.GetAllSamples( 1644 EXPECT_THAT(histogram_tester.GetAllSamples(
1645 kPrefix + "FromHttpsRealm.OnHttpsRealmWithDifferentHost"), 1645 kPrefix + "FromHttpsRealm.OnHttpsRealmWithDifferentHost"),
1646 testing::ElementsAre(base::Bucket(1, 2), base::Bucket(2, 1))); 1646 testing::ElementsAre(base::Bucket(1, 2), base::Bucket(2, 1)));
1647 EXPECT_THAT(histogram_tester.GetAllSamples( 1647 EXPECT_THAT(histogram_tester.GetAllSamples(
1648 kPrefix + "FromHttpsRealm.OnAnyRealmWithDifferentHost"), 1648 kPrefix + "FromHttpsRealm.OnAnyRealmWithDifferentHost"),
1649 testing::ElementsAre(base::Bucket(3, 1), base::Bucket(4, 1), 1649 testing::ElementsAre(base::Bucket(3, 1), base::Bucket(4, 1),
1650 base::Bucket(5, 1))); 1650 base::Bucket(5, 1)));
1651 } 1651 }
1652 1652
1653 TEST_F(LoginDatabaseTest, ClearPasswordValues) {
1654 db().set_clear_password_values(true);
1655
1656 // Add a PasswordForm, the password should be cleared.
1657 base::HistogramTester histogram_tester;
1658 PasswordForm form;
1659 form.origin = GURL("http://accounts.google.com/LoginAuth");
1660 form.signon_realm = "http://accounts.google.com/";
1661 form.username_value = ASCIIToUTF16("my_username");
1662 form.password_value = ASCIIToUTF16("12345");
1663 EXPECT_EQ(AddChangeForForm(form), db().AddLogin(form));
1664
1665 std::vector<std::unique_ptr<PasswordForm>> result;
1666 EXPECT_TRUE(db().GetLogins(PasswordStore::FormDigest(form), &result));
1667 ASSERT_EQ(1U, result.size());
1668 PasswordForm expected_form = form;
1669 expected_form.password_value.clear();
1670 EXPECT_EQ(expected_form, *result[0]);
1671
1672 // Update the password, it should stay empty.
1673 form.password_value = ASCIIToUTF16("password");
1674 EXPECT_EQ(UpdateChangeForForm(form), db().UpdateLogin(form));
1675 EXPECT_TRUE(db().GetLogins(PasswordStore::FormDigest(form), &result));
1676 ASSERT_EQ(1U, result.size());
1677 EXPECT_EQ(expected_form, *result[0]);
1678
1679 // Encrypting/decrypting shouldn't happen. Thus there should be no keychain
1680 // access on Mac.
1681 histogram_tester.ExpectTotalCount("OSX.Keychain.Access", 0);
1682 }
1683
1684 #if defined(OS_POSIX) 1653 #if defined(OS_POSIX)
1685 // Only the current user has permission to read the database. 1654 // Only the current user has permission to read the database.
1686 // 1655 //
1687 // Only POSIX because GetPosixFilePermissions() only exists on POSIX. 1656 // Only POSIX because GetPosixFilePermissions() only exists on POSIX.
1688 // This tests that sql::Connection::set_restrict_to_user() was called, 1657 // This tests that sql::Connection::set_restrict_to_user() was called,
1689 // and that function is a noop on non-POSIX platforms in any case. 1658 // and that function is a noop on non-POSIX platforms in any case.
1690 TEST_F(LoginDatabaseTest, FilePermissions) { 1659 TEST_F(LoginDatabaseTest, FilePermissions) {
1691 int mode = base::FILE_PERMISSION_MASK; 1660 int mode = base::FILE_PERMISSION_MASK;
1692 EXPECT_TRUE(base::GetPosixFilePermissions(file_, &mode)); 1661 EXPECT_TRUE(base::GetPosixFilePermissions(file_, &mode));
1693 EXPECT_EQ((mode & base::FILE_PERMISSION_USER_MASK), mode); 1662 EXPECT_EQ((mode & base::FILE_PERMISSION_USER_MASK), mode);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 LoginDatabaseMigrationTest, 1875 LoginDatabaseMigrationTest,
1907 testing::Range(1, kCurrentVersionNumber + 1)); 1876 testing::Range(1, kCurrentVersionNumber + 1));
1908 INSTANTIATE_TEST_CASE_P(MigrationToVCurrent, 1877 INSTANTIATE_TEST_CASE_P(MigrationToVCurrent,
1909 LoginDatabaseMigrationTestV9, 1878 LoginDatabaseMigrationTestV9,
1910 testing::Values(9)); 1879 testing::Values(9));
1911 INSTANTIATE_TEST_CASE_P(MigrationToVCurrent, 1880 INSTANTIATE_TEST_CASE_P(MigrationToVCurrent,
1912 LoginDatabaseMigrationTestBroken, 1881 LoginDatabaseMigrationTestBroken,
1913 testing::Range(1, 4)); 1882 testing::Range(1, 4));
1914 1883
1915 } // namespace password_manager 1884 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698