OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 9 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
10 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 10 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
30 | 30 |
31 using net::test_server::BasicHttpResponse; | 31 using net::test_server::BasicHttpResponse; |
32 using net::test_server::HttpRequest; | 32 using net::test_server::HttpRequest; |
33 using net::test_server::HttpResponse; | 33 using net::test_server::HttpResponse; |
34 | 34 |
35 namespace chromeos { | 35 namespace chromeos { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
| 39 const char kTestAuthCode[] = "fake-auth-code"; |
| 40 const char kTestGaiaUberToken[] = "fake-uber-token"; |
| 41 const char kTestAuthLoginAccessToken[] = "fake-access-token"; |
| 42 const char kTestRefreshToken[] = "fake-refresh-token"; |
| 43 const char kTestSessionSIDCookie[] = "fake-session-SID-cookie"; |
| 44 const char kTestSessionLSIDCookie[] = "fake-session-LSID-cookie"; |
| 45 |
39 const char kRelayState[] = "RelayState"; | 46 const char kRelayState[] = "RelayState"; |
40 | 47 |
41 const char kDefaultIdpHtml[] = | 48 const char kDefaultIdpHtml[] = |
42 "<form id=IdPForm method=post action=\"$Post\">" | 49 "<form id=IdPForm method=post action=\"$Post\">" |
43 "<input type=hidden name=RelayState value=\"$RelayState\">" | 50 "<input type=hidden name=RelayState value=\"$RelayState\">" |
44 "User: <input type=text id=Email name=Email>" | 51 "User: <input type=text id=Email name=Email>" |
45 "Password: <input type=password id=Password name=Password>" | 52 "Password: <input type=password id=Password name=Password>" |
46 "<input id=Submit type=submit>" | 53 "<input id=Submit type=submit>" |
47 "</form>"; | 54 "</form>"; |
48 | 55 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 155 |
149 std::string gaia_host("gaia"); | 156 std::string gaia_host("gaia"); |
150 GURL::Replacements replace_gaia_host; | 157 GURL::Replacements replace_gaia_host; |
151 replace_gaia_host.SetHostStr(gaia_host); | 158 replace_gaia_host.SetHostStr(gaia_host); |
152 gaia_url_ = server_url.ReplaceComponents(replace_gaia_host); | 159 gaia_url_ = server_url.ReplaceComponents(replace_gaia_host); |
153 | 160 |
154 command_line->AppendSwitchASCII(::switches::kGaiaUrl, gaia_url_.spec()); | 161 command_line->AppendSwitchASCII(::switches::kGaiaUrl, gaia_url_.spec()); |
155 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url_.spec()); | 162 command_line->AppendSwitchASCII(::switches::kLsoUrl, gaia_url_.spec()); |
156 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl, | 163 command_line->AppendSwitchASCII(::switches::kGoogleApisUrl, |
157 gaia_url_.spec()); | 164 gaia_url_.spec()); |
| 165 fake_gaia_.Initialize(); |
158 | 166 |
159 std::string saml_idp_host("saml.idp"); | 167 std::string saml_idp_host("saml.idp"); |
160 GURL::Replacements replace_saml_idp_host; | 168 GURL::Replacements replace_saml_idp_host; |
161 replace_saml_idp_host.SetHostStr(saml_idp_host); | 169 replace_saml_idp_host.SetHostStr(saml_idp_host); |
162 GURL saml_idp_url = server_url.ReplaceComponents(replace_saml_idp_host); | 170 GURL saml_idp_url = server_url.ReplaceComponents(replace_saml_idp_host); |
163 saml_idp_url = saml_idp_url.Resolve("/SAML/SSO"); | 171 saml_idp_url = saml_idp_url.Resolve("/SAML/SSO"); |
164 | 172 |
165 fake_saml_idp_.SetUp(saml_idp_url.path(), gaia_url_); | 173 fake_saml_idp_.SetUp(saml_idp_url.path(), gaia_url_); |
166 fake_gaia_.RegisterSamlUser("saml_user", saml_idp_url); | 174 fake_gaia_.RegisterSamlUser("saml_user", saml_idp_url); |
167 } | 175 } |
168 | 176 |
169 virtual void SetUpOnMainThread() OVERRIDE { | 177 virtual void SetUpOnMainThread() OVERRIDE { |
| 178 fake_gaia_.SetAuthTokens(kTestAuthCode, |
| 179 kTestRefreshToken, |
| 180 kTestAuthLoginAccessToken, |
| 181 kTestGaiaUberToken, |
| 182 kTestSessionSIDCookie, |
| 183 kTestSessionLSIDCookie); |
| 184 |
170 embedded_test_server()->RegisterRequestHandler( | 185 embedded_test_server()->RegisterRequestHandler( |
171 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); | 186 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); |
172 embedded_test_server()->RegisterRequestHandler(base::Bind( | 187 embedded_test_server()->RegisterRequestHandler(base::Bind( |
173 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); | 188 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); |
174 | 189 |
175 // Restart the thread as the sandbox host process has already been spawned. | 190 // Restart the thread as the sandbox host process has already been spawned. |
176 embedded_test_server()->RestartThreadAndListen(); | 191 embedded_test_server()->RestartThreadAndListen(); |
177 } | 192 } |
178 | 193 |
179 virtual void CleanUpOnMainThread() OVERRIDE { | 194 virtual void CleanUpOnMainThread() OVERRIDE { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 SetSignFormField("Email", "fake_user"); | 388 SetSignFormField("Email", "fake_user"); |
374 ExecuteJsInSigninFrame("document.getElementById('IdPForm').submit();"); | 389 ExecuteJsInSigninFrame("document.getElementById('IdPForm').submit();"); |
375 | 390 |
376 OobeScreenWaiter(OobeDisplay::SCREEN_MESSAGE_BOX).Wait(); | 391 OobeScreenWaiter(OobeDisplay::SCREEN_MESSAGE_BOX).Wait(); |
377 JsExpect( | 392 JsExpect( |
378 "$('message-box-title').textContent == " | 393 "$('message-box-title').textContent == " |
379 "loadTimeData.getString('noPasswordWarningTitle')"); | 394 "loadTimeData.getString('noPasswordWarningTitle')"); |
380 } | 395 } |
381 | 396 |
382 } // namespace chromeos | 397 } // namespace chromeos |
OLD | NEW |