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

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

Issue 2049103002: Fix SAML single-password scrapping authenticating with an empty password (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 6 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/resources/gaia_auth_host/authenticator.js » ('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 #include <memory> 6 #include <memory>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 SystemSaltGetter::ConvertRawSaltToHexString( 486 SystemSaltGetter::ConvertRawSaltToHexString(
487 FakeCryptohomeClient::GetStubSystemSalt())); 487 FakeCryptohomeClient::GetStubSystemSalt()));
488 EXPECT_EQ(key.GetSecret(), cryptohome_client_->salted_hashed_secret()); 488 EXPECT_EQ(key.GetSecret(), cryptohome_client_->salted_hashed_secret());
489 } 489 }
490 490
491 // Tests the single password scraped flow. 491 // Tests the single password scraped flow.
492 IN_PROC_BROWSER_TEST_F(SamlTest, ScrapedSingle) { 492 IN_PROC_BROWSER_TEST_F(SamlTest, ScrapedSingle) {
493 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); 493 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html");
494 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); 494 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail);
495 495
496 // Make sure that the password is scraped correctly.
497 ASSERT_TRUE(content::ExecuteScript(
498 GetLoginUI()->GetWebContents(),
499 "$('gaia-signin').gaiaAuthHost_.addEventListener('authCompleted',"
500 " function(e) {"
501 " var password = e.detail.password;"
502 " window.domAutomationController.setAutomationId(0);"
503 " window.domAutomationController.send(password);"
504 " });"));
505
496 // Fill-in the SAML IdP form and submit. 506 // Fill-in the SAML IdP form and submit.
497 SetSignFormField("Email", "fake_user"); 507 SetSignFormField("Email", "fake_user");
498 SetSignFormField("Password", "fake_password"); 508 SetSignFormField("Password", "fake_password");
499 509
500 // Scraping a single password should finish the login and start the session. 510 // Scraping a single password should finish the login and start the session.
501 content::WindowedNotificationObserver session_start_waiter( 511 content::WindowedNotificationObserver session_start_waiter(
502 chrome::NOTIFICATION_SESSION_STARTED, 512 chrome::NOTIFICATION_SESSION_STARTED,
503 content::NotificationService::AllSources()); 513 content::NotificationService::AllSources());
514 content::DOMMessageQueue message_queue;
504 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); 515 ExecuteJsInSigninFrame("document.getElementById('Submit').click();");
516 std::string message;
517 do {
518 ASSERT_TRUE(message_queue.WaitForMessage(&message));
519 } while (message != "\"fake_password\"");
520
505 session_start_waiter.Wait(); 521 session_start_waiter.Wait();
506 } 522 }
507 523
508 // Tests password scraping from a dynamically created password field. 524 // Tests password scraping from a dynamically created password field.
509 IN_PROC_BROWSER_TEST_F(SamlTest, ScrapedDynamic) { 525 IN_PROC_BROWSER_TEST_F(SamlTest, ScrapedDynamic) {
510 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); 526 fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html");
511 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); 527 StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail);
512 528
513 ExecuteJsInSigninFrame( 529 ExecuteJsInSigninFrame(
514 "(function() {" 530 "(function() {"
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 1360
1345 // Scraping one password should finish login. 1361 // Scraping one password should finish login.
1346 content::WindowedNotificationObserver session_start_waiter( 1362 content::WindowedNotificationObserver session_start_waiter(
1347 chrome::NOTIFICATION_SESSION_STARTED, 1363 chrome::NOTIFICATION_SESSION_STARTED,
1348 content::NotificationService::AllSources()); 1364 content::NotificationService::AllSources());
1349 ExecuteJsInSigninFrame("document.getElementById('Submit').click();"); 1365 ExecuteJsInSigninFrame("document.getElementById('Submit').click();");
1350 session_start_waiter.Wait(); 1366 session_start_waiter.Wait();
1351 } 1367 }
1352 1368
1353 } // namespace chromeos 1369 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/gaia_auth_host/authenticator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698