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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 redirect_url, "SAMLResponse", "fake_response"); | 210 redirect_url, "SAMLResponse", "fake_response"); |
211 redirect_url = net::AppendQueryParameter( | 211 redirect_url = net::AppendQueryParameter( |
212 redirect_url, kRelayState, relay_state); | 212 redirect_url, kRelayState, relay_state); |
213 | 213 |
214 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); | 214 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); |
215 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); | 215 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); |
216 http_response->AddCustomHeader("Location", redirect_url.spec()); | 216 http_response->AddCustomHeader("Location", redirect_url.spec()); |
217 http_response->AddCustomHeader( | 217 http_response->AddCustomHeader( |
218 "Set-cookie", | 218 "Set-cookie", |
219 base::StringPrintf("saml=%s", cookie_value_.c_str())); | 219 base::StringPrintf("saml=%s", cookie_value_.c_str())); |
220 return http_response.PassAs<HttpResponse>(); | 220 return http_response.Pass(); |
221 } | 221 } |
222 | 222 |
223 scoped_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse( | 223 scoped_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse( |
224 const std::string& html_template, | 224 const std::string& html_template, |
225 const std::string& relay_state, | 225 const std::string& relay_state, |
226 const std::string& next_path) { | 226 const std::string& next_path) { |
227 std::string response_html = html_template; | 227 std::string response_html = html_template; |
228 ReplaceSubstringsAfterOffset(&response_html, 0, "$RelayState", relay_state); | 228 ReplaceSubstringsAfterOffset(&response_html, 0, "$RelayState", relay_state); |
229 ReplaceSubstringsAfterOffset(&response_html, 0, "$Post", next_path); | 229 ReplaceSubstringsAfterOffset(&response_html, 0, "$Post", next_path); |
230 ReplaceSubstringsAfterOffset( | 230 ReplaceSubstringsAfterOffset( |
231 &response_html, 0, "$Refresh", refresh_url_.spec()); | 231 &response_html, 0, "$Refresh", refresh_url_.spec()); |
232 | 232 |
233 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); | 233 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); |
234 http_response->set_code(net::HTTP_OK); | 234 http_response->set_code(net::HTTP_OK); |
235 http_response->set_content(response_html); | 235 http_response->set_content(response_html); |
236 http_response->set_content_type("text/html"); | 236 http_response->set_content_type("text/html"); |
237 | 237 |
238 return http_response.PassAs<HttpResponse>(); | 238 return http_response.Pass(); |
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 { |
(...skipping 704 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 |