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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 // Tests the no password scraped flow. | 464 // Tests the no password scraped flow. |
465 IN_PROC_BROWSER_TEST_F(SamlTest, ScrapedNone) { | 465 IN_PROC_BROWSER_TEST_F(SamlTest, ScrapedNone) { |
466 fake_saml_idp()->SetLoginHTMLTemplate("saml_login_no_passwords.html"); | 466 fake_saml_idp()->SetLoginHTMLTemplate("saml_login_no_passwords.html"); |
467 | 467 |
468 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | 468 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |
469 | 469 |
470 SetSignFormField("Email", "fake_user"); | 470 SetSignFormField("Email", "fake_user"); |
471 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 471 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
472 | 472 |
473 OobeScreenWaiter(OobeDisplay::SCREEN_MESSAGE_BOX).Wait(); | 473 OobeScreenWaiter(OobeDisplay::SCREEN_FATAL_ERROR).Wait(); |
474 JsExpect( | |
475 "$('message-box-title').textContent == " | |
476 "loadTimeData.getString('noPasswordWarningTitle')"); | |
477 } | 474 } |
478 | 475 |
479 // Types |bob@example.com| into the GAIA login form but then authenticates as | 476 // Types |bob@example.com| into the GAIA login form but then authenticates as |
480 // |alice@example.com| via SAML. Verifies that the logged-in user is correctly | 477 // |alice@example.com| via SAML. Verifies that the logged-in user is correctly |
481 // identified as Alice. | 478 // identified as Alice. |
482 IN_PROC_BROWSER_TEST_F(SamlTest, UseAutenticatedUserEmailAddress) { | 479 IN_PROC_BROWSER_TEST_F(SamlTest, UseAutenticatedUserEmailAddress) { |
483 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 480 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
484 // Type |bob@example.com| into the GAIA login form. | 481 // Type |bob@example.com| into the GAIA login form. |
485 StartSamlAndWaitForIdpPageLoad(kSecondSAMLUserEmail); | 482 StartSamlAndWaitForIdpPageLoad(kSecondSAMLUserEmail); |
486 | 483 |
487 // Authenticate as alice@example.com via SAML (the |Email| provided here is | 484 // Authenticate as alice@example.com via SAML (the |Email| provided here is |
488 // irrelevant - the authenticated user's e-mail address that FakeGAIA | 485 // irrelevant - the authenticated user's e-mail address that FakeGAIA |
489 // reports was set via SetMergeSessionParams()). | 486 // reports was set via SetMergeSessionParams()). |
490 SetSignFormField("Email", "fake_user"); | 487 SetSignFormField("Email", "fake_user"); |
491 SetSignFormField("Password", "fake_password"); | 488 SetSignFormField("Password", "fake_password"); |
492 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | 489 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
493 | 490 |
494 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); | 491 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); |
495 | 492 |
496 SendConfirmPassword("fake_password"); | 493 SendConfirmPassword("fake_password"); |
497 content::WindowedNotificationObserver( | 494 content::WindowedNotificationObserver( |
498 chrome::NOTIFICATION_SESSION_STARTED, | 495 chrome::NOTIFICATION_SESSION_STARTED, |
499 content::NotificationService::AllSources()).Wait(); | 496 content::NotificationService::AllSources()).Wait(); |
500 const User* user = UserManager::Get()->GetActiveUser(); | 497 const User* user = UserManager::Get()->GetActiveUser(); |
501 ASSERT_TRUE(user); | 498 ASSERT_TRUE(user); |
502 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); | 499 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); |
503 } | 500 } |
504 | 501 |
| 502 // Tests the password confirm flow: show error on the first failure and |
| 503 // fatal error on the second failure. |
| 504 IN_PROC_BROWSER_TEST_F(SamlTest, PasswordConfirmFlow) { |
| 505 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
| 506 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |
| 507 |
| 508 // Fill-in the SAML IdP form and submit. |
| 509 SetSignFormField("Email", "fake_user"); |
| 510 SetSignFormField("Password", "fake_password"); |
| 511 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); |
| 512 |
| 513 // Lands on confirm password screen with no error message. |
| 514 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); |
| 515 JsExpect("!$('confirm-password').classList.contains('error')"); |
| 516 |
| 517 // Enter an unknown password for the first time should go back to confirm |
| 518 // password screen with error message. |
| 519 SendConfirmPassword("wrong_password"); |
| 520 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); |
| 521 JsExpect("$('confirm-password').classList.contains('error')"); |
| 522 |
| 523 // Enter an unknown password 2nd time should go back to confirm password |
| 524 // screen. |
| 525 SendConfirmPassword("wrong_password"); |
| 526 OobeScreenWaiter(OobeDisplay::SCREEN_FATAL_ERROR).Wait(); |
| 527 } |
| 528 |
505 class SAMLPolicyTest : public SamlTest { | 529 class SAMLPolicyTest : public SamlTest { |
506 public: | 530 public: |
507 SAMLPolicyTest(); | 531 SAMLPolicyTest(); |
508 virtual ~SAMLPolicyTest(); | 532 virtual ~SAMLPolicyTest(); |
509 | 533 |
510 // SamlTest: | 534 // SamlTest: |
511 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 535 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
512 virtual void SetUpOnMainThread() OVERRIDE; | 536 virtual void SetUpOnMainThread() OVERRIDE; |
513 | 537 |
514 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); | 538 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 | 651 |
628 // Verifies that when the offline login time limit is exceeded for a user who | 652 // Verifies that when the offline login time limit is exceeded for a user who |
629 // authenticated via SAML, that user is forced to log in online the next time. | 653 // authenticated via SAML, that user is forced to log in online the next time. |
630 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLZeroLimit) { | 654 IN_PROC_BROWSER_TEST_F(SAMLPolicyTest, SAMLZeroLimit) { |
631 login_screen_load_observer_->Wait(); | 655 login_screen_load_observer_->Wait(); |
632 // Verify that offline login is not allowed. | 656 // Verify that offline login is not allowed. |
633 JsExpect("!document.querySelector('#pod-row .signin-button').hidden"); | 657 JsExpect("!document.querySelector('#pod-row .signin-button').hidden"); |
634 } | 658 } |
635 | 659 |
636 } // namespace chromeos | 660 } // namespace chromeos |
OLD | NEW |