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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 return http_response.PassAs<HttpResponse>(); | 238 return http_response.PassAs<HttpResponse>(); |
239 } | 239 } |
240 | 240 |
241 } // namespace | 241 } // namespace |
242 | 242 |
243 class SamlTest : public InProcessBrowserTest { | 243 class SamlTest : public InProcessBrowserTest { |
244 public: | 244 public: |
245 SamlTest() : saml_load_injected_(false) {} | 245 SamlTest() : saml_load_injected_(false) {} |
246 virtual ~SamlTest() {} | 246 virtual ~SamlTest() {} |
247 | 247 |
248 virtual void SetUp() OVERRIDE { | 248 virtual void SetUp() override { |
249 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 249 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
250 | 250 |
251 // Start the GAIA https wrapper here so that the GAIA URLs can be pointed at | 251 // Start the GAIA https wrapper here so that the GAIA URLs can be pointed at |
252 // it in SetUpCommandLine(). | 252 // it in SetUpCommandLine(). |
253 gaia_https_forwarder_.reset( | 253 gaia_https_forwarder_.reset( |
254 new HTTPSForwarder(embedded_test_server()->base_url())); | 254 new HTTPSForwarder(embedded_test_server()->base_url())); |
255 ASSERT_TRUE(gaia_https_forwarder_->Start()); | 255 ASSERT_TRUE(gaia_https_forwarder_->Start()); |
256 | 256 |
257 // Start the SAML IdP https wrapper here so that GAIA can be pointed at it | 257 // Start the SAML IdP https wrapper here so that GAIA can be pointed at it |
258 // in SetUpCommandLine(). | 258 // in SetUpCommandLine(). |
259 saml_https_forwarder_.reset( | 259 saml_https_forwarder_.reset( |
260 new HTTPSForwarder(embedded_test_server()->base_url())); | 260 new HTTPSForwarder(embedded_test_server()->base_url())); |
261 ASSERT_TRUE(saml_https_forwarder_->Start()); | 261 ASSERT_TRUE(saml_https_forwarder_->Start()); |
262 | 262 |
263 // Stop IO thread here because no threads are allowed while | 263 // Stop IO thread here because no threads are allowed while |
264 // spawning sandbox host process. See crbug.com/322732. | 264 // spawning sandbox host process. See crbug.com/322732. |
265 embedded_test_server()->StopThread(); | 265 embedded_test_server()->StopThread(); |
266 | 266 |
267 InProcessBrowserTest::SetUp(); | 267 InProcessBrowserTest::SetUp(); |
268 } | 268 } |
269 | 269 |
270 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 270 virtual void SetUpInProcessBrowserTestFixture() override { |
271 host_resolver()->AddRule("*", "127.0.0.1"); | 271 host_resolver()->AddRule("*", "127.0.0.1"); |
272 } | 272 } |
273 | 273 |
274 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 274 virtual void SetUpCommandLine(CommandLine* command_line) override { |
275 command_line->AppendSwitch(switches::kLoginManager); | 275 command_line->AppendSwitch(switches::kLoginManager); |
276 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | 276 command_line->AppendSwitch(switches::kForceLoginManagerInTests); |
277 command_line->AppendSwitch(::switches::kDisableBackgroundNetworking); | 277 command_line->AppendSwitch(::switches::kDisableBackgroundNetworking); |
278 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 278 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
279 | 279 |
280 const GURL gaia_url = gaia_https_forwarder_->GetURL(""); | 280 const GURL gaia_url = gaia_https_forwarder_->GetURL(""); |
281 command_line->AppendSwitchASCII(::switches::kGaiaUrl, gaia_url.spec()); | 281 command_line->AppendSwitchASCII(::switches::kGaiaUrl, gaia_url.spec()); |
282 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url.spec()); | 282 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url.spec()); |
283 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl, | 283 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl, |
284 gaia_url.spec()); | 284 gaia_url.spec()); |
285 | 285 |
286 const GURL saml_idp_url = saml_https_forwarder_->GetURL("SAML"); | 286 const GURL saml_idp_url = saml_https_forwarder_->GetURL("SAML"); |
287 fake_saml_idp_.SetUp(saml_idp_url.path(), gaia_url); | 287 fake_saml_idp_.SetUp(saml_idp_url.path(), gaia_url); |
288 fake_gaia_.RegisterSamlUser(kFirstSAMLUserEmail, saml_idp_url); | 288 fake_gaia_.RegisterSamlUser(kFirstSAMLUserEmail, saml_idp_url); |
289 fake_gaia_.RegisterSamlUser(kSecondSAMLUserEmail, saml_idp_url); | 289 fake_gaia_.RegisterSamlUser(kSecondSAMLUserEmail, saml_idp_url); |
290 fake_gaia_.RegisterSamlUser( | 290 fake_gaia_.RegisterSamlUser( |
291 kHTTPSAMLUserEmail, | 291 kHTTPSAMLUserEmail, |
292 embedded_test_server()->base_url().Resolve("/SAML")); | 292 embedded_test_server()->base_url().Resolve("/SAML")); |
293 fake_gaia_.RegisterSamlUser(kDifferentDomainSAMLUserEmail, saml_idp_url); | 293 fake_gaia_.RegisterSamlUser(kDifferentDomainSAMLUserEmail, saml_idp_url); |
294 | 294 |
295 fake_gaia_.Initialize(); | 295 fake_gaia_.Initialize(); |
296 } | 296 } |
297 | 297 |
298 virtual void SetUpOnMainThread() OVERRIDE { | 298 virtual void SetUpOnMainThread() override { |
299 fake_gaia_.SetFakeMergeSessionParams(kFirstSAMLUserEmail, | 299 fake_gaia_.SetFakeMergeSessionParams(kFirstSAMLUserEmail, |
300 kTestAuthSIDCookie1, | 300 kTestAuthSIDCookie1, |
301 kTestAuthLSIDCookie1); | 301 kTestAuthLSIDCookie1); |
302 | 302 |
303 embedded_test_server()->RegisterRequestHandler( | 303 embedded_test_server()->RegisterRequestHandler( |
304 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); | 304 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); |
305 embedded_test_server()->RegisterRequestHandler(base::Bind( | 305 embedded_test_server()->RegisterRequestHandler(base::Bind( |
306 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); | 306 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); |
307 | 307 |
308 // Restart the thread as the sandbox host process has already been spawned. | 308 // Restart the thread as the sandbox host process has already been spawned. |
309 embedded_test_server()->RestartThreadAndListen(); | 309 embedded_test_server()->RestartThreadAndListen(); |
310 | 310 |
311 login_screen_load_observer_.reset(new content::WindowedNotificationObserver( | 311 login_screen_load_observer_.reset(new content::WindowedNotificationObserver( |
312 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 312 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
313 content::NotificationService::AllSources())); | 313 content::NotificationService::AllSources())); |
314 } | 314 } |
315 | 315 |
316 virtual void TearDownOnMainThread() OVERRIDE { | 316 virtual void TearDownOnMainThread() override { |
317 // If the login display is still showing, exit gracefully. | 317 // If the login display is still showing, exit gracefully. |
318 if (LoginDisplayHostImpl::default_host()) { | 318 if (LoginDisplayHostImpl::default_host()) { |
319 base::MessageLoop::current()->PostTask(FROM_HERE, | 319 base::MessageLoop::current()->PostTask(FROM_HERE, |
320 base::Bind(&chrome::AttemptExit)); | 320 base::Bind(&chrome::AttemptExit)); |
321 content::RunMessageLoop(); | 321 content::RunMessageLoop(); |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 WebUILoginDisplay* GetLoginDisplay() { | 325 WebUILoginDisplay* GetLoginDisplay() { |
326 ExistingUserController* controller = | 326 ExistingUserController* controller = |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 base::UTF8ToUTF16(url.spec())), | 638 base::UTF8ToUTF16(url.spec())), |
639 WaitForAndGetFatalErrorMessage()); | 639 WaitForAndGetFatalErrorMessage()); |
640 } | 640 } |
641 | 641 |
642 class SAMLPolicyTest : public SamlTest { | 642 class SAMLPolicyTest : public SamlTest { |
643 public: | 643 public: |
644 SAMLPolicyTest(); | 644 SAMLPolicyTest(); |
645 virtual ~SAMLPolicyTest(); | 645 virtual ~SAMLPolicyTest(); |
646 | 646 |
647 // SamlTest: | 647 // SamlTest: |
648 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 648 virtual void SetUpInProcessBrowserTestFixture() override; |
649 virtual void SetUpOnMainThread() OVERRIDE; | 649 virtual void SetUpOnMainThread() override; |
650 | 650 |
651 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); | 651 void SetSAMLOfflineSigninTimeLimitPolicy(int limit); |
652 void EnableTransferSAMLCookiesPolicy(); | 652 void EnableTransferSAMLCookiesPolicy(); |
653 | 653 |
654 void ShowGAIALoginForm(); | 654 void ShowGAIALoginForm(); |
655 void LogInWithSAML(const std::string& user_id, | 655 void LogInWithSAML(const std::string& user_id, |
656 const std::string& auth_sid_cookie, | 656 const std::string& auth_sid_cookie, |
657 const std::string& auth_lsid_cookie); | 657 const std::string& auth_lsid_cookie); |
658 | 658 |
659 std::string GetCookieValue(const std::string& name); | 659 std::string GetCookieValue(const std::string& name); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 kTestAuthSIDCookie1, | 953 kTestAuthSIDCookie1, |
954 kTestAuthLSIDCookie1); | 954 kTestAuthLSIDCookie1); |
955 | 955 |
956 GetCookies(); | 956 GetCookies(); |
957 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 957 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
958 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 958 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
959 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); | 959 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
960 } | 960 } |
961 | 961 |
962 } // namespace chromeos | 962 } // namespace chromeos |
OLD | NEW |