OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 std::string challenge_str = "Basic realm=\""; | 297 std::string challenge_str = "Basic realm=\""; |
298 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(), | 298 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(), |
299 challenge_str.end()); | 299 challenge_str.end()); |
300 HttpUtil::NameValuePairsIterator parameters = challenge.param_pairs(); | 300 HttpUtil::NameValuePairsIterator parameters = challenge.param_pairs(); |
301 | 301 |
302 EXPECT_TRUE(parameters.valid()); | 302 EXPECT_TRUE(parameters.valid()); |
303 EXPECT_EQ(std::string("Basic"), challenge.scheme()); | 303 EXPECT_EQ(std::string("Basic"), challenge.scheme()); |
304 EXPECT_TRUE(parameters.GetNext()); | 304 EXPECT_TRUE(parameters.GetNext()); |
305 EXPECT_TRUE(parameters.valid()); | 305 EXPECT_TRUE(parameters.valid()); |
306 EXPECT_EQ(std::string("realm"), parameters.name()); | 306 EXPECT_EQ(std::string("realm"), parameters.name()); |
307 EXPECT_EQ(std::string(""), parameters.value()); | 307 EXPECT_EQ(std::string(), parameters.value()); |
308 EXPECT_FALSE(parameters.GetNext()); | 308 EXPECT_FALSE(parameters.GetNext()); |
309 } | 309 } |
310 | 310 |
311 // Use a name=value property with mismatching quote marks and spaces in the | 311 // Use a name=value property with mismatching quote marks and spaces in the |
312 // value. | 312 // value. |
313 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotesSpaces) { | 313 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotesSpaces) { |
314 std::string challenge_str = "Basic realm=\"foo bar"; | 314 std::string challenge_str = "Basic realm=\"foo bar"; |
315 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(), | 315 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(), |
316 challenge_str.end()); | 316 challenge_str.end()); |
317 HttpUtil::NameValuePairsIterator parameters = challenge.param_pairs(); | 317 HttpUtil::NameValuePairsIterator parameters = challenge.param_pairs(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 std::string name; | 426 std::string name; |
427 | 427 |
428 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); | 428 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); |
429 EXPECT_STREQ("Authorization", name.c_str()); | 429 EXPECT_STREQ("Authorization", name.c_str()); |
430 | 430 |
431 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); | 431 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); |
432 EXPECT_STREQ("Proxy-Authorization", name.c_str()); | 432 EXPECT_STREQ("Proxy-Authorization", name.c_str()); |
433 } | 433 } |
434 | 434 |
435 } // namespace net | 435 } // namespace net |
OLD | NEW |