Index: components/password_manager/content/browser/credential_manager_impl_unittest.cc |
diff --git a/components/password_manager/content/browser/credential_manager_impl_unittest.cc b/components/password_manager/content/browser/credential_manager_impl_unittest.cc |
index 377649611a2ec9f133f1d9ae1a3f39ad07bde1c9..6b748a0cff3e6ba3aee8a0bacb946667c14b7443 100644 |
--- a/components/password_manager/content/browser/credential_manager_impl_unittest.cc |
+++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc |
@@ -292,13 +292,14 @@ class CredentialManagerImplTest : public content::RenderViewHostTestHarness { |
content::RenderViewHostTestHarness::TearDown(); |
} |
- void ExpectZeroClickSignInFailure(bool zero_click_only, |
- bool include_passwords, |
- const std::vector<GURL>& federations) { |
+ void ExpectZeroClickSignInFailure( |
+ mojom::CredentialMediationRequirement mediation, |
vasilii
2017/05/18 12:34:03
No "mojo::"
jdoerrie
2017/05/18 14:57:24
Done.
|
+ bool include_passwords, |
+ const std::vector<GURL>& federations) { |
bool called = false; |
mojom::CredentialManagerError error; |
base::Optional<CredentialInfo> credential; |
- CallGet(zero_click_only, include_passwords, federations, |
+ CallGet(mediation, include_passwords, federations, |
base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _)) |
.Times(testing::Exactly(0)); |
@@ -311,14 +312,35 @@ class CredentialManagerImplTest : public content::RenderViewHostTestHarness { |
EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, credential->type); |
} |
- void ExpectZeroClickSignInSuccess(bool zero_click_only, |
- bool include_passwords, |
- const std::vector<GURL>& federations, |
- CredentialType type) { |
+ void ExpectAccountChooser(mojom::CredentialMediationRequirement mediation, |
+ bool include_passwords, |
+ const std::vector<GURL>& federations, |
+ CredentialType type) { |
bool called = false; |
mojom::CredentialManagerError error; |
base::Optional<CredentialInfo> credential; |
- CallGet(zero_click_only, include_passwords, federations, |
+ CallGet(mediation, include_passwords, federations, |
+ base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
+ EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _)) |
+ .Times(testing::Exactly(1)); |
+ EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(testing::Exactly(0)); |
+ |
+ RunAllPendingTasks(); |
+ |
+ EXPECT_TRUE(called); |
+ EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error); |
+ EXPECT_EQ(type, credential->type); |
+ } |
+ |
+ void ExpectZeroClickSignInSuccess( |
+ mojom::CredentialMediationRequirement mediation, |
+ bool include_passwords, |
+ const std::vector<GURL>& federations, |
+ CredentialType type) { |
+ bool called = false; |
+ mojom::CredentialManagerError error; |
+ base::Optional<CredentialInfo> credential; |
+ CallGet(mediation, include_passwords, federations, |
base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _)) |
.Times(testing::Exactly(0)); |
@@ -331,14 +353,14 @@ class CredentialManagerImplTest : public content::RenderViewHostTestHarness { |
EXPECT_EQ(type, credential->type); |
} |
- void ExpectCredentialType(bool zero_click_only, |
+ void ExpectCredentialType(mojom::CredentialMediationRequirement mediation, |
bool include_passwords, |
const std::vector<GURL>& federations, |
CredentialType type) { |
bool called = false; |
mojom::CredentialManagerError error; |
base::Optional<CredentialInfo> credential; |
- CallGet(zero_click_only, include_passwords, federations, |
+ CallGet(mediation, include_passwords, federations, |
base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
RunAllPendingTasks(); |
@@ -361,11 +383,11 @@ class CredentialManagerImplTest : public content::RenderViewHostTestHarness { |
cm_service_impl_->RequireUserMediation(std::move(callback)); |
} |
- void CallGet(bool zero_click_only, |
+ void CallGet(mojom::CredentialMediationRequirement mediation, |
bool include_passwords, |
const std::vector<GURL>& federations, |
CredentialManagerImpl::GetCallback callback) { |
- cm_service_impl_->Get(zero_click_only, include_passwords, federations, |
+ cm_service_impl_->Get(mediation, include_passwords, federations, |
std::move(callback)); |
} |
@@ -680,7 +702,7 @@ TEST_F(CredentialManagerImplTest, CredentialManagerGetOverwriteZeroClick) { |
bool called = false; |
mojom::CredentialManagerError error; |
base::Optional<CredentialInfo> credential; |
- CallGet(false, true, federations, |
+ CallGet(mojom::CredentialMediationRequirement::OPTIONAL, true, federations, |
base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
RunAllPendingTasks(); |
@@ -813,8 +835,11 @@ TEST_F(CredentialManagerImplTest, |
.Times(testing::Exactly(0)); |
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(testing::Exactly(0)); |
- ExpectCredentialType(false, true, federations, |
- CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::OPTIONAL, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::SILENT, true, |
vasilii
2017/05/18 12:34:03
We have CredentialManagerOnRequestCredentialWithZe
|
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -826,8 +851,11 @@ TEST_F(CredentialManagerImplTest, |
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(testing::Exactly(0)); |
std::vector<GURL> federations; |
- ExpectCredentialType(false, true, federations, |
- CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::OPTIONAL, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::REQUIRED, true, |
vasilii
2017/05/18 12:34:03
I'd avoid calling Get() twice in the same test unl
|
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -836,10 +864,16 @@ TEST_F(CredentialManagerImplTest, |
subdomain_form_.is_public_suffix_match = true; |
EXPECT_CALL(*client_, |
PromptUserToChooseCredentialsPtr( |
- UnorderedElementsAre(Pointee(subdomain_form_)), _, _)); |
+ UnorderedElementsAre(Pointee(subdomain_form_)), _, _)) |
+ .Times(testing::Exactly(2)); |
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(0); |
- ExpectCredentialType(false, true, std::vector<GURL>(), |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::OPTIONAL, true, |
+ std::vector<GURL>(), |
+ CredentialType::CREDENTIAL_TYPE_PASSWORD); |
+ |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ std::vector<GURL>(), |
CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
@@ -852,9 +886,15 @@ TEST_F(CredentialManagerImplTest, |
EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr( |
UnorderedElementsAre(Pointee(origin_path_form_), |
Pointee(form_)), |
- _, _)); |
+ _, _)) |
+ .Times(testing::Exactly(2)); |
+ |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::OPTIONAL, true, |
+ std::vector<GURL>(), |
+ CredentialType::CREDENTIAL_TYPE_PASSWORD); |
- ExpectCredentialType(false, true, std::vector<GURL>(), |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ std::vector<GURL>(), |
CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
@@ -869,8 +909,12 @@ TEST_F(CredentialManagerImplTest, |
store_->AddLogin(duplicate); |
std::vector<GURL> federations; |
- ExpectZeroClickSignInSuccess(false, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::OPTIONAL, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_PASSWORD); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -912,7 +956,7 @@ TEST_F(CredentialManagerImplTest, |
base::Optional<CredentialInfo> credential; |
std::vector<GURL> federations; |
federations.push_back(GURL("https://google.com/")); |
- CallGet(false, true, federations, |
+ CallGet(mojom::CredentialMediationRequirement::OPTIONAL, true, federations, |
base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
RunAllPendingTasks(); |
@@ -929,8 +973,8 @@ TEST_F(CredentialManagerImplTest, |
.Times(testing::Exactly(0)); |
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(testing::Exactly(0)); |
- ExpectCredentialType(false, true, federations, |
- CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::OPTIONAL, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -946,7 +990,7 @@ TEST_F(CredentialManagerImplTest, |
bool called = false; |
mojom::CredentialManagerError error; |
base::Optional<CredentialInfo> credential; |
- CallGet(false, true, federations, |
+ CallGet(mojom::CredentialMediationRequirement::OPTIONAL, true, federations, |
base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
RunAllPendingTasks(); |
@@ -963,7 +1007,11 @@ TEST_F( |
.Times(testing::Exactly(0)); |
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(testing::Exactly(0)); |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
+ |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::REQUIRED, |
vasilii
2017/05/18 12:34:03
Here and below, we shouldn't mix CredentialMediati
|
+ true, federations); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -975,8 +1023,12 @@ TEST_F(CredentialManagerImplTest, |
EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0); |
- ExpectZeroClickSignInSuccess(true, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_PASSWORD); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -988,7 +1040,11 @@ TEST_F(CredentialManagerImplTest, |
EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0); |
- ExpectZeroClickSignInFailure(true, false, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ false, federations); |
+ |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::REQUIRED, |
+ false, federations); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1003,8 +1059,12 @@ TEST_F(CredentialManagerImplTest, |
EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0); |
- ExpectZeroClickSignInSuccess(true, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_FEDERATED); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_FEDERATED); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1019,7 +1079,11 @@ TEST_F(CredentialManagerImplTest, |
EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0); |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
+ |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::REQUIRED, |
+ true, federations); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1038,8 +1102,16 @@ TEST_F(CredentialManagerImplTest, |
// We pass in 'true' for the 'include_passwords' argument to ensure that |
// password-type credentials are included as potential matches. |
- ExpectZeroClickSignInSuccess(true, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_PASSWORD); |
+ |
+ static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) |
+ ->ExpectCallToGetAffiliatedAndroidRealms( |
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1058,7 +1130,15 @@ TEST_F(CredentialManagerImplTest, |
// We pass in 'false' for the 'include_passwords' argument to ensure that |
// password-type credentials are excluded as potential matches. |
- ExpectZeroClickSignInFailure(true, false, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ false, federations); |
+ |
+ static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) |
+ ->ExpectCallToGetAffiliatedAndroidRealms( |
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
+ |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::REQUIRED, |
+ false, federations); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1080,8 +1160,16 @@ TEST_F(CredentialManagerImplTest, |
->ExpectCallToGetAffiliatedAndroidRealms( |
cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
- ExpectZeroClickSignInSuccess(true, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_FEDERATED); |
+ |
+ static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) |
+ ->ExpectCallToGetAffiliatedAndroidRealms( |
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_FEDERATED); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1103,7 +1191,14 @@ TEST_F(CredentialManagerImplTest, |
->ExpectCallToGetAffiliatedAndroidRealms( |
cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
+ static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) |
+ ->ExpectCallToGetAffiliatedAndroidRealms( |
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
+ |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::REQUIRED, |
+ true, federations); |
} |
TEST_F(CredentialManagerImplTest, RequestCredentialWithoutFirstRun) { |
@@ -1116,7 +1211,11 @@ TEST_F(CredentialManagerImplTest, RequestCredentialWithoutFirstRun) { |
NotifyUserCouldBeAutoSignedInPtr(testing::Pointee(form_))) |
.Times(1); |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, RequestCredentialWithFirstRunAndSkip) { |
@@ -1130,7 +1229,11 @@ TEST_F(CredentialManagerImplTest, RequestCredentialWithFirstRunAndSkip) { |
NotifyUserCouldBeAutoSignedInPtr(testing::Pointee(form_))) |
.Times(1); |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, RequestCredentialWithTLSErrors) { |
@@ -1142,7 +1245,11 @@ TEST_F(CredentialManagerImplTest, RequestCredentialWithTLSErrors) { |
std::vector<GURL> federations; |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
+ |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::REQUIRED, |
+ true, federations); |
} |
TEST_F(CredentialManagerImplTest, RequestCredentialWhilePrerendering) { |
@@ -1154,7 +1261,11 @@ TEST_F(CredentialManagerImplTest, RequestCredentialWhilePrerendering) { |
std::vector<GURL> federations; |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
+ |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::REQUIRED, |
+ true, federations); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1168,8 +1279,8 @@ TEST_F(CredentialManagerImplTest, |
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(testing::Exactly(0)); |
// With two items in the password store, we shouldn't get credentials back. |
- ExpectCredentialType(true, true, federations, |
- CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::SILENT, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1185,8 +1296,8 @@ TEST_F(CredentialManagerImplTest, |
// With two items in the password store, we shouldn't get credentials back, |
// even though only one item has |skip_zero_click| set |false|. |
- ExpectCredentialType(true, true, federations, |
- CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::SILENT, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1203,8 +1314,8 @@ TEST_F(CredentialManagerImplTest, |
// We only have cross-origin zero-click credentials; they should not be |
// returned. |
- ExpectCredentialType(true, true, federations, |
- CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::SILENT, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1222,14 +1333,14 @@ TEST_F(CredentialManagerImplTest, |
mojom::CredentialManagerError error_1; |
base::Optional<CredentialInfo> credential_1; |
CallGet( |
- false, true, federations, |
+ mojom::CredentialMediationRequirement::OPTIONAL, true, federations, |
base::Bind(&GetCredentialCallback, &called_1, &error_1, &credential_1)); |
// 2nd request. |
bool called_2 = false; |
mojom::CredentialManagerError error_2; |
base::Optional<CredentialInfo> credential_2; |
CallGet( |
- false, true, federations, |
+ mojom::CredentialMediationRequirement::OPTIONAL, true, federations, |
base::Bind(&GetCredentialCallback, &called_2, &error_2, &credential_2)); |
EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _)) |
@@ -1286,7 +1397,7 @@ TEST_F(CredentialManagerImplTest, ResetSkipZeroClickAfterPrompt) { |
bool called = false; |
mojom::CredentialManagerError error; |
base::Optional<CredentialInfo> credential; |
- CallGet(false, true, federations, |
+ CallGet(mojom::CredentialMediationRequirement::OPTIONAL, true, federations, |
base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
RunAllPendingTasks(); |
@@ -1322,7 +1433,8 @@ TEST_F(CredentialManagerImplTest, NoResetSkipZeroClickAfterPromptInIncognito) { |
bool called = false; |
mojom::CredentialManagerError error; |
base::Optional<CredentialInfo> credential; |
- CallGet(false, true, std::vector<GURL>(), |
+ CallGet(mojom::CredentialMediationRequirement::OPTIONAL, true, |
+ std::vector<GURL>(), |
base::Bind(&GetCredentialCallback, &called, &error, &credential)); |
RunAllPendingTasks(); |
@@ -1343,8 +1455,8 @@ TEST_F(CredentialManagerImplTest, IncognitoZeroClickRequestCredential) { |
.Times(testing::Exactly(0)); |
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr()).Times(testing::Exactly(0)); |
- ExpectCredentialType(true, true, federations, |
- CredentialType::CREDENTIAL_TYPE_EMPTY); |
+ ExpectCredentialType(mojom::CredentialMediationRequirement::SILENT, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_EMPTY); |
} |
TEST_F(CredentialManagerImplTest, ZeroClickWithAffiliatedFormInPasswordStore) { |
@@ -1363,8 +1475,16 @@ TEST_F(CredentialManagerImplTest, ZeroClickWithAffiliatedFormInPasswordStore) { |
->ExpectCallToGetAffiliatedAndroidRealms( |
cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
- ExpectZeroClickSignInSuccess(true, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_PASSWORD); |
+ |
+ static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) |
+ ->ExpectCallToGetAffiliatedAndroidRealms( |
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1385,7 +1505,15 @@ TEST_F(CredentialManagerImplTest, |
->ExpectCallToGetAffiliatedAndroidRealms( |
cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
+ |
+ static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) |
+ ->ExpectCallToGetAffiliatedAndroidRealms( |
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1412,7 +1540,8 @@ TEST_F(CredentialManagerImplTest, |
->ExpectCallToGetAffiliatedAndroidRealms(digest, affiliated_realms); |
std::vector<GURL> federations; |
- ExpectZeroClickSignInFailure(true, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations); |
} |
TEST_F(CredentialManagerImplTest, |
@@ -1432,15 +1561,28 @@ TEST_F(CredentialManagerImplTest, |
->ExpectCallToGetAffiliatedAndroidRealms( |
cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
- ExpectZeroClickSignInSuccess(true, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_PASSWORD); |
+ |
+ static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper()) |
+ ->ExpectCallToGetAffiliatedAndroidRealms( |
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, ZeroClickWithPSLCredential) { |
subdomain_form_.skip_zero_click = false; |
store_->AddLogin(subdomain_form_); |
- ExpectZeroClickSignInFailure(true, true, std::vector<GURL>()); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::SILENT, |
+ true, std::vector<GURL>()); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ std::vector<GURL>(), |
+ CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, ZeroClickWithPSLAndNormalCredentials) { |
@@ -1452,8 +1594,12 @@ TEST_F(CredentialManagerImplTest, ZeroClickWithPSLAndNormalCredentials) { |
store_->AddLogin(subdomain_form_); |
std::vector<GURL> federations = {GURL("https://google.com/")}; |
- ExpectZeroClickSignInSuccess(true, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_FEDERATED); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_FEDERATED); |
} |
TEST_F(CredentialManagerImplTest, ZeroClickAfterMigratingHttpCredential) { |
@@ -1466,8 +1612,12 @@ TEST_F(CredentialManagerImplTest, ZeroClickAfterMigratingHttpCredential) { |
store_->AddLogin(form_); |
std::vector<GURL> federations; |
- ExpectZeroClickSignInSuccess(true, true, federations, |
+ ExpectZeroClickSignInSuccess(mojom::CredentialMediationRequirement::SILENT, |
+ true, federations, |
CredentialType::CREDENTIAL_TYPE_PASSWORD); |
+ |
+ ExpectAccountChooser(mojom::CredentialMediationRequirement::REQUIRED, true, |
+ federations, CredentialType::CREDENTIAL_TYPE_PASSWORD); |
} |
TEST_F(CredentialManagerImplTest, MigrateWithEmptyStore) { |
@@ -1475,7 +1625,11 @@ TEST_F(CredentialManagerImplTest, MigrateWithEmptyStore) { |
NavigateAndCommit(GURL("http://127.0.0.1:8000/")); |
std::vector<GURL> federations; |
- ExpectZeroClickSignInFailure(false, true, federations); |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::OPTIONAL, |
+ true, federations); |
+ |
+ ExpectZeroClickSignInFailure(mojom::CredentialMediationRequirement::REQUIRED, |
+ true, federations); |
} |
vasilii
2017/05/18 12:34:03
There should be a new test for CredentialMediation
vasilii
2017/05/18 16:16:12
Not addressed.
jdoerrie
2017/05/19 09:03:18
Done.
|
TEST_F(CredentialManagerImplTest, GetSynthesizedFormForOrigin) { |