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> | 5 #include <cstring> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 "Set-cookie", | 248 "Set-cookie", |
249 base::StringPrintf("saml=%s", cookie_value_.c_str())); | 249 base::StringPrintf("saml=%s", cookie_value_.c_str())); |
250 return http_response.Pass(); | 250 return http_response.Pass(); |
251 } | 251 } |
252 | 252 |
253 scoped_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse( | 253 scoped_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse( |
254 const std::string& html_template, | 254 const std::string& html_template, |
255 const std::string& relay_state, | 255 const std::string& relay_state, |
256 const std::string& next_path) { | 256 const std::string& next_path) { |
257 std::string response_html = html_template; | 257 std::string response_html = html_template; |
258 ReplaceSubstringsAfterOffset(&response_html, 0, "$RelayState", relay_state); | 258 base::ReplaceSubstringsAfterOffset( |
259 ReplaceSubstringsAfterOffset(&response_html, 0, "$Post", next_path); | 259 &response_html, 0, "$RelayState", relay_state); |
260 ReplaceSubstringsAfterOffset( | 260 base::ReplaceSubstringsAfterOffset( |
| 261 &response_html, 0, "$Post", next_path); |
| 262 base::ReplaceSubstringsAfterOffset( |
261 &response_html, 0, "$Refresh", refresh_url_.spec()); | 263 &response_html, 0, "$Refresh", refresh_url_.spec()); |
262 | 264 |
263 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); | 265 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); |
264 http_response->set_code(net::HTTP_OK); | 266 http_response->set_code(net::HTTP_OK); |
265 http_response->set_content(response_html); | 267 http_response->set_content(response_html); |
266 http_response->set_content_type("text/html"); | 268 http_response->set_content_type("text/html"); |
267 | 269 |
268 return http_response.Pass(); | 270 return http_response.Pass(); |
269 } | 271 } |
270 | 272 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 | 370 |
369 std::string message; | 371 std::string message; |
370 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 372 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
371 EXPECT_EQ("\"SamlLoaded\"", message); | 373 EXPECT_EQ("\"SamlLoaded\"", message); |
372 } | 374 } |
373 | 375 |
374 void SendConfirmPassword(const std::string& password_to_confirm) { | 376 void SendConfirmPassword(const std::string& password_to_confirm) { |
375 std::string js = | 377 std::string js = |
376 "$('confirm-password-input').value='$Password';" | 378 "$('confirm-password-input').value='$Password';" |
377 "$('confirm-password').onConfirmPassword_();"; | 379 "$('confirm-password').onConfirmPassword_();"; |
378 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password_to_confirm); | 380 base::ReplaceSubstringsAfterOffset( |
| 381 &js, 0, "$Password", password_to_confirm); |
379 ASSERT_TRUE(content::ExecuteScript(GetLoginUI()->GetWebContents(), js)); | 382 ASSERT_TRUE(content::ExecuteScript(GetLoginUI()->GetWebContents(), js)); |
380 } | 383 } |
381 | 384 |
382 std::string WaitForAndGetFatalErrorMessage() { | 385 std::string WaitForAndGetFatalErrorMessage() { |
383 OobeScreenWaiter(OobeDisplay::SCREEN_FATAL_ERROR).Wait(); | 386 OobeScreenWaiter(OobeDisplay::SCREEN_FATAL_ERROR).Wait(); |
384 std::string error_message; | 387 std::string error_message; |
385 if (!content::ExecuteScriptAndExtractString( | 388 if (!content::ExecuteScriptAndExtractString( |
386 GetLoginUI()->GetWebContents(), | 389 GetLoginUI()->GetWebContents(), |
387 "window.domAutomationController.send(" | 390 "window.domAutomationController.send(" |
388 "$('fatal-error-message').textContent);", | 391 "$('fatal-error-message').textContent);", |
(...skipping 26 matching lines...) Expand all Loading... |
415 // visible when SAML IdP page is loaded. And 'cancel' button goes back to | 418 // visible when SAML IdP page is loaded. And 'cancel' button goes back to |
416 // gaia on clicking. | 419 // gaia on clicking. |
417 IN_PROC_BROWSER_TEST_P(SamlTest, SamlUI) { | 420 IN_PROC_BROWSER_TEST_P(SamlTest, SamlUI) { |
418 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 421 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |
419 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | 422 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |
420 | 423 |
421 // Saml flow UI expectations. | 424 // Saml flow UI expectations. |
422 JsExpect("$('gaia-signin').classList.contains('full-width')"); | 425 JsExpect("$('gaia-signin').classList.contains('full-width')"); |
423 JsExpect("!$('saml-notice-container').hidden"); | 426 JsExpect("!$('saml-notice-container').hidden"); |
424 std::string js = "$('saml-notice-message').textContent.indexOf('$Host') > -1"; | 427 std::string js = "$('saml-notice-message').textContent.indexOf('$Host') > -1"; |
425 ReplaceSubstringsAfterOffset(&js, 0, "$Host", kIdPHost); | 428 base::ReplaceSubstringsAfterOffset(&js, 0, "$Host", kIdPHost); |
426 JsExpect(js); | 429 JsExpect(js); |
427 if (!use_webview()) { | 430 if (!use_webview()) { |
428 JsExpect("!$('cancel-add-user-button').hidden"); | 431 JsExpect("!$('cancel-add-user-button').hidden"); |
429 } | 432 } |
430 | 433 |
431 SetupAuthFlowChangeListener(); | 434 SetupAuthFlowChangeListener(); |
432 | 435 |
433 // Click on 'cancel'. | 436 // Click on 'cancel'. |
434 content::DOMMessageQueue message_queue; // Observe before 'cancel'. | 437 content::DOMMessageQueue message_queue; // Observe before 'cancel'. |
435 if (use_webview()) { | 438 if (use_webview()) { |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 " 'authDomainChange'," | 681 " 'authDomainChange'," |
679 " processEventsAndSendIfHostFound);" | 682 " processEventsAndSendIfHostFound);" |
680 " }" | 683 " }" |
681 " }, 0);" | 684 " }, 0);" |
682 "};" | 685 "};" |
683 "if (!sendIfHostFound()) {" | 686 "if (!sendIfHostFound()) {" |
684 " $('gaia-signin').gaiaAuthHost_.addEventListener(" | 687 " $('gaia-signin').gaiaAuthHost_.addEventListener(" |
685 " 'authDomainChange'," | 688 " 'authDomainChange'," |
686 " processEventsAndSendIfHostFound);" | 689 " processEventsAndSendIfHostFound);" |
687 "}"; | 690 "}"; |
688 ReplaceSubstringsAfterOffset(&js, 0, "$Host", kAdditionalIdPHost); | 691 base::ReplaceSubstringsAfterOffset(&js, 0, "$Host", kAdditionalIdPHost); |
689 bool dummy; | 692 bool dummy; |
690 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 693 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
691 GetLoginUI()->GetWebContents(), js, &dummy)); | 694 GetLoginUI()->GetWebContents(), js, &dummy)); |
692 | 695 |
693 // Verify that the notice is visible. | 696 // Verify that the notice is visible. |
694 JsExpect("!$('saml-notice-container').hidden"); | 697 JsExpect("!$('saml-notice-container').hidden"); |
695 } | 698 } |
696 | 699 |
697 // Verifies that when GAIA attempts to redirect to a SAML IdP served over http, | 700 // Verifies that when GAIA attempts to redirect to a SAML IdP served over http, |
698 // not https, the redirect is blocked and an error message is shown. | 701 // not https, the redirect is blocked and an error message is shown. |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); | 1227 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); |
1225 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); | 1228 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); |
1226 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); | 1229 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); |
1227 } | 1230 } |
1228 | 1231 |
1229 INSTANTIATE_TEST_CASE_P(SamlSuite, | 1232 INSTANTIATE_TEST_CASE_P(SamlSuite, |
1230 SAMLPolicyTest, | 1233 SAMLPolicyTest, |
1231 testing::Bool()); | 1234 testing::Bool()); |
1232 | 1235 |
1233 } // namespace chromeos | 1236 } // namespace chromeos |
OLD | NEW |