OLD | NEW |
---|---|
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_dispatc her.h" | 5 #include "components/password_manager/content/browser/credential_manager_dispatc her.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 | 295 |
296 RunAllPendingTasks(); | 296 RunAllPendingTasks(); |
297 | 297 |
298 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 298 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; |
299 const IPC::Message* message = | 299 const IPC::Message* message = |
300 process()->sink().GetFirstMessageMatching(kMsgID); | 300 process()->sink().GetFirstMessageMatching(kMsgID); |
301 EXPECT_TRUE(message); | 301 EXPECT_TRUE(message); |
302 EXPECT_TRUE(client_->did_prompt_user_to_choose()); | 302 EXPECT_TRUE(client_->did_prompt_user_to_choose()); |
303 } | 303 } |
304 | 304 |
305 TEST_F( | |
306 CredentialManagerDispatcherTest, | |
307 CredentialManagerOnRequestCredentialWithZeroClickOnlyEmptyPasswordStore) { | |
308 form_.is_zero_click = false; | |
309 store_->AddLogin(form_); | |
310 | |
311 std::vector<GURL> federations; | |
312 dispatcher()->OnRequestCredential(kRequestId, true, federations); | |
vabr (Chromium)
2015/01/28 13:37:51
nit: I guess that "true" is the "require 0-click"
| |
313 | |
314 RunAllPendingTasks(); | |
315 | |
316 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | |
317 const IPC::Message* message = | |
318 process()->sink().GetFirstMessageMatching(kMsgID); | |
319 EXPECT_TRUE(message); | |
320 EXPECT_FALSE(client_->did_prompt_user_to_choose()); | |
321 CredentialManagerMsg_SendCredential::Param send_param; | |
322 CredentialManagerMsg_SendCredential::Read(message, &send_param); | |
323 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, get<1>(send_param).type); | |
324 } | |
325 | |
326 TEST_F(CredentialManagerDispatcherTest, | |
327 CredentialManagerOnRequestCredentialWithZeroClickOnlyFullPasswordStore) { | |
328 form_.is_zero_click = true; | |
329 store_->AddLogin(form_); | |
330 | |
331 std::vector<GURL> federations; | |
332 dispatcher()->OnRequestCredential(kRequestId, true, federations); | |
333 | |
334 RunAllPendingTasks(); | |
335 | |
336 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | |
337 const IPC::Message* message = | |
338 process()->sink().GetFirstMessageMatching(kMsgID); | |
339 EXPECT_TRUE(message); | |
340 EXPECT_FALSE(client_->did_prompt_user_to_choose()); | |
341 CredentialManagerMsg_SendCredential::Param send_param; | |
342 CredentialManagerMsg_SendCredential::Read(message, &send_param); | |
343 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_LOCAL, get<1>(send_param).type); | |
344 } | |
345 | |
346 TEST_F(CredentialManagerDispatcherTest, | |
347 CredentialManagerOnRequestCredentialWithZeroClickOnlyTwoPasswordStore) { | |
348 form_.is_zero_click = true; | |
349 store_->AddLogin(form_); | |
350 store_->AddLogin(form_); | |
351 | |
352 std::vector<GURL> federations; | |
353 dispatcher()->OnRequestCredential(kRequestId, true, federations); | |
354 | |
355 RunAllPendingTasks(); | |
356 | |
357 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | |
358 const IPC::Message* message = | |
359 process()->sink().GetFirstMessageMatching(kMsgID); | |
360 EXPECT_TRUE(message); | |
361 EXPECT_FALSE(client_->did_prompt_user_to_choose()); | |
362 CredentialManagerMsg_SendCredential::Param send_param; | |
363 CredentialManagerMsg_SendCredential::Read(message, &send_param); | |
364 | |
365 // With two items in the password store, we shouldn't get credentials back. | |
366 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, get<1>(send_param).type); | |
367 } | |
368 | |
305 TEST_F(CredentialManagerDispatcherTest, | 369 TEST_F(CredentialManagerDispatcherTest, |
306 CredentialManagerOnRequestCredentialWhileRequestPending) { | 370 CredentialManagerOnRequestCredentialWhileRequestPending) { |
307 store_->AddLogin(form_); | 371 store_->AddLogin(form_); |
308 | 372 |
309 std::vector<GURL> federations; | 373 std::vector<GURL> federations; |
310 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 374 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
311 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 375 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
312 | 376 |
313 // Check that the second request triggered a rejection. | 377 // Check that the second request triggered a rejection. |
314 uint32 kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID; | 378 uint32 kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 const IPC::Message* message = | 414 const IPC::Message* message = |
351 process()->sink().GetFirstMessageMatching(kMsgID); | 415 process()->sink().GetFirstMessageMatching(kMsgID); |
352 ASSERT_TRUE(message); | 416 ASSERT_TRUE(message); |
353 CredentialManagerMsg_SendCredential::Param param; | 417 CredentialManagerMsg_SendCredential::Param param; |
354 CredentialManagerMsg_SendCredential::Read(message, ¶m); | 418 CredentialManagerMsg_SendCredential::Read(message, ¶m); |
355 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, get<1>(param).type); | 419 EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, get<1>(param).type); |
356 EXPECT_FALSE(client_->did_prompt_user_to_choose()); | 420 EXPECT_FALSE(client_->did_prompt_user_to_choose()); |
357 } | 421 } |
358 | 422 |
359 } // namespace password_manager | 423 } // namespace password_manager |
OLD | NEW |