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

Side by Side Diff: net/http/http_auth_unittest.cc

Issue 1800003: Auto-format style pass over files. (Closed)
Patch Set: Remove trailing whitespace. Created 10 years, 7 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 | « net/http/http_auth_handler_ntlm_win.cc ('k') | net/http/http_byte_range.cc » ('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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/ref_counted.h" 7 #include "base/ref_counted.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/http/http_auth.h" 10 #include "net/http/http_auth.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 EXPECT_EQ(std::string("foobar@baz.com"), challenge.value()); 189 EXPECT_EQ(std::string("foobar@baz.com"), challenge.value());
190 EXPECT_EQ(std::string("foobar@baz.com"), challenge.unquoted_value()); 190 EXPECT_EQ(std::string("foobar@baz.com"), challenge.unquoted_value());
191 EXPECT_FALSE(challenge.value_is_quoted()); 191 EXPECT_FALSE(challenge.value_is_quoted());
192 EXPECT_FALSE(challenge.GetNext()); 192 EXPECT_FALSE(challenge.GetNext());
193 } 193 }
194 194
195 // Use a name=value property with mismatching quote marks. 195 // Use a name=value property with mismatching quote marks.
196 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotes) { 196 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotes) {
197 std::string challenge_str = "Basic realm=\"foobar@baz.com"; 197 std::string challenge_str = "Basic realm=\"foobar@baz.com";
198 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(), 198 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(),
199 challenge_str.end()); 199 challenge_str.end());
200 EXPECT_TRUE(challenge.valid()); 200 EXPECT_TRUE(challenge.valid());
201 EXPECT_EQ(std::string("Basic"), challenge.scheme()); 201 EXPECT_EQ(std::string("Basic"), challenge.scheme());
202 EXPECT_TRUE(challenge.GetNext()); 202 EXPECT_TRUE(challenge.GetNext());
203 EXPECT_TRUE(challenge.valid()); 203 EXPECT_TRUE(challenge.valid());
204 EXPECT_EQ(std::string("realm"), challenge.name()); 204 EXPECT_EQ(std::string("realm"), challenge.name());
205 EXPECT_EQ(std::string("foobar@baz.com"), challenge.value()); 205 EXPECT_EQ(std::string("foobar@baz.com"), challenge.value());
206 EXPECT_EQ(std::string("foobar@baz.com"), challenge.unquoted_value()); 206 EXPECT_EQ(std::string("foobar@baz.com"), challenge.unquoted_value());
207 EXPECT_FALSE(challenge.value_is_quoted()); 207 EXPECT_FALSE(challenge.value_is_quoted());
208 EXPECT_FALSE(challenge.GetNext()); 208 EXPECT_FALSE(challenge.GetNext());
209 } 209 }
210 210
211 // Use a name= property without a value and with mismatching quote marks. 211 // Use a name= property without a value and with mismatching quote marks.
212 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotesNoValue) { 212 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotesNoValue) {
213 std::string challenge_str = "Basic realm=\""; 213 std::string challenge_str = "Basic realm=\"";
214 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(), 214 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(),
215 challenge_str.end()); 215 challenge_str.end());
216 EXPECT_TRUE(challenge.valid()); 216 EXPECT_TRUE(challenge.valid());
217 EXPECT_EQ(std::string("Basic"), challenge.scheme()); 217 EXPECT_EQ(std::string("Basic"), challenge.scheme());
218 EXPECT_TRUE(challenge.GetNext()); 218 EXPECT_TRUE(challenge.GetNext());
219 EXPECT_TRUE(challenge.valid()); 219 EXPECT_TRUE(challenge.valid());
220 EXPECT_EQ(std::string("realm"), challenge.name()); 220 EXPECT_EQ(std::string("realm"), challenge.name());
221 EXPECT_EQ(std::string(""), challenge.value()); 221 EXPECT_EQ(std::string(""), challenge.value());
222 EXPECT_FALSE(challenge.value_is_quoted()); 222 EXPECT_FALSE(challenge.value_is_quoted());
223 EXPECT_FALSE(challenge.GetNext()); 223 EXPECT_FALSE(challenge.GetNext());
224 } 224 }
225 225
226 // Use a name=value property with mismatching quote marks and spaces in the 226 // Use a name=value property with mismatching quote marks and spaces in the
227 // value. 227 // value.
228 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotesSpaces) { 228 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotesSpaces) {
229 std::string challenge_str = "Basic realm=\"foo bar"; 229 std::string challenge_str = "Basic realm=\"foo bar";
230 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(), 230 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(),
231 challenge_str.end()); 231 challenge_str.end());
232 EXPECT_TRUE(challenge.valid()); 232 EXPECT_TRUE(challenge.valid());
233 EXPECT_EQ(std::string("Basic"), challenge.scheme()); 233 EXPECT_EQ(std::string("Basic"), challenge.scheme());
234 EXPECT_TRUE(challenge.GetNext()); 234 EXPECT_TRUE(challenge.GetNext());
235 EXPECT_TRUE(challenge.valid()); 235 EXPECT_TRUE(challenge.valid());
236 EXPECT_EQ(std::string("realm"), challenge.name()); 236 EXPECT_EQ(std::string("realm"), challenge.name());
237 EXPECT_EQ(std::string("foo bar"), challenge.value()); 237 EXPECT_EQ(std::string("foo bar"), challenge.value());
238 EXPECT_EQ(std::string("foo bar"), challenge.unquoted_value()); 238 EXPECT_EQ(std::string("foo bar"), challenge.unquoted_value());
239 EXPECT_FALSE(challenge.value_is_quoted()); 239 EXPECT_FALSE(challenge.value_is_quoted());
240 EXPECT_FALSE(challenge.GetNext()); 240 EXPECT_FALSE(challenge.GetNext());
241 } 241 }
242 242
243 // Use multiple name=value properties with mismatching quote marks in the last 243 // Use multiple name=value properties with mismatching quote marks in the last
244 // value. 244 // value.
245 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotesMultiple) { 245 TEST(HttpAuthTest, ChallengeTokenizerMismatchedQuotesMultiple) {
246 std::string challenge_str = "Digest qop=, algorithm=md5, realm=\"foo"; 246 std::string challenge_str = "Digest qop=, algorithm=md5, realm=\"foo";
247 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(), 247 HttpAuth::ChallengeTokenizer challenge(challenge_str.begin(),
248 challenge_str.end()); 248 challenge_str.end());
249 EXPECT_TRUE(challenge.valid()); 249 EXPECT_TRUE(challenge.valid());
250 EXPECT_EQ(std::string("Digest"), challenge.scheme()); 250 EXPECT_EQ(std::string("Digest"), challenge.scheme());
251 EXPECT_TRUE(challenge.GetNext()); 251 EXPECT_TRUE(challenge.GetNext());
252 EXPECT_TRUE(challenge.valid()); 252 EXPECT_TRUE(challenge.valid());
253 EXPECT_EQ(std::string("qop"), challenge.name()); 253 EXPECT_EQ(std::string("qop"), challenge.name());
254 EXPECT_EQ(std::string(""), challenge.value()); 254 EXPECT_EQ(std::string(""), challenge.value());
255 EXPECT_FALSE(challenge.value_is_quoted()); 255 EXPECT_FALSE(challenge.value_is_quoted());
256 EXPECT_TRUE(challenge.GetNext()); 256 EXPECT_TRUE(challenge.GetNext());
257 EXPECT_TRUE(challenge.valid()); 257 EXPECT_TRUE(challenge.valid());
258 EXPECT_EQ(std::string("algorithm"), challenge.name()); 258 EXPECT_EQ(std::string("algorithm"), challenge.name());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 std::string name; 347 std::string name;
348 348
349 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); 349 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER);
350 EXPECT_STREQ("Authorization", name.c_str()); 350 EXPECT_STREQ("Authorization", name.c_str());
351 351
352 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); 352 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY);
353 EXPECT_STREQ("Proxy-Authorization", name.c_str()); 353 EXPECT_STREQ("Proxy-Authorization", name.c_str());
354 } 354 }
355 355
356 } // namespace net 356 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_ntlm_win.cc ('k') | net/http/http_byte_range.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698