Commit d77deebb authored by Irina Fedorova's avatar Irina Fedorova Committed by Commit Bot

Update CompromiseTypeFlags

This CL adds kWeakCredential flag to CompromiseTypeFlags enum and rename
it to InsecureCredentialTypeFlags. We need this changes because in the
feature we want to add passwords weakness check and use this enum.

Bug: 1119752
Change-Id: Ic27157ef119f9725b20d35507e371117ae95d51c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377720
Commit-Queue: Irina Fedorova <irfedorova@google.com>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802676}
parent 41f8db90
...@@ -56,8 +56,8 @@ namespace { ...@@ -56,8 +56,8 @@ namespace {
using autofill::PasswordForm; using autofill::PasswordForm;
using password_manager::CanonicalizeUsername; using password_manager::CanonicalizeUsername;
using password_manager::CompromiseTypeFlags;
using password_manager::CredentialWithPassword; using password_manager::CredentialWithPassword;
using password_manager::InsecureCredentialTypeFlags;
using password_manager::LeakCheckCredential; using password_manager::LeakCheckCredential;
using ui::TimeFormat; using ui::TimeFormat;
...@@ -72,6 +72,14 @@ std::unique_ptr<std::string> GetChangePasswordUrl(const GURL& url) { ...@@ -72,6 +72,14 @@ std::unique_ptr<std::string> GetChangePasswordUrl(const GURL& url) {
password_manager::CreateChangePasswordUrl(url).spec()); password_manager::CreateChangePasswordUrl(url).spec());
} }
// Unsets the bit responsible for the weak credential in the |flag|.
InsecureCredentialTypeFlags UnsetWeakCredentialTypeFlag(
InsecureCredentialTypeFlags flag) {
return static_cast<InsecureCredentialTypeFlags>(
static_cast<int>(flag) &
~(static_cast<int>(InsecureCredentialTypeFlags::kWeakCredential)));
}
} // namespace } // namespace
// Key used to attach UserData to a LeakCheckCredential. // Key used to attach UserData to a LeakCheckCredential.
...@@ -194,8 +202,10 @@ std::vector<CompromisedCredentialAndType> OrderCompromisedCredentials( ...@@ -194,8 +202,10 @@ std::vector<CompromisedCredentialAndType> OrderCompromisedCredentials(
std::vector<CompromisedCredentialAndType> results; std::vector<CompromisedCredentialAndType> results;
results.reserve(compromised_credentials.size()); results.reserve(compromised_credentials.size());
for (auto& credential : compromised_credentials) { for (auto& credential : compromised_credentials) {
// Since CompromiseType does not contain information about weakness of
// credential, we need to unset this bit in the |credential.insecure_type|.
auto type = static_cast<api::passwords_private::CompromiseType>( auto type = static_cast<api::passwords_private::CompromiseType>(
credential.compromise_type); UnsetWeakCredentialTypeFlag(credential.insecure_type));
results.push_back({std::move(credential), type}); results.push_back({std::move(credential), type});
} }
// Reordering phished credential to the beginning. // Reordering phished credential to the beginning.
......
...@@ -75,7 +75,7 @@ using password_manager::BulkLeakCheckDelegateInterface; ...@@ -75,7 +75,7 @@ using password_manager::BulkLeakCheckDelegateInterface;
using password_manager::BulkLeakCheckService; using password_manager::BulkLeakCheckService;
using password_manager::CompromisedCredentials; using password_manager::CompromisedCredentials;
using password_manager::CompromiseType; using password_manager::CompromiseType;
using password_manager::CompromiseTypeFlags; using password_manager::InsecureCredentialTypeFlags;
using password_manager::IsLeaked; using password_manager::IsLeaked;
using password_manager::LeakCheckCredential; using password_manager::LeakCheckCredential;
using password_manager::TestPasswordStore; using password_manager::TestPasswordStore;
...@@ -264,21 +264,21 @@ class PasswordCheckDelegateTest : public ::testing::Test { ...@@ -264,21 +264,21 @@ class PasswordCheckDelegateTest : public ::testing::Test {
TEST_F(PasswordCheckDelegateTest, VerifyCastingOfCompromisedCredentialTypes) { TEST_F(PasswordCheckDelegateTest, VerifyCastingOfCompromisedCredentialTypes) {
static_assert( static_assert(
static_cast<int>(api::passwords_private::COMPROMISE_TYPE_NONE) == static_cast<int>(api::passwords_private::COMPROMISE_TYPE_NONE) ==
static_cast<int>(CompromiseTypeFlags::kNotCompromised), static_cast<int>(InsecureCredentialTypeFlags::kSecure),
""); "");
static_assert( static_assert(
static_cast<int>(api::passwords_private::COMPROMISE_TYPE_LEAKED) == static_cast<int>(api::passwords_private::COMPROMISE_TYPE_LEAKED) ==
static_cast<int>(CompromiseTypeFlags::kCredentialLeaked), static_cast<int>(InsecureCredentialTypeFlags::kCredentialLeaked),
""); "");
static_assert( static_assert(
static_cast<int>(api::passwords_private::COMPROMISE_TYPE_PHISHED) == static_cast<int>(api::passwords_private::COMPROMISE_TYPE_PHISHED) ==
static_cast<int>(CompromiseTypeFlags::kCredentialPhished), static_cast<int>(InsecureCredentialTypeFlags::kCredentialPhished),
""); "");
static_assert( static_assert(
static_cast<int>( static_cast<int>(
api::passwords_private::COMPROMISE_TYPE_PHISHED_AND_LEAKED) == api::passwords_private::COMPROMISE_TYPE_PHISHED_AND_LEAKED) ==
static_cast<int>(CompromiseTypeFlags::kCredentialLeaked | static_cast<int>(InsecureCredentialTypeFlags::kCredentialLeaked |
CompromiseTypeFlags::kCredentialPhished), InsecureCredentialTypeFlags::kCredentialPhished),
""); "");
} }
......
...@@ -86,10 +86,10 @@ void PasswordCheckBridge::GetCompromisedCredentials( ...@@ -86,10 +86,10 @@ void PasswordCheckBridge::GetCompromisedCredentials(
credential.change_password_url), credential.change_password_url),
base::android::ConvertUTF8ToJavaString(env, credential.package_name), base::android::ConvertUTF8ToJavaString(env, credential.package_name),
credential.create_time.ToJavaTime(), credential.create_time.ToJavaTime(),
(credential.compromise_type == (credential.insecure_type ==
password_manager::CompromiseTypeFlags::kCredentialLeaked), password_manager::InsecureCredentialTypeFlags::kCredentialLeaked),
(credential.compromise_type == (credential.insecure_type ==
password_manager::CompromiseTypeFlags::kCredentialPhished), password_manager::InsecureCredentialTypeFlags::kCredentialPhished),
credential.has_script); credential.has_script);
} }
} }
......
...@@ -40,6 +40,7 @@ using autofill::PasswordForm; ...@@ -40,6 +40,7 @@ using autofill::PasswordForm;
using password_manager::BulkLeakCheckService; using password_manager::BulkLeakCheckService;
using password_manager::CompromisedCredentials; using password_manager::CompromisedCredentials;
using password_manager::CompromiseType; using password_manager::CompromiseType;
using password_manager::InsecureCredentialTypeFlags;
using password_manager::PasswordCheckUIStatus; using password_manager::PasswordCheckUIStatus;
using password_manager::TestPasswordStore; using password_manager::TestPasswordStore;
using password_manager::prefs::kLastTimePasswordCheckCompleted; using password_manager::prefs::kLastTimePasswordCheckCompleted;
...@@ -54,7 +55,6 @@ using testing::Return; ...@@ -54,7 +55,6 @@ using testing::Return;
using CompromisedCredentialForUI = using CompromisedCredentialForUI =
PasswordCheckManager::CompromisedCredentialForUI; PasswordCheckManager::CompromisedCredentialForUI;
using CompromiseTypeFlags = password_manager::CompromiseTypeFlags;
using State = password_manager::BulkLeakCheckService::State; using State = password_manager::BulkLeakCheckService::State;
namespace { namespace {
...@@ -187,7 +187,7 @@ auto ExpectCompromisedCredentialForUI( ...@@ -187,7 +187,7 @@ auto ExpectCompromisedCredentialForUI(
const base::string16& display_origin, const base::string16& display_origin,
const base::Optional<std::string>& package_name, const base::Optional<std::string>& package_name,
const base::Optional<std::string>& change_password_url, const base::Optional<std::string>& change_password_url,
CompromiseTypeFlags compromise_type, InsecureCredentialTypeFlags insecure_type,
bool has_script) { bool has_script) {
auto package_name_field_matcher = auto package_name_field_matcher =
package_name.has_value() package_name.has_value()
...@@ -203,7 +203,7 @@ auto ExpectCompromisedCredentialForUI( ...@@ -203,7 +203,7 @@ auto ExpectCompromisedCredentialForUI(
Field(&CompromisedCredentialForUI::display_username, display_username), Field(&CompromisedCredentialForUI::display_username, display_username),
Field(&CompromisedCredentialForUI::display_origin, display_origin), Field(&CompromisedCredentialForUI::display_origin, display_origin),
package_name_field_matcher, change_password_url_field_matcher, package_name_field_matcher, change_password_url_field_matcher,
Field(&CompromisedCredentialForUI::compromise_type, compromise_type), Field(&CompromisedCredentialForUI::insecure_type, insecure_type),
Field(&CompromisedCredentialForUI::has_script, has_script)); Field(&CompromisedCredentialForUI::has_script, has_script));
} }
...@@ -309,7 +309,7 @@ TEST_F(PasswordCheckManagerTest, CorrectlyCreatesUIStructForSiteCredential) { ...@@ -309,7 +309,7 @@ TEST_F(PasswordCheckManagerTest, CorrectlyCreatesUIStructForSiteCredential) {
ElementsAre(ExpectCompromisedCredentialForUI( ElementsAre(ExpectCompromisedCredentialForUI(
base::ASCIIToUTF16(kUsername1), base::ASCIIToUTF16("example.com"), base::ASCIIToUTF16(kUsername1), base::ASCIIToUTF16("example.com"),
base::nullopt, "https://example.com/", base::nullopt, "https://example.com/",
CompromiseTypeFlags::kCredentialLeaked, InsecureCredentialTypeFlags::kCredentialLeaked,
/*has_script=*/false))); /*has_script=*/false)));
} }
...@@ -333,12 +333,12 @@ TEST_F(PasswordCheckManagerTest, CorrectlyCreatesUIStructForAppCredentials) { ...@@ -333,12 +333,12 @@ TEST_F(PasswordCheckManagerTest, CorrectlyCreatesUIStructForAppCredentials) {
ExpectCompromisedCredentialForUI( ExpectCompromisedCredentialForUI(
base::ASCIIToUTF16(kUsername1), base::ASCIIToUTF16(kUsername1),
base::ASCIIToUTF16("App (com.example.app)"), "com.example.app", base::ASCIIToUTF16("App (com.example.app)"), "com.example.app",
base::nullopt, CompromiseTypeFlags::kCredentialLeaked, base::nullopt, InsecureCredentialTypeFlags::kCredentialLeaked,
/*has_script=*/false), /*has_script=*/false),
ExpectCompromisedCredentialForUI( ExpectCompromisedCredentialForUI(
base::ASCIIToUTF16(kUsername2), base::ASCIIToUTF16("Example App"), base::ASCIIToUTF16(kUsername2), base::ASCIIToUTF16("Example App"),
"com.example.app", base::nullopt, "com.example.app", base::nullopt,
CompromiseTypeFlags::kCredentialLeaked, InsecureCredentialTypeFlags::kCredentialLeaked,
/*has_script=*/false))); /*has_script=*/false)));
} }
...@@ -388,7 +388,8 @@ TEST_F(PasswordCheckManagerTest, ...@@ -388,7 +388,8 @@ TEST_F(PasswordCheckManagerTest,
ElementsAre(ExpectCompromisedCredentialForUI( ElementsAre(ExpectCompromisedCredentialForUI(
base::ASCIIToUTF16(kUsername1), base::ASCIIToUTF16("example.com"), base::ASCIIToUTF16(kUsername1), base::ASCIIToUTF16("example.com"),
base::nullopt, "https://example.com/", base::nullopt, "https://example.com/",
CompromiseTypeFlags::kCredentialLeaked, /*has_script=*/false))); InsecureCredentialTypeFlags::kCredentialLeaked,
/*has_script=*/false)));
} }
TEST_F(PasswordCheckManagerTest, TEST_F(PasswordCheckManagerTest,
...@@ -414,7 +415,8 @@ TEST_F(PasswordCheckManagerTest, ...@@ -414,7 +415,8 @@ TEST_F(PasswordCheckManagerTest,
ElementsAre(ExpectCompromisedCredentialForUI( ElementsAre(ExpectCompromisedCredentialForUI(
base::ASCIIToUTF16(kUsername1), base::ASCIIToUTF16("example.com"), base::ASCIIToUTF16(kUsername1), base::ASCIIToUTF16("example.com"),
base::nullopt, "https://example.com/", base::nullopt, "https://example.com/",
CompromiseTypeFlags::kCredentialLeaked, /*has_script=*/true))); InsecureCredentialTypeFlags::kCredentialLeaked,
/*has_script=*/true)));
} }
TEST_F(PasswordCheckManagerTest, UpdatesProgressCorrectly) { TEST_F(PasswordCheckManagerTest, UpdatesProgressCorrectly) {
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
namespace password_manager { namespace password_manager {
// Extra information about CompromisedCredentials which is required by UI. // Extra information about InsecureCredentials which is required by UI.
struct CredentialMetadata { struct CredentialMetadata {
std::vector<autofill::PasswordForm> forms; std::vector<autofill::PasswordForm> forms;
CompromiseTypeFlags type = CompromiseTypeFlags::kNotCompromised; InsecureCredentialTypeFlags type = InsecureCredentialTypeFlags::kSecure;
base::Time latest_time; base::Time latest_time;
}; };
...@@ -54,20 +54,20 @@ struct CredentialWithoutPasswordLess { ...@@ -54,20 +54,20 @@ struct CredentialWithoutPasswordLess {
} }
}; };
CompromiseTypeFlags ConvertCompromiseType(CompromiseType type) { InsecureCredentialTypeFlags ConvertCompromiseType(CompromiseType type) {
switch (type) { switch (type) {
case CompromiseType::kLeaked: case CompromiseType::kLeaked:
return CompromiseTypeFlags::kCredentialLeaked; return InsecureCredentialTypeFlags::kCredentialLeaked;
case CompromiseType::kPhished: case CompromiseType::kPhished:
return CompromiseTypeFlags::kCredentialPhished; return InsecureCredentialTypeFlags::kCredentialPhished;
} }
NOTREACHED(); NOTREACHED();
} }
// This function takes two lists of compromised credentials and saved passwords // This function takes two lists of compromised credentials and saved passwords
// and joins them, producing a map that contains CredentialWithPassword as keys // and joins them, producing a map that contains CredentialWithPassword as keys
// and vector<autofill::PasswordForm> as values with CredentialCompromiseType as // and vector<autofill::PasswordForm> as values with InsecureCredentialTypeFlags
// values. // as values.
CredentialPasswordsMap JoinCompromisedCredentialsWithSavedPasswords( CredentialPasswordsMap JoinCompromisedCredentialsWithSavedPasswords(
const std::vector<CompromisedCredentials>& credentials, const std::vector<CompromisedCredentials>& credentials,
SavedPasswordsPresenter::SavedPasswordsView saved_passwords) { SavedPasswordsPresenter::SavedPasswordsView saved_passwords) {
...@@ -83,7 +83,7 @@ CredentialPasswordsMap JoinCompromisedCredentialsWithSavedPasswords( ...@@ -83,7 +83,7 @@ CredentialPasswordsMap JoinCompromisedCredentialsWithSavedPasswords(
for (const auto& form : saved_passwords) { for (const auto& form : saved_passwords) {
CredentialView compromised_credential(form); CredentialView compromised_credential(form);
auto& credential_to_form = credentials_to_forms[compromised_credential]; auto& credential_to_form = credentials_to_forms[compromised_credential];
credential_to_form.type = CompromiseTypeFlags::kCredentialLeaked; credential_to_form.type = InsecureCredentialTypeFlags::kCredentialLeaked;
credential_to_form.forms.push_back(form); credential_to_form.forms.push_back(form);
credential_to_form.latest_time = form.date_created; credential_to_form.latest_time = form.date_created;
} }
...@@ -131,7 +131,7 @@ std::vector<CredentialWithPassword> ExtractCompromisedCredentials( ...@@ -131,7 +131,7 @@ std::vector<CredentialWithPassword> ExtractCompromisedCredentials(
credentials.reserve(credentials_to_forms.size()); credentials.reserve(credentials_to_forms.size());
for (const auto& credential_to_forms : credentials_to_forms) { for (const auto& credential_to_forms : credentials_to_forms) {
CredentialWithPassword credential(credential_to_forms.first); CredentialWithPassword credential(credential_to_forms.first);
credential.compromise_type = credential_to_forms.second.type; credential.insecure_type = credential_to_forms.second.type;
credential.create_time = credential_to_forms.second.latest_time; credential.create_time = credential_to_forms.second.latest_time;
credentials.push_back(std::move(credential)); credentials.push_back(std::move(credential));
} }
...@@ -178,7 +178,7 @@ CredentialWithPassword::CredentialWithPassword( ...@@ -178,7 +178,7 @@ CredentialWithPassword::CredentialWithPassword(
credential.username, credential.username,
/*password=*/{}), /*password=*/{}),
create_time(credential.create_time), create_time(credential.create_time),
compromise_type(ConvertCompromiseType(credential.compromise_type)) {} insecure_type(ConvertCompromiseType(credential.compromise_type)) {}
CredentialWithPassword& CredentialWithPassword::operator=( CredentialWithPassword& CredentialWithPassword::operator=(
const CredentialWithPassword& other) = default; const CredentialWithPassword& other) = default;
......
...@@ -27,22 +27,24 @@ namespace password_manager { ...@@ -27,22 +27,24 @@ namespace password_manager {
class LeakCheckCredential; class LeakCheckCredential;
enum class CompromiseTypeFlags { enum class InsecureCredentialTypeFlags {
kNotCompromised = 0, kSecure = 0,
// If the credentials was leaked by a data breach. // If the credential was leaked by a data breach.
kCredentialLeaked = 1 << 0, kCredentialLeaked = 1 << 0,
// If the credentials was reused on a phishing site. // If the credential was reused on a phishing site.
kCredentialPhished = 1 << 1, kCredentialPhished = 1 << 1,
// If the credential has a weak password.
kWeakCredential = 1 << 2,
}; };
constexpr CompromiseTypeFlags operator|(CompromiseTypeFlags lhs, constexpr InsecureCredentialTypeFlags operator|(
CompromiseTypeFlags rhs) { InsecureCredentialTypeFlags lhs,
return static_cast<CompromiseTypeFlags>(static_cast<int>(lhs) | InsecureCredentialTypeFlags rhs) {
static_cast<int>(rhs)); return static_cast<InsecureCredentialTypeFlags>(static_cast<int>(lhs) |
static_cast<int>(rhs));
} }
// Simple struct that augments key values of CompromisedCredentials and a // Simple struct that augments key values of InsecureCredentials and a password.
// password.
struct CredentialView { struct CredentialView {
CredentialView(std::string signon_realm, CredentialView(std::string signon_realm,
GURL url, GURL url,
...@@ -62,10 +64,11 @@ struct CredentialView { ...@@ -62,10 +64,11 @@ struct CredentialView {
base::string16 password; base::string16 password;
}; };
// All information needed by UI to represent CompromisedCredential. It's a // All information needed by UI to represent InsecureCredential. It's a result
// result of deduplicating CompromisedCredentials to have single entity both for // of deduplicating InsecureCredentials to have single entity for phished,
// phished and leaked credentials with latest |create_time|, and after that // leaked and weak credentials with latest |create_time|, and after that joining
// joining with autofill::PasswordForms to get passwords. // with autofill::PasswordForms to get passwords. If the credential is only
// weak, |create_time| will be unset.
struct CredentialWithPassword : CredentialView { struct CredentialWithPassword : CredentialView {
explicit CredentialWithPassword(const CredentialView& credential); explicit CredentialWithPassword(const CredentialView& credential);
explicit CredentialWithPassword(const CompromisedCredentials& credential); explicit CredentialWithPassword(const CompromisedCredentials& credential);
...@@ -77,7 +80,8 @@ struct CredentialWithPassword : CredentialView { ...@@ -77,7 +80,8 @@ struct CredentialWithPassword : CredentialView {
CredentialWithPassword& operator=(const CredentialWithPassword& other); CredentialWithPassword& operator=(const CredentialWithPassword& other);
CredentialWithPassword& operator=(CredentialWithPassword&& other); CredentialWithPassword& operator=(CredentialWithPassword&& other);
base::Time create_time; base::Time create_time;
CompromiseTypeFlags compromise_type = CompromiseTypeFlags::kNotCompromised; InsecureCredentialTypeFlags insecure_type =
InsecureCredentialTypeFlags::kSecure;
}; };
// Comparator that can compare CredentialView or CredentialsWithPasswords. // Comparator that can compare CredentialView or CredentialsWithPasswords.
...@@ -88,7 +92,7 @@ struct PasswordCredentialLess { ...@@ -88,7 +92,7 @@ struct PasswordCredentialLess {
} }
}; };
// Extra information about CompromisedCredentials which is required by UI. // Extra information about InsecureCredentials which is required by UI.
struct CredentialMetadata; struct CredentialMetadata;
// This class provides clients with saved compromised credentials and // This class provides clients with saved compromised credentials and
......
...@@ -77,10 +77,10 @@ CredentialWithPassword MakeCompromisedCredential( ...@@ -77,10 +77,10 @@ CredentialWithPassword MakeCompromisedCredential(
CompromisedCredentials credential) { CompromisedCredentials credential) {
CredentialWithPassword credential_with_password((CredentialView(form))); CredentialWithPassword credential_with_password((CredentialView(form)));
credential_with_password.create_time = credential.create_time; credential_with_password.create_time = credential.create_time;
credential_with_password.compromise_type = credential_with_password.insecure_type =
credential.compromise_type == CompromiseType::kLeaked credential.compromise_type == CompromiseType::kLeaked
? CompromiseTypeFlags::kCredentialLeaked ? InsecureCredentialTypeFlags::kCredentialLeaked
: CompromiseTypeFlags::kCredentialPhished; : InsecureCredentialTypeFlags::kCredentialPhished;
return credential_with_password; return credential_with_password;
} }
...@@ -113,8 +113,7 @@ bool operator==(const CredentialWithPassword& lhs, ...@@ -113,8 +113,7 @@ bool operator==(const CredentialWithPassword& lhs,
const CredentialWithPassword& rhs) { const CredentialWithPassword& rhs) {
return lhs.signon_realm == rhs.signon_realm && lhs.username == rhs.username && return lhs.signon_realm == rhs.signon_realm && lhs.username == rhs.username &&
lhs.create_time == rhs.create_time && lhs.create_time == rhs.create_time &&
lhs.compromise_type == rhs.compromise_type && lhs.insecure_type == rhs.insecure_type && lhs.password == rhs.password;
lhs.password == rhs.password;
} }
std::ostream& operator<<(std::ostream& out, std::ostream& operator<<(std::ostream& out,
...@@ -123,7 +122,7 @@ std::ostream& operator<<(std::ostream& out, ...@@ -123,7 +122,7 @@ std::ostream& operator<<(std::ostream& out,
<< ", username: " << credential.username << ", username: " << credential.username
<< ", create_time: " << credential.create_time << ", create_time: " << credential.create_time
<< ", compromise_type: " << ", compromise_type: "
<< static_cast<int>(credential.compromise_type) << static_cast<int>(credential.insecure_type)
<< ", password: " << credential.password << " }"; << ", password: " << credential.password << " }";
} }
...@@ -272,8 +271,8 @@ TEST_F(CompromisedCredentialsManagerTest, JoinPhishedAndLeaked) { ...@@ -272,8 +271,8 @@ TEST_F(CompromisedCredentialsManagerTest, JoinPhishedAndLeaked) {
CredentialWithPassword expected = MakeCompromisedCredential(password, leaked); CredentialWithPassword expected = MakeCompromisedCredential(password, leaked);
expected.password = password.password_value; expected.password = password.password_value;
expected.compromise_type = (CompromiseTypeFlags::kCredentialLeaked | expected.insecure_type = (InsecureCredentialTypeFlags::kCredentialLeaked |
CompromiseTypeFlags::kCredentialPhished); InsecureCredentialTypeFlags::kCredentialPhished);
EXPECT_THAT(provider().GetCompromisedCredentials(), ElementsAre(expected)); EXPECT_THAT(provider().GetCompromisedCredentials(), ElementsAre(expected));
} }
......
...@@ -54,7 +54,7 @@ using password_manager::CredentialWithPassword; ...@@ -54,7 +54,7 @@ using password_manager::CredentialWithPassword;
using password_manager::MockBulkLeakCheckService; using password_manager::MockBulkLeakCheckService;
using password_manager::CompromisedCredentials; using password_manager::CompromisedCredentials;
using password_manager::CompromiseType; using password_manager::CompromiseType;
using password_manager::CompromiseTypeFlags; using password_manager::InsecureCredentialTypeFlags;
using password_manager::IsLeaked; using password_manager::IsLeaked;
using password_manager::LeakCheckCredential; using password_manager::LeakCheckCredential;
using password_manager::TestPasswordStore; using password_manager::TestPasswordStore;
...@@ -132,14 +132,14 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, ...@@ -132,14 +132,14 @@ auto ExpectCompromisedCredential(const std::string& signon_realm,
const base::StringPiece& username, const base::StringPiece& username,
const base::StringPiece& password, const base::StringPiece& password,
base::TimeDelta elapsed_time_since_compromise, base::TimeDelta elapsed_time_since_compromise,
CompromiseTypeFlags compromise_type) { InsecureCredentialTypeFlags insecure_type) {
return AllOf( return AllOf(
Field(&CredentialWithPassword::signon_realm, signon_realm), Field(&CredentialWithPassword::signon_realm, signon_realm),
Field(&CredentialWithPassword::username, base::ASCIIToUTF16(username)), Field(&CredentialWithPassword::username, base::ASCIIToUTF16(username)),
Field(&CredentialWithPassword::password, base::ASCIIToUTF16(password)), Field(&CredentialWithPassword::password, base::ASCIIToUTF16(password)),
Field(&CredentialWithPassword::create_time, Field(&CredentialWithPassword::create_time,
(base::Time::Now() - elapsed_time_since_compromise)), (base::Time::Now() - elapsed_time_since_compromise)),
Field(&CredentialWithPassword::compromise_type, compromise_type)); Field(&CredentialWithPassword::insecure_type, insecure_type));
} }
class IOSChromePasswordCheckManagerTest : public PlatformTest { class IOSChromePasswordCheckManagerTest : public PlatformTest {
...@@ -189,7 +189,7 @@ TEST_F(IOSChromePasswordCheckManagerTest, GetCompromisedCredentials) { ...@@ -189,7 +189,7 @@ TEST_F(IOSChromePasswordCheckManagerTest, GetCompromisedCredentials) {
manager().GetCompromisedCredentials(), manager().GetCompromisedCredentials(),
ElementsAre(ExpectCompromisedCredential( ElementsAre(ExpectCompromisedCredential(
kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1), kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1),
CompromiseTypeFlags::kCredentialLeaked))); InsecureCredentialTypeFlags::kCredentialLeaked)));
} }
// Test that we don't create an entry in the password store if IsLeaked is // Test that we don't create an entry in the password store if IsLeaked is
...@@ -223,7 +223,7 @@ TEST_F(IOSChromePasswordCheckManagerTest, OnLeakFoundCreatesCredential) { ...@@ -223,7 +223,7 @@ TEST_F(IOSChromePasswordCheckManagerTest, OnLeakFoundCreatesCredential) {
manager().GetCompromisedCredentials(), manager().GetCompromisedCredentials(),
ElementsAre(ExpectCompromisedCredential( ElementsAre(ExpectCompromisedCredential(
kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(0), kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(0),
CompromiseTypeFlags::kCredentialLeaked))); InsecureCredentialTypeFlags::kCredentialLeaked)));
} }
// Verifies that the case where the user has no saved passwords is reported // Verifies that the case where the user has no saved passwords is reported
...@@ -286,7 +286,7 @@ TEST_F(IOSChromePasswordCheckManagerTest, ...@@ -286,7 +286,7 @@ TEST_F(IOSChromePasswordCheckManagerTest,
observer, observer,
CompromisedCredentialsChanged(ElementsAre(ExpectCompromisedCredential( CompromisedCredentialsChanged(ElementsAre(ExpectCompromisedCredential(
kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1), kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1),
CompromiseTypeFlags::kCredentialLeaked)))); InsecureCredentialTypeFlags::kCredentialLeaked))));
store().AddCompromisedCredentials(MakeCompromised( store().AddCompromisedCredentials(MakeCompromised(
kExampleCom, kUsername1, base::TimeDelta::FromMinutes(1))); kExampleCom, kUsername1, base::TimeDelta::FromMinutes(1)));
RunUntilIdle(); RunUntilIdle();
...@@ -337,7 +337,7 @@ TEST_F(IOSChromePasswordCheckManagerTest, DeletePassword) { ...@@ -337,7 +337,7 @@ TEST_F(IOSChromePasswordCheckManagerTest, DeletePassword) {
manager().GetCompromisedCredentials(), manager().GetCompromisedCredentials(),
ElementsAre(ExpectCompromisedCredential( ElementsAre(ExpectCompromisedCredential(
kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1), kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1),
CompromiseTypeFlags::kCredentialLeaked))); InsecureCredentialTypeFlags::kCredentialLeaked)));
manager().DeleteCompromisedPasswordForm(form); manager().DeleteCompromisedPasswordForm(form);
RunUntilIdle(); RunUntilIdle();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment