Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: chrome/browser/chromeos/login/saml/saml_browsertest.cc

Issue 1054403002: Basic tests for new webview based signin flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove flaky back-button check Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/test/oobe_base_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/json/json_file_value_serializer.h" 14 #include "base/json/json_file_value_serializer.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/run_loop.h" 20 #include "base/run_loop.h"
21 #include "base/strings/string16.h" 21 #include "base/strings/string16.h"
22 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "base/values.h" 25 #include "base/values.h"
26 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
27 #include "chrome/browser/chromeos/login/existing_user_controller.h" 27 #include "chrome/browser/chromeos/login/existing_user_controller.h"
28 #include "chrome/browser/chromeos/login/startup_utils.h" 28 #include "chrome/browser/chromeos/login/startup_utils.h"
29 #include "chrome/browser/chromeos/login/test/https_forwarder.h" 29 #include "chrome/browser/chromeos/login/test/https_forwarder.h"
30 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
30 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" 31 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
31 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 32 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
32 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" 33 #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
33 #include "chrome/browser/chromeos/login/wizard_controller.h" 34 #include "chrome/browser/chromeos/login/wizard_controller.h"
34 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 35 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
35 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 36 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
36 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 37 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
37 #include "chrome/browser/chromeos/profiles/profile_helper.h" 38 #include "chrome/browser/chromeos/profiles/profile_helper.h"
38 #include "chrome/browser/chromeos/settings/cros_settings.h" 39 #include "chrome/browser/chromeos/settings/cros_settings.h"
39 #include "chrome/browser/lifetime/application_lifetime.h"
40 #include "chrome/browser/policy/test/local_policy_test_server.h" 40 #include "chrome/browser/policy/test/local_policy_test_server.h"
41 #include "chrome/browser/profiles/profile.h" 41 #include "chrome/browser/profiles/profile.h"
42 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" 42 #include "chrome/browser/ui/webui/signin/inline_login_ui.h"
43 #include "chrome/common/chrome_constants.h" 43 #include "chrome/common/chrome_constants.h"
44 #include "chrome/common/chrome_paths.h" 44 #include "chrome/common/chrome_paths.h"
45 #include "chrome/common/chrome_switches.h" 45 #include "chrome/common/chrome_switches.h"
46 #include "chrome/common/extensions/features/feature_channel.h" 46 #include "chrome/common/extensions/features/feature_channel.h"
47 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
48 #include "chrome/grit/generated_resources.h" 48 #include "chrome/grit/generated_resources.h"
49 #include "chrome/test/base/in_process_browser_test.h" 49 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); 252 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse());
253 http_response->set_code(net::HTTP_OK); 253 http_response->set_code(net::HTTP_OK);
254 http_response->set_content(response_html); 254 http_response->set_content(response_html);
255 http_response->set_content_type("text/html"); 255 http_response->set_content_type("text/html");
256 256
257 return http_response.Pass(); 257 return http_response.Pass();
258 } 258 }
259 259
260 } // namespace 260 } // namespace
261 261
262 class SamlTest : public InProcessBrowserTest, 262 class SamlTest : public OobeBaseTest, public testing::WithParamInterface<bool> {
263 public testing::WithParamInterface<bool> {
264 public: 263 public:
265 SamlTest() : gaia_frame_parent_("signin-frame"), saml_load_injected_(false) {} 264 SamlTest() : saml_load_injected_(false) { use_webview_ = GetParam(); }
266 ~SamlTest() override {} 265 ~SamlTest() override {}
267 266
268 bool UseWebView() const {
269 return GetParam();
270 }
271
272 void SetUp() override {
273 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
274
275 // Start the GAIA https wrapper here so that the GAIA URLs can be pointed at
276 // it in SetUpCommandLine().
277 gaia_https_forwarder_.reset(
278 new HTTPSForwarder(embedded_test_server()->base_url()));
279 ASSERT_TRUE(gaia_https_forwarder_->Start());
280
281 // Start the SAML IdP https wrapper here so that GAIA can be pointed at it
282 // in SetUpCommandLine().
283 saml_https_forwarder_.reset(
284 new HTTPSForwarder(embedded_test_server()->base_url()));
285 ASSERT_TRUE(saml_https_forwarder_->Start());
286
287 // Stop IO thread here because no threads are allowed while
288 // spawning sandbox host process. See crbug.com/322732.
289 embedded_test_server()->StopThread();
290
291 InProcessBrowserTest::SetUp();
292 }
293
294 bool SetUpUserDataDirectory() override {
295 if (UseWebView()) {
296 // Fake Dev channel to enable webview signin.
297 scoped_channel_.reset(new extensions::ScopedCurrentChannel(
298 chrome::VersionInfo::CHANNEL_DEV));
299
300 base::FilePath user_data_dir;
301 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
302 base::FilePath local_state_path =
303 user_data_dir.Append(chrome::kLocalStateFilename);
304
305 // Set webview enabled flag only when local state file does not exist.
306 // Otherwise, we break PRE tests that leave state in it.
307 if (!base::PathExists(local_state_path)) {
308 base::DictionaryValue local_state_dict;
309 local_state_dict.SetBoolean(prefs::kWebviewSigninEnabled, true);
310 // OobeCompleted to skip controller-pairing-screen which still uses
311 // iframe and ends up in a JS error in oobe page init.
312 // See http://crbug.com/467147
313 local_state_dict.SetBoolean(prefs::kOobeComplete, true);
314
315 CHECK(JSONFileValueSerializer(local_state_path)
316 .Serialize(local_state_dict));
317 }
318 }
319
320 return InProcessBrowserTest::SetUpUserDataDirectory();
321 }
322
323 void SetUpInProcessBrowserTestFixture() override {
324 host_resolver()->AddRule("*", "127.0.0.1");
325 }
326
327 void SetUpCommandLine(base::CommandLine* command_line) override { 267 void SetUpCommandLine(base::CommandLine* command_line) override {
328 command_line->AppendSwitch(switches::kLoginManager);
329 command_line->AppendSwitch(switches::kForceLoginManagerInTests);
330 command_line->AppendSwitch(switches::kOobeSkipPostLogin); 268 command_line->AppendSwitch(switches::kOobeSkipPostLogin);
331 command_line->AppendSwitch(::switches::kDisableBackgroundNetworking);
332 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
333 269
334 const GURL gaia_url = gaia_https_forwarder_->GetURL(""); 270 const GURL gaia_url = gaia_https_forwarder_->GetURL("");
335 command_line->AppendSwitchASCII(::switches::kGaiaUrl, gaia_url.spec());
336 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url.spec());
337 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl,
338 gaia_url.spec());
339
340 const GURL saml_idp_url = saml_https_forwarder_->GetURL("SAML"); 271 const GURL saml_idp_url = saml_https_forwarder_->GetURL("SAML");
341 fake_saml_idp_.SetUp(saml_idp_url.path(), gaia_url); 272 fake_saml_idp_.SetUp(saml_idp_url.path(), gaia_url);
342 fake_gaia_.RegisterSamlUser(kFirstSAMLUserEmail, saml_idp_url); 273 fake_gaia_->RegisterSamlUser(kFirstSAMLUserEmail, saml_idp_url);
343 fake_gaia_.RegisterSamlUser(kSecondSAMLUserEmail, saml_idp_url); 274 fake_gaia_->RegisterSamlUser(kSecondSAMLUserEmail, saml_idp_url);
344 fake_gaia_.RegisterSamlUser( 275 fake_gaia_->RegisterSamlUser(
345 kHTTPSAMLUserEmail, 276 kHTTPSAMLUserEmail,
346 embedded_test_server()->base_url().Resolve("/SAML")); 277 embedded_test_server()->base_url().Resolve("/SAML"));
347 fake_gaia_.RegisterSamlUser(kDifferentDomainSAMLUserEmail, saml_idp_url); 278 fake_gaia_->RegisterSamlUser(kDifferentDomainSAMLUserEmail, saml_idp_url);
348 279
349 fake_gaia_.Initialize(); 280 OobeBaseTest::SetUpCommandLine(command_line);
350 fake_gaia_.set_issue_oauth_code_cookie(UseWebView());
351 } 281 }
352 282
353 void SetUpOnMainThread() override { 283 void SetUpOnMainThread() override {
354 fake_gaia_.SetFakeMergeSessionParams(kFirstSAMLUserEmail, 284 fake_gaia_->SetFakeMergeSessionParams(
355 kTestAuthSIDCookie1, 285 kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1);
356 kTestAuthLSIDCookie1);
357 286
358 embedded_test_server()->RegisterRequestHandler(
359 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_)));
360 embedded_test_server()->RegisterRequestHandler(base::Bind( 287 embedded_test_server()->RegisterRequestHandler(base::Bind(
361 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); 288 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_)));
362 289
363 // Restart the thread as the sandbox host process has already been spawned. 290 OobeBaseTest::SetUpOnMainThread();
364 embedded_test_server()->RestartThreadAndListen();
365
366 login_screen_load_observer_.reset(new content::WindowedNotificationObserver(
367 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
368 content::NotificationService::AllSources()));
369 }
370
371 void TearDownOnMainThread() override {
372 // If the login display is still showing, exit gracefully.
373 if (LoginDisplayHostImpl::default_host()) {
374 base::MessageLoop::current()->PostTask(FROM_HERE,
375 base::Bind(&chrome::AttemptExit));
376 content::RunMessageLoop();
377 }
378 }
379
380 WebUILoginDisplay* GetLoginDisplay() {
381 ExistingUserController* controller =
382 ExistingUserController::current_controller();
383 CHECK(controller);
384 return static_cast<WebUILoginDisplay*>(controller->login_display());
385 }
386
387 void WaitForSigninScreen() {
388 WizardController* wizard_controller =
389 WizardController::default_controller();
390 if (wizard_controller) {
391 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
392 }
393 WizardController::SkipPostLoginScreensForTesting();
394
395 login_screen_load_observer_->Wait();
396 } 291 }
397 292
398 virtual void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) { 293 virtual void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) {
399 WaitForSigninScreen(); 294 WaitForSigninScreen();
400 295
401 if (!saml_load_injected_) { 296 if (!saml_load_injected_) {
402 saml_load_injected_ = true; 297 saml_load_injected_ = true;
403 298
404 ASSERT_TRUE(content::ExecuteScript( 299 ASSERT_TRUE(content::ExecuteScript(
405 GetLoginUI()->GetWebContents(), 300 GetLoginUI()->GetWebContents(),
406 "$('gaia-signin').gaiaAuthHost_.addEventListener('authFlowChange'," 301 "$('gaia-signin').gaiaAuthHost_.addEventListener('authFlowChange',"
407 "function() {" 302 "function() {"
408 "window.domAutomationController.setAutomationId(0);" 303 "window.domAutomationController.setAutomationId(0);"
409 "window.domAutomationController.send(" 304 "window.domAutomationController.send("
410 "$('gaia-signin').isSAML() ? 'SamlLoaded' : 'GaiaLoaded');" 305 "$('gaia-signin').isSAML() ? 'SamlLoaded' : 'GaiaLoaded');"
411 "});")); 306 "});"));
412 } 307 }
413 308
414 content::DOMMessageQueue message_queue; // Start observe before SAML. 309 content::DOMMessageQueue message_queue; // Start observe before SAML.
415 GetLoginDisplay()->ShowSigninScreenForCreds(gaia_email, ""); 310 GetLoginDisplay()->ShowSigninScreenForCreds(gaia_email, "");
416 311
417 std::string message; 312 std::string message;
418 ASSERT_TRUE(message_queue.WaitForMessage(&message)); 313 ASSERT_TRUE(message_queue.WaitForMessage(&message));
419 EXPECT_EQ("\"SamlLoaded\"", message); 314 EXPECT_EQ("\"SamlLoaded\"", message);
420 } 315 }
421 316
422 void SetSignFormField(const std::string& field_id,
423 const std::string& field_value) {
424 std::string js =
425 "(function(){"
426 "document.getElementById('$FieldId').value = '$FieldValue';"
427 "var e = new Event('input');"
428 "document.getElementById('$FieldId').dispatchEvent(e);"
429 "})();";
430 ReplaceSubstringsAfterOffset(&js, 0, "$FieldId", field_id);
431 ReplaceSubstringsAfterOffset(&js, 0, "$FieldValue", field_value);
432 ExecuteJsInSigninFrame(js);
433 }
434
435 void SendConfirmPassword(const std::string& password_to_confirm) { 317 void SendConfirmPassword(const std::string& password_to_confirm) {
436 std::string js = 318 std::string js =
437 "$('confirm-password-input').value='$Password';" 319 "$('confirm-password-input').value='$Password';"
438 "$('confirm-password').onConfirmPassword_();"; 320 "$('confirm-password').onConfirmPassword_();";
439 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password_to_confirm); 321 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password_to_confirm);
440 ASSERT_TRUE(content::ExecuteScript(GetLoginUI()->GetWebContents(), js)); 322 ASSERT_TRUE(content::ExecuteScript(GetLoginUI()->GetWebContents(), js));
441 } 323 }
442 324
443 void JsExpect(const std::string& js) {
444 bool result;
445 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
446 GetLoginUI()->GetWebContents(),
447 "window.domAutomationController.send(!!(" + js + "));",
448 &result));
449 EXPECT_TRUE(result) << js;
450 }
451
452 std::string WaitForAndGetFatalErrorMessage() { 325 std::string WaitForAndGetFatalErrorMessage() {
453 OobeScreenWaiter(OobeDisplay::SCREEN_FATAL_ERROR).Wait(); 326 OobeScreenWaiter(OobeDisplay::SCREEN_FATAL_ERROR).Wait();
454 std::string error_message; 327 std::string error_message;
455 if (!content::ExecuteScriptAndExtractString( 328 if (!content::ExecuteScriptAndExtractString(
456 GetLoginUI()->GetWebContents(), 329 GetLoginUI()->GetWebContents(),
457 "window.domAutomationController.send(" 330 "window.domAutomationController.send("
458 "$('fatal-error-message').textContent);", 331 "$('fatal-error-message').textContent);",
459 &error_message)) { 332 &error_message)) {
460 ADD_FAILURE(); 333 ADD_FAILURE();
461 } 334 }
462 return error_message; 335 return error_message;
463 } 336 }
464 337
465 content::WebUI* GetLoginUI() {
466 return static_cast<LoginDisplayHostImpl*>(
467 LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui();
468 }
469
470 // Executes JavaScript code in the auth iframe hosted by gaia_auth extension.
471 void ExecuteJsInSigninFrame(const std::string& js) {
472 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe(
473 GetLoginUI()->GetWebContents(), GURL(), gaia_frame_parent_);
474 ASSERT_TRUE(content::ExecuteScript(frame, js));
475 }
476
477 FakeSamlIdp* fake_saml_idp() { return &fake_saml_idp_; } 338 FakeSamlIdp* fake_saml_idp() { return &fake_saml_idp_; }
478 339
479 protected: 340 protected:
480 scoped_ptr<content::WindowedNotificationObserver> login_screen_load_observer_; 341 void InitHttpsForwarders() override {
481 FakeGaia fake_gaia_; 342 saml_https_forwarder_.reset(
343 new HTTPSForwarder(embedded_test_server()->base_url()));
344 ASSERT_TRUE(saml_https_forwarder_->Start());
482 345
483 std::string gaia_frame_parent_; 346 OobeBaseTest::InitHttpsForwarders();
347 }
484 348
485 scoped_ptr<HTTPSForwarder> gaia_https_forwarder_;
486 scoped_ptr<HTTPSForwarder> saml_https_forwarder_; 349 scoped_ptr<HTTPSForwarder> saml_https_forwarder_;
487 350
488 private: 351 private:
489 FakeSamlIdp fake_saml_idp_; 352 FakeSamlIdp fake_saml_idp_;
490 scoped_ptr<extensions::ScopedCurrentChannel> scoped_channel_;
491 353
492 bool saml_load_injected_; 354 bool saml_load_injected_;
493 355
494 DISALLOW_COPY_AND_ASSIGN(SamlTest); 356 DISALLOW_COPY_AND_ASSIGN(SamlTest);
495 }; 357 };
496 358
497 // Tests that signin frame should have 'saml' class and 'cancel' button is 359 // Tests that signin frame should have 'saml' class and 'cancel' button is
498 // visible when SAML IdP page is loaded. And 'cancel' button goes back to 360 // visible when SAML IdP page is loaded. And 'cancel' button goes back to
499 // gaia on clicking. 361 // gaia on clicking.
500 IN_PROC_BROWSER_TEST_P(SamlTest, SamlUI) { 362 IN_PROC_BROWSER_TEST_P(SamlTest, SamlUI) {
501 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); 363 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html");
502 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); 364 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail);
503 365
504 // Saml flow UI expectations. 366 // Saml flow UI expectations.
505 JsExpect("$('gaia-signin').classList.contains('full-width')"); 367 JsExpect("$('gaia-signin').classList.contains('full-width')");
506 if (!UseWebView()) { 368 if (!use_webview_) {
507 JsExpect("!$('cancel-add-user-button').hidden"); 369 JsExpect("!$('cancel-add-user-button').hidden");
508 } 370 }
509 371
510 // Click on 'cancel'. 372 // Click on 'cancel'.
511 content::DOMMessageQueue message_queue; // Observe before 'cancel'. 373 content::DOMMessageQueue message_queue; // Observe before 'cancel'.
512 if (UseWebView()) { 374 if (use_webview_) {
513 ASSERT_TRUE(content::ExecuteScript( 375 ASSERT_TRUE(content::ExecuteScript(
514 GetLoginUI()->GetWebContents(), 376 GetLoginUI()->GetWebContents(),
515 "$('close-button-item').click();")); 377 "$('close-button-item').click();"));
516 } else { 378 } else {
517 ASSERT_TRUE(content::ExecuteScript( 379 ASSERT_TRUE(content::ExecuteScript(
518 GetLoginUI()->GetWebContents(), 380 GetLoginUI()->GetWebContents(),
519 "$('cancel-add-user-button').click();")); 381 "$('cancel-add-user-button').click();"));
520 } 382 }
521 383
522 // Auth flow should change back to Gaia. 384 // Auth flow should change back to Gaia.
523 std::string message; 385 std::string message;
524 do { 386 do {
525 ASSERT_TRUE(message_queue.WaitForMessage(&message)); 387 ASSERT_TRUE(message_queue.WaitForMessage(&message));
526 } while (message != "\"GaiaLoaded\""); 388 } while (message != "\"GaiaLoaded\"");
527 389
528 // Saml flow is gone. 390 // Saml flow is gone.
529 JsExpect("!$('gaia-signin').classList.contains('full-width')"); 391 JsExpect("!$('gaia-signin').classList.contains('full-width')");
530 } 392 }
531 393
532 // Tests the sign-in flow when the credentials passing API is used. 394 // Tests the sign-in flow when the credentials passing API is used.
533 IN_PROC_BROWSER_TEST_P(SamlTest, CredentialPassingAPI) { 395 IN_PROC_BROWSER_TEST_P(SamlTest, CredentialPassingAPI) {
534 // Disabled for webview because the script is injected using 396 // Disabled for webview because the script is injected using
535 // webview.executeScript and there is no way to control the injection time. 397 // webview.executeScript and there is no way to control the injection time.
536 // As a result, this test is flaky and fails about 20% of the time. 398 // As a result, this test is flaky and fails about 20% of the time.
537 // TODO(xiyuan): Re-enable when webview.addContentScript API is ready. 399 // TODO(xiyuan): Re-enable when webview.addContentScript API is ready.
538 if (UseWebView()) 400 if (use_webview_)
539 return; 401 return;
540 402
541 fake_saml_idp()->SetLoginHTMLTemplate("saml_api_login.html"); 403 fake_saml_idp()->SetLoginHTMLTemplate("saml_api_login.html");
542 fake_saml_idp()->SetLoginAuthHTMLTemplate("saml_api_login_auth.html"); 404 fake_saml_idp()->SetLoginAuthHTMLTemplate("saml_api_login_auth.html");
543 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); 405 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail);
544 406
545 content::WindowedNotificationObserver session_start_waiter( 407 content::WindowedNotificationObserver session_start_waiter(
546 chrome::NOTIFICATION_SESSION_STARTED, 408 chrome::NOTIFICATION_SESSION_STARTED,
547 content::NotificationService::AllSources()); 409 content::NotificationService::AllSources());
548 410
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 ASSERT_TRUE(user); 537 ASSERT_TRUE(user);
676 EXPECT_EQ(kFirstSAMLUserEmail, user->email()); 538 EXPECT_EQ(kFirstSAMLUserEmail, user->email());
677 } 539 }
678 540
679 // Verifies that if the authenticated user's e-mail address cannot be retrieved, 541 // Verifies that if the authenticated user's e-mail address cannot be retrieved,
680 // an error message is shown. 542 // an error message is shown.
681 IN_PROC_BROWSER_TEST_P(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) { 543 IN_PROC_BROWSER_TEST_P(SamlTest, FailToRetrieveAutenticatedUserEmailAddress) {
682 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); 544 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html");
683 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); 545 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail);
684 546
685 fake_gaia_.SetFakeMergeSessionParams( 547 fake_gaia_->SetFakeMergeSessionParams("", kTestAuthSIDCookie1,
686 "", kTestAuthSIDCookie1, kTestAuthLSIDCookie1); 548 kTestAuthLSIDCookie1);
687 SetSignFormField("Email", "fake_user"); 549 SetSignFormField("Email", "fake_user");
688 SetSignFormField("Password", "fake_password"); 550 SetSignFormField("Password", "fake_password");
689 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); 551 ExecuteJsInSigninFrame("document.getElementById('Submit').click();");
690 552
691 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_ACCOUNT_DETAILS), 553 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_ACCOUNT_DETAILS),
692 WaitForAndGetFatalErrorMessage()); 554 WaitForAndGetFatalErrorMessage());
693 } 555 }
694 556
695 // Tests the password confirm flow: show error on the first failure and 557 // Tests the password confirm flow: show error on the first failure and
696 // fatal error on the second failure. 558 // fatal error on the second failure.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 678
817 void SAMLEnrollmentTest::SetUpOnMainThread() { 679 void SAMLEnrollmentTest::SetUpOnMainThread() {
818 Observe(GetLoginUI()->GetWebContents()); 680 Observe(GetLoginUI()->GetWebContents());
819 681
820 FakeGaia::AccessTokenInfo token_info; 682 FakeGaia::AccessTokenInfo token_info;
821 token_info.token = kTestUserinfoToken; 683 token_info.token = kTestUserinfoToken;
822 token_info.scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth); 684 token_info.scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth);
823 token_info.scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope); 685 token_info.scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope);
824 token_info.audience = GaiaUrls::GetInstance()->oauth2_chrome_client_id(); 686 token_info.audience = GaiaUrls::GetInstance()->oauth2_chrome_client_id();
825 token_info.email = kFirstSAMLUserEmail; 687 token_info.email = kFirstSAMLUserEmail;
826 fake_gaia_.IssueOAuthToken(kTestRefreshToken, token_info); 688 fake_gaia_->IssueOAuthToken(kTestRefreshToken, token_info);
827 689
828 SamlTest::SetUpOnMainThread(); 690 SamlTest::SetUpOnMainThread();
829 } 691 }
830 692
831 void SAMLEnrollmentTest::StartSamlAndWaitForIdpPageLoad( 693 void SAMLEnrollmentTest::StartSamlAndWaitForIdpPageLoad(
832 const std::string& gaia_email) { 694 const std::string& gaia_email) {
833 WaitForSigninScreen(); 695 WaitForSigninScreen();
834 run_loop_.reset(new base::RunLoop); 696 run_loop_.reset(new base::RunLoop);
835 ExistingUserController::current_controller()->OnStartEnterpriseEnrollment(); 697 ExistingUserController::current_controller()->OnStartEnterpriseEnrollment();
836 run_loop_->Run(); 698 run_loop_->Run();
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 ASSERT_TRUE(message_queue.WaitForMessage(&message)); 911 ASSERT_TRUE(message_queue.WaitForMessage(&message));
1050 EXPECT_EQ("\"ready\"", message); 912 EXPECT_EQ("\"ready\"", message);
1051 } 913 }
1052 914
1053 void SAMLPolicyTest::LogInWithSAML(const std::string& user_id, 915 void SAMLPolicyTest::LogInWithSAML(const std::string& user_id,
1054 const std::string& auth_sid_cookie, 916 const std::string& auth_sid_cookie,
1055 const std::string& auth_lsid_cookie) { 917 const std::string& auth_lsid_cookie) {
1056 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); 918 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html");
1057 StartSamlAndWaitForIdpPageLoad(user_id); 919 StartSamlAndWaitForIdpPageLoad(user_id);
1058 920
1059 fake_gaia_.SetFakeMergeSessionParams( 921 fake_gaia_->SetFakeMergeSessionParams(user_id, auth_sid_cookie,
1060 user_id, auth_sid_cookie, auth_lsid_cookie); 922 auth_lsid_cookie);
1061 SetSignFormField("Email", "fake_user"); 923 SetSignFormField("Email", "fake_user");
1062 SetSignFormField("Password", "fake_password"); 924 SetSignFormField("Password", "fake_password");
1063 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); 925 ExecuteJsInSigninFrame("document.getElementById('Submit').click();");
1064 926
1065 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait(); 927 OobeScreenWaiter(OobeDisplay::SCREEN_CONFIRM_PASSWORD).Wait();
1066 928
1067 content::WindowedNotificationObserver session_start_waiter( 929 content::WindowedNotificationObserver session_start_waiter(
1068 chrome::NOTIFICATION_SESSION_STARTED, 930 chrome::NOTIFICATION_SESSION_STARTED,
1069 content::NotificationService::AllSources()); 931 content::NotificationService::AllSources());
1070 SendConfirmPassword("fake_password"); 932 SendConfirmPassword("fake_password");
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName)); 1106 EXPECT_EQ(kTestAuthSIDCookie1, GetCookieValue(kGAIASIDCookieName));
1245 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName)); 1107 EXPECT_EQ(kTestAuthLSIDCookie1, GetCookieValue(kGAIALSIDCookieName));
1246 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName)); 1108 EXPECT_EQ(kSAMLIdPCookieValue1, GetCookieValue(kSAMLIdPCookieName));
1247 } 1109 }
1248 1110
1249 INSTANTIATE_TEST_CASE_P(SamlSuite, 1111 INSTANTIATE_TEST_CASE_P(SamlSuite,
1250 SAMLPolicyTest, 1112 SAMLPolicyTest,
1251 testing::Bool()); 1113 testing::Bool());
1252 1114
1253 } // namespace chromeos 1115 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/test/oobe_base_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698