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 <cstring> | |
6 | |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 9 #include "base/callback.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/files/scoped_temp_dir.h" | |
11 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
14 #include "base/path_service.h" | 18 #include "base/path_service.h" |
15 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
16 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
17 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
20 #include "base/values.h" | 24 #include "base/values.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
22 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 26 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
23 #include "chrome/browser/chromeos/login/test/https_forwarder.h" | 27 #include "chrome/browser/chromeos/login/test/https_forwarder.h" |
24 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 28 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
25 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 29 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
26 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 30 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
27 #include "chrome/browser/chromeos/login/wizard_controller.h" | 31 #include "chrome/browser/chromeos/login/wizard_controller.h" |
28 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 32 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
29 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 33 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
30 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 34 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
31 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 35 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
32 #include "chrome/browser/chromeos/settings/cros_settings.h" | 36 #include "chrome/browser/chromeos/settings/cros_settings.h" |
33 #include "chrome/browser/lifetime/application_lifetime.h" | 37 #include "chrome/browser/lifetime/application_lifetime.h" |
38 #include "chrome/browser/policy/test/local_policy_test_server.h" | |
34 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
35 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" | 40 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
36 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
37 #include "chrome/common/chrome_switches.h" | 42 #include "chrome/common/chrome_switches.h" |
38 #include "chrome/grit/generated_resources.h" | 43 #include "chrome/grit/generated_resources.h" |
39 #include "chrome/test/base/in_process_browser_test.h" | 44 #include "chrome/test/base/in_process_browser_test.h" |
40 #include "chromeos/chromeos_switches.h" | 45 #include "chromeos/chromeos_switches.h" |
41 #include "chromeos/dbus/dbus_thread_manager.h" | 46 #include "chromeos/dbus/dbus_thread_manager.h" |
42 #include "chromeos/dbus/fake_session_manager_client.h" | 47 #include "chromeos/dbus/fake_session_manager_client.h" |
43 #include "chromeos/dbus/session_manager_client.h" | 48 #include "chromeos/dbus/session_manager_client.h" |
44 #include "chromeos/settings/cros_settings_names.h" | 49 #include "chromeos/settings/cros_settings_names.h" |
45 #include "components/policy/core/browser/browser_policy_connector.h" | 50 #include "components/policy/core/browser/browser_policy_connector.h" |
46 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 51 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
47 #include "components/policy/core/common/policy_map.h" | 52 #include "components/policy/core/common/policy_map.h" |
53 #include "components/policy/core/common/policy_switches.h" | |
48 #include "components/policy/core/common/policy_types.h" | 54 #include "components/policy/core/common/policy_types.h" |
49 #include "components/user_manager/user.h" | 55 #include "components/user_manager/user.h" |
50 #include "components/user_manager/user_manager.h" | 56 #include "components/user_manager/user_manager.h" |
51 #include "content/public/browser/browser_thread.h" | 57 #include "content/public/browser/browser_thread.h" |
58 #include "content/public/browser/render_frame_host.h" | |
52 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
60 #include "content/public/browser/web_contents_observer.h" | |
53 #include "content/public/test/browser_test_utils.h" | 61 #include "content/public/test/browser_test_utils.h" |
54 #include "content/public/test/test_utils.h" | 62 #include "content/public/test/test_utils.h" |
55 #include "google_apis/gaia/fake_gaia.h" | 63 #include "google_apis/gaia/fake_gaia.h" |
64 #include "google_apis/gaia/gaia_constants.h" | |
56 #include "google_apis/gaia/gaia_switches.h" | 65 #include "google_apis/gaia/gaia_switches.h" |
66 #include "google_apis/gaia/gaia_urls.h" | |
57 #include "net/base/url_util.h" | 67 #include "net/base/url_util.h" |
58 #include "net/cookies/canonical_cookie.h" | 68 #include "net/cookies/canonical_cookie.h" |
59 #include "net/cookies/cookie_monster.h" | 69 #include "net/cookies/cookie_monster.h" |
60 #include "net/cookies/cookie_store.h" | 70 #include "net/cookies/cookie_store.h" |
61 #include "net/dns/mock_host_resolver.h" | 71 #include "net/dns/mock_host_resolver.h" |
62 #include "net/test/embedded_test_server/embedded_test_server.h" | 72 #include "net/test/embedded_test_server/embedded_test_server.h" |
63 #include "net/test/embedded_test_server/http_request.h" | 73 #include "net/test/embedded_test_server/http_request.h" |
64 #include "net/test/embedded_test_server/http_response.h" | 74 #include "net/test/embedded_test_server/http_response.h" |
65 #include "net/url_request/url_request_context.h" | 75 #include "net/url_request/url_request_context.h" |
66 #include "net/url_request/url_request_context_getter.h" | 76 #include "net/url_request/url_request_context_getter.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
96 const char kHTTPSAMLUserEmail[] = "carol@example.com"; | 106 const char kHTTPSAMLUserEmail[] = "carol@example.com"; |
97 const char kNonSAMLUserEmail[] = "dan@example.com"; | 107 const char kNonSAMLUserEmail[] = "dan@example.com"; |
98 const char kDifferentDomainSAMLUserEmail[] = "eve@example.test"; | 108 const char kDifferentDomainSAMLUserEmail[] = "eve@example.test"; |
99 | 109 |
100 const char kSAMLIdPCookieName[] = "saml"; | 110 const char kSAMLIdPCookieName[] = "saml"; |
101 const char kSAMLIdPCookieValue1[] = "value-1"; | 111 const char kSAMLIdPCookieValue1[] = "value-1"; |
102 const char kSAMLIdPCookieValue2[] = "value-2"; | 112 const char kSAMLIdPCookieValue2[] = "value-2"; |
103 | 113 |
104 const char kRelayState[] = "RelayState"; | 114 const char kRelayState[] = "RelayState"; |
105 | 115 |
116 const char kTestUserinfoToken[] = "fake-userinfo-token"; | |
117 const char kTestRefreshToken[] = "fake-refresh-token"; | |
118 const char kPolicy[] = "{\"managed_users\": [\"*\"]}"; | |
119 | |
106 // FakeSamlIdp serves IdP auth form and the form submission. The form is | 120 // FakeSamlIdp serves IdP auth form and the form submission. The form is |
107 // served with the template's RelayState placeholder expanded to the real | 121 // served with the template's RelayState placeholder expanded to the real |
108 // RelayState parameter from request. The form submission redirects back to | 122 // RelayState parameter from request. The form submission redirects back to |
109 // FakeGaia with the same RelayState. | 123 // FakeGaia with the same RelayState. |
110 class FakeSamlIdp { | 124 class FakeSamlIdp { |
111 public: | 125 public: |
112 FakeSamlIdp(); | 126 FakeSamlIdp(); |
113 ~FakeSamlIdp(); | 127 ~FakeSamlIdp(); |
114 | 128 |
115 void SetUp(const std::string& base_path, const GURL& gaia_url); | 129 void SetUp(const std::string& base_path, const GURL& gaia_url); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 http_response->set_content(response_html); | 249 http_response->set_content(response_html); |
236 http_response->set_content_type("text/html"); | 250 http_response->set_content_type("text/html"); |
237 | 251 |
238 return http_response.Pass(); | 252 return http_response.Pass(); |
239 } | 253 } |
240 | 254 |
241 } // namespace | 255 } // namespace |
242 | 256 |
243 class SamlTest : public InProcessBrowserTest { | 257 class SamlTest : public InProcessBrowserTest { |
244 public: | 258 public: |
245 SamlTest() : saml_load_injected_(false) {} | 259 SamlTest() : gaia_frame_parent_("signin-frame"), saml_load_injected_(false) {} |
246 virtual ~SamlTest() {} | 260 virtual ~SamlTest() {} |
247 | 261 |
248 virtual void SetUp() override { | 262 virtual void SetUp() override { |
249 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 263 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
250 | 264 |
251 // Start the GAIA https wrapper here so that the GAIA URLs can be pointed at | 265 // Start the GAIA https wrapper here so that the GAIA URLs can be pointed at |
252 // it in SetUpCommandLine(). | 266 // it in SetUpCommandLine(). |
253 gaia_https_forwarder_.reset( | 267 gaia_https_forwarder_.reset( |
254 new HTTPSForwarder(embedded_test_server()->base_url())); | 268 new HTTPSForwarder(embedded_test_server()->base_url())); |
255 ASSERT_TRUE(gaia_https_forwarder_->Start()); | 269 ASSERT_TRUE(gaia_https_forwarder_->Start()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 WizardController* wizard_controller = | 347 WizardController* wizard_controller = |
334 WizardController::default_controller(); | 348 WizardController::default_controller(); |
335 if (wizard_controller) { | 349 if (wizard_controller) { |
336 WizardController::SkipPostLoginScreensForTesting(); | 350 WizardController::SkipPostLoginScreensForTesting(); |
337 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); | 351 wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
338 } | 352 } |
339 | 353 |
340 login_screen_load_observer_->Wait(); | 354 login_screen_load_observer_->Wait(); |
341 } | 355 } |
342 | 356 |
343 void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) { | 357 virtual void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) { |
344 WaitForSigninScreen(); | 358 WaitForSigninScreen(); |
345 | 359 |
346 if (!saml_load_injected_) { | 360 if (!saml_load_injected_) { |
347 saml_load_injected_ = true; | 361 saml_load_injected_ = true; |
348 | 362 |
349 ASSERT_TRUE(content::ExecuteScript( | 363 ASSERT_TRUE(content::ExecuteScript( |
350 GetLoginUI()->GetWebContents(), | 364 GetLoginUI()->GetWebContents(), |
351 "$('gaia-signin').gaiaAuthHost_.addEventListener('authFlowChange'," | 365 "$('gaia-signin').gaiaAuthHost_.addEventListener('authFlowChange'," |
352 "function() {" | 366 "function() {" |
353 "window.domAutomationController.setAutomationId(0);" | 367 "window.domAutomationController.setAutomationId(0);" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 } | 422 } |
409 | 423 |
410 content::WebUI* GetLoginUI() { | 424 content::WebUI* GetLoginUI() { |
411 return static_cast<LoginDisplayHostImpl*>( | 425 return static_cast<LoginDisplayHostImpl*>( |
412 LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui(); | 426 LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui(); |
413 } | 427 } |
414 | 428 |
415 // Executes JavaScript code in the auth iframe hosted by gaia_auth extension. | 429 // Executes JavaScript code in the auth iframe hosted by gaia_auth extension. |
416 void ExecuteJsInSigninFrame(const std::string& js) { | 430 void ExecuteJsInSigninFrame(const std::string& js) { |
417 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe( | 431 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe( |
418 GetLoginUI()->GetWebContents(), GURL(), "signin-frame"); | 432 GetLoginUI()->GetWebContents(), GURL(), gaia_frame_parent_); |
419 ASSERT_TRUE(content::ExecuteScript(frame, js)); | 433 ASSERT_TRUE(content::ExecuteScript(frame, js)); |
420 } | 434 } |
421 | 435 |
422 FakeSamlIdp* fake_saml_idp() { return &fake_saml_idp_; } | 436 FakeSamlIdp* fake_saml_idp() { return &fake_saml_idp_; } |
423 | 437 |
424 protected: | 438 protected: |
425 scoped_ptr<content::WindowedNotificationObserver> login_screen_load_observer_; | 439 scoped_ptr<content::WindowedNotificationObserver> login_screen_load_observer_; |
426 FakeGaia fake_gaia_; | 440 FakeGaia fake_gaia_; |
427 | 441 |
442 std::string gaia_frame_parent_; | |
443 | |
444 scoped_ptr<HTTPSForwarder> gaia_https_forwarder_; | |
445 scoped_ptr<HTTPSForwarder> saml_https_forwarder_; | |
446 | |
428 private: | 447 private: |
429 FakeSamlIdp fake_saml_idp_; | 448 FakeSamlIdp fake_saml_idp_; |
430 scoped_ptr<HTTPSForwarder> gaia_https_forwarder_; | |
431 scoped_ptr<HTTPSForwarder> saml_https_forwarder_; | |
432 | 449 |
433 bool saml_load_injected_; | 450 bool saml_load_injected_; |
434 | 451 |
435 DISALLOW_COPY_AND_ASSIGN(SamlTest); | 452 DISALLOW_COPY_AND_ASSIGN(SamlTest); |
436 }; | 453 }; |
437 | 454 |
438 // Tests that signin frame should have 'saml' class and 'cancel' button is | 455 // Tests that signin frame should have 'saml' class and 'cancel' button is |
439 // visible when SAML IdP page is loaded. And 'cancel' button goes back to | 456 // visible when SAML IdP page is loaded. And 'cancel' button goes back to |
440 // gaia on clicking. | 457 // gaia on clicking. |
441 IN_PROC_BROWSER_TEST_F(SamlTest, SamlUI) { | 458 IN_PROC_BROWSER_TEST_F(SamlTest, SamlUI) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 | 649 |
633 WaitForSigninScreen(); | 650 WaitForSigninScreen(); |
634 GetLoginDisplay()->ShowSigninScreenForCreds(kFirstSAMLUserEmail, ""); | 651 GetLoginDisplay()->ShowSigninScreenForCreds(kFirstSAMLUserEmail, ""); |
635 | 652 |
636 EXPECT_EQ(l10n_util::GetStringFUTF8( | 653 EXPECT_EQ(l10n_util::GetStringFUTF8( |
637 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL, | 654 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL, |
638 base::UTF8ToUTF16(url.spec())), | 655 base::UTF8ToUTF16(url.spec())), |
639 WaitForAndGetFatalErrorMessage()); | 656 WaitForAndGetFatalErrorMessage()); |
640 } | 657 } |
641 | 658 |
659 class SAMLEnrollmentTest : public SamlTest, | |
660 public content::WebContentsObserver { | |
661 public: | |
662 SAMLEnrollmentTest(); | |
663 ~SAMLEnrollmentTest() override; | |
664 | |
665 // SamlTest: | |
666 void SetUp() override; | |
667 void SetUpCommandLine(CommandLine* command_line) override; | |
668 void SetUpOnMainThread() override; | |
669 void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) override; | |
670 | |
671 // content::WebContentsObserver: | |
672 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | |
673 void DidFinishLoad(content::RenderFrameHost* render_frame_host, | |
674 const GURL& validated_url) override; | |
675 | |
676 void WaitForEnrollmentSuccess(); | |
677 | |
678 private: | |
679 scoped_ptr<policy::LocalPolicyTestServer> test_server_; | |
680 base::ScopedTempDir temp_dir_; | |
681 | |
682 scoped_ptr<base::RunLoop> run_loop_; | |
683 content::RenderFrameHost* auth_frame_; | |
684 | |
685 DISALLOW_COPY_AND_ASSIGN(SAMLEnrollmentTest); | |
686 }; | |
687 | |
688 SAMLEnrollmentTest::SAMLEnrollmentTest() : auth_frame_(nullptr) { | |
689 gaia_frame_parent_ = "oauth-enroll-signin-frame"; | |
690 } | |
691 | |
692 SAMLEnrollmentTest::~SAMLEnrollmentTest() { | |
693 } | |
694 | |
695 void SAMLEnrollmentTest::SetUp() { | |
696 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
697 const base::FilePath policy_file = | |
698 temp_dir_.path().AppendASCII("policy.json"); | |
699 ASSERT_EQ(static_cast<int>(strlen(kPolicy)), | |
Mattias Nissler (ping if slow)
2014/12/04 19:46:02
If I'm not mistaken, you can just use sizeof inste
bartfab (slow)
2014/12/05 12:34:36
I can use |sizeof(kPolicy) - 1| but that feels mor
Mattias Nissler (ping if slow)
2014/12/05 13:07:09
Well, then the test would fail. Anyhow, fair enoug
| |
700 base::WriteFile(policy_file, kPolicy, strlen(kPolicy))); | |
701 | |
702 test_server_.reset(new policy::LocalPolicyTestServer(policy_file)); | |
703 ASSERT_TRUE(test_server_->Start()); | |
704 | |
705 SamlTest::SetUp(); | |
706 } | |
707 | |
708 void SAMLEnrollmentTest::SetUpCommandLine(CommandLine* command_line) { | |
709 command_line->AppendSwitchASCII(policy::switches::kDeviceManagementUrl, | |
710 test_server_->GetServiceURL().spec()); | |
711 command_line->AppendSwitch(policy::switches::kDisablePolicyKeyVerification); | |
712 command_line->AppendSwitch(switches::kEnterpriseEnrollmentSkipRobotAuth); | |
Mattias Nissler (ping if slow)
2014/12/04 19:46:02
Any good reason for this?
bartfab (slow)
2014/12/05 12:34:36
The robot account generation code causes an OAuth
Mattias Nissler (ping if slow)
2014/12/05 13:07:09
If I ever get to write an end-to-end FRE/enrollmen
bartfab (slow)
2014/12/15 17:10:21
Done.
| |
713 | |
714 SamlTest::SetUpCommandLine(command_line); | |
715 } | |
716 | |
717 void SAMLEnrollmentTest::SetUpOnMainThread() { | |
718 Observe(GetLoginUI()->GetWebContents()); | |
719 | |
720 FakeGaia::AccessTokenInfo token_info; | |
721 token_info.token = kTestUserinfoToken; | |
722 token_info.scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth); | |
723 token_info.scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope); | |
724 token_info.audience = GaiaUrls::GetInstance()->oauth2_chrome_client_id(); | |
725 token_info.email = kFirstSAMLUserEmail; | |
726 fake_gaia_.IssueOAuthToken(kTestRefreshToken, token_info); | |
727 | |
728 SamlTest::SetUpOnMainThread(); | |
729 } | |
730 | |
731 void SAMLEnrollmentTest::StartSamlAndWaitForIdpPageLoad( | |
732 const std::string& gaia_email) { | |
733 WaitForSigninScreen(); | |
734 run_loop_.reset(new base::RunLoop); | |
735 ExistingUserController::current_controller()->OnStartEnterpriseEnrollment(); | |
736 run_loop_->Run(); | |
737 | |
738 SetSignFormField("Email", gaia_email); | |
739 | |
740 run_loop_.reset(new base::RunLoop); | |
741 ExecuteJsInSigninFrame("document.getElementById('signIn').click();"); | |
742 run_loop_->Run(); | |
743 } | |
744 | |
745 void SAMLEnrollmentTest::RenderFrameCreated( | |
746 content::RenderFrameHost* render_frame_host) { | |
747 content::RenderFrameHost* parent = render_frame_host->GetParent(); | |
748 if (!parent || parent->GetFrameName() != gaia_frame_parent_) | |
749 return; | |
750 | |
751 // The GAIA extension created the iframe in which the login form will be | |
752 // shown. Now wait for the login form to finish loading. | |
753 auth_frame_ = render_frame_host; | |
754 Observe(content::WebContents::FromRenderFrameHost(auth_frame_)); | |
755 } | |
756 | |
757 void SAMLEnrollmentTest::DidFinishLoad( | |
758 content::RenderFrameHost* render_frame_host, | |
759 const GURL& validated_url) { | |
760 if (render_frame_host != auth_frame_) | |
761 return; | |
762 | |
763 const GURL origin = validated_url.GetOrigin(); | |
764 if (origin != gaia_https_forwarder_->GetURL("") && | |
765 origin != saml_https_forwarder_->GetURL("")) { | |
766 return; | |
767 } | |
768 | |
769 // The GAIA or SAML IdP login form finished loading. | |
770 if (run_loop_) | |
771 run_loop_->Quit(); | |
772 } | |
773 | |
774 // Waits until the class |oauth-enroll-state-success| becomes set for the | |
775 // enrollment screen, indicating enrollment success. | |
776 void SAMLEnrollmentTest::WaitForEnrollmentSuccess() { | |
Mattias Nissler (ping if slow)
2014/12/04 19:46:02
Instead of this, why not just observe DeviceCloudP
bartfab (slow)
2014/12/05 12:34:36
This verifies that the enrollment success reaches
Mattias Nissler (ping if slow)
2014/12/05 13:07:09
OK, fair enough. Might additionally want to click
bartfab (slow)
2014/12/15 17:10:21
I had a look. We cannot get at the exit code becau
| |
777 bool done = false; | |
778 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
779 GetLoginUI()->GetWebContents(), | |
780 "var enrollmentScreen = document.getElementById('oauth-enrollment');" | |
781 "function SendReplyIfEnrollmentDone() {" | |
782 " if (!enrollmentScreen.classList.contains(" | |
783 " 'oauth-enroll-state-success')) {" | |
784 " return false;" | |
785 " }" | |
786 " domAutomationController.send(true);" | |
787 " observer.disconnect();" | |
788 " return true;" | |
789 "}" | |
790 "var observer = new MutationObserver(SendReplyIfEnrollmentDone);" | |
791 "if (!SendReplyIfEnrollmentDone()) {" | |
792 " var options = { attributes: true, attributeFilter: [ 'class' ] };" | |
793 " observer.observe(enrollmentScreen, options);" | |
794 "}", | |
795 &done)); | |
796 } | |
797 | |
798 IN_PROC_BROWSER_TEST_F(SAMLEnrollmentTest, WithoutCredentialsPassingAPI) { | |
799 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | |
800 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | |
801 | |
802 // Fill-in the SAML IdP form and submit. | |
803 SetSignFormField("Email", "fake_user"); | |
804 SetSignFormField("Password", "fake_password"); | |
805 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | |
806 | |
807 WaitForEnrollmentSuccess(); | |
808 } | |
809 | |
810 IN_PROC_BROWSER_TEST_F(SAMLEnrollmentTest, WithCredentialsPassingAPI) { | |
811 fake_saml_idp()->SetLoginHTMLTemplate("saml_api_login.html"); | |
812 fake_saml_idp()->SetLoginAuthHTMLTemplate("saml_api_login_auth.html"); | |
813 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | |
814 | |
815 // Fill-in the SAML IdP form and submit. | |
816 SetSignFormField("Email", "fake_user"); | |
817 SetSignFormField("Password", "fake_password"); | |
818 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); | |
819 | |
820 WaitForEnrollmentSuccess(); | |
821 } | |
822 | |
642 class SAMLPolicyTest : public SamlTest { | 823 class SAMLPolicyTest : public SamlTest { |
643 public: | 824 public: |
644 SAMLPolicyTest(); | 825 SAMLPolicyTest(); |
645 virtual ~SAMLPolicyTest(); | 826 virtual ~SAMLPolicyTest(); |
646 | 827 |
647 // SamlTest: | 828 // SamlTest: |
648 virtual void SetUpInProcessBrowserTestFixture() override; | 829 virtual void SetUpInProcessBrowserTestFixture() override; |
649 virtual void SetUpOnMainThread() override; | 830 virtual void SetUpOnMainThread() override; |
650 | 831 |
651 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); | 832 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
953 kTestAuthSIDCookie1, | 1134 kTestAuthSIDCookie1, |
954 kTestAuthLSIDCookie1); | 1135 kTestAuthLSIDCookie1); |
955 | 1136 |
956 GetCookies(); | 1137 GetCookies(); |
957 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 1138 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
958 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 1139 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
959 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); | 1140 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
960 } | 1141 } |
961 | 1142 |
962 } // namespace chromeos | 1143 } // namespace chromeos |
OLD | NEW |