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

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

Issue 1408433006: Support tls-server-end-point channel bindings for HTTP authentication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Narrower dependencies, update comments, address review comments. Created 4 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/http/http_auth_gssapi_posix.h" 5 #include "net/http/http_auth_gssapi_posix.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/native_library.h" 9 #include "base/native_library.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 std::string first_challenge_text = "Negotiate"; 202 std::string first_challenge_text = "Negotiate";
203 HttpAuthChallengeTokenizer first_challenge(first_challenge_text.begin(), 203 HttpAuthChallengeTokenizer first_challenge(first_challenge_text.begin(),
204 first_challenge_text.end()); 204 first_challenge_text.end());
205 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_ACCEPT, 205 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_ACCEPT,
206 auth_gssapi.ParseChallenge(&first_challenge)); 206 auth_gssapi.ParseChallenge(&first_challenge));
207 207
208 // Generate an auth token and create another thing. 208 // Generate an auth token and create another thing.
209 EstablishInitialContext(&mock_library); 209 EstablishInitialContext(&mock_library);
210 std::string auth_token; 210 std::string auth_token;
211 EXPECT_EQ(OK, auth_gssapi.GenerateAuthToken(NULL, "HTTP/intranet.google.com", 211 EXPECT_EQ(OK, auth_gssapi.GenerateAuthToken(NULL, "HTTP/intranet.google.com",
212 &auth_token, 212 std::string(), &auth_token,
213 base::Bind(&UnexpectedCallback))); 213 base::Bind(&UnexpectedCallback)));
214 214
215 std::string second_challenge_text = "Negotiate Zm9vYmFy"; 215 std::string second_challenge_text = "Negotiate Zm9vYmFy";
216 HttpAuthChallengeTokenizer second_challenge(second_challenge_text.begin(), 216 HttpAuthChallengeTokenizer second_challenge(second_challenge_text.begin(),
217 second_challenge_text.end()); 217 second_challenge_text.end());
218 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_ACCEPT, 218 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_ACCEPT,
219 auth_gssapi.ParseChallenge(&second_challenge)); 219 auth_gssapi.ParseChallenge(&second_challenge));
220 } 220 }
221 221
222 TEST(HttpAuthGSSAPITest, ParseChallenge_UnexpectedTokenFirstRound) { 222 TEST(HttpAuthGSSAPITest, ParseChallenge_UnexpectedTokenFirstRound) {
(...skipping 17 matching lines...) Expand all
240 CHROME_GSS_SPNEGO_MECH_OID_DESC); 240 CHROME_GSS_SPNEGO_MECH_OID_DESC);
241 std::string first_challenge_text = "Negotiate"; 241 std::string first_challenge_text = "Negotiate";
242 HttpAuthChallengeTokenizer first_challenge(first_challenge_text.begin(), 242 HttpAuthChallengeTokenizer first_challenge(first_challenge_text.begin(),
243 first_challenge_text.end()); 243 first_challenge_text.end());
244 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_ACCEPT, 244 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_ACCEPT,
245 auth_gssapi.ParseChallenge(&first_challenge)); 245 auth_gssapi.ParseChallenge(&first_challenge));
246 246
247 EstablishInitialContext(&mock_library); 247 EstablishInitialContext(&mock_library);
248 std::string auth_token; 248 std::string auth_token;
249 EXPECT_EQ(OK, auth_gssapi.GenerateAuthToken(NULL, "HTTP/intranet.google.com", 249 EXPECT_EQ(OK, auth_gssapi.GenerateAuthToken(NULL, "HTTP/intranet.google.com",
250 &auth_token, 250 std::string(), &auth_token,
251 base::Bind(&UnexpectedCallback))); 251 base::Bind(&UnexpectedCallback)));
252 std::string second_challenge_text = "Negotiate"; 252 std::string second_challenge_text = "Negotiate";
253 HttpAuthChallengeTokenizer second_challenge(second_challenge_text.begin(), 253 HttpAuthChallengeTokenizer second_challenge(second_challenge_text.begin(),
254 second_challenge_text.end()); 254 second_challenge_text.end());
255 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, 255 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT,
256 auth_gssapi.ParseChallenge(&second_challenge)); 256 auth_gssapi.ParseChallenge(&second_challenge));
257 } 257 }
258 258
259 TEST(HttpAuthGSSAPITest, ParseChallenge_NonBase64EncodedToken) { 259 TEST(HttpAuthGSSAPITest, ParseChallenge_NonBase64EncodedToken) {
260 // If a later-round challenge has an invalid base64 encoded token, it should 260 // If a later-round challenge has an invalid base64 encoded token, it should
261 // be treated as an invalid challenge. 261 // be treated as an invalid challenge.
262 test::MockGSSAPILibrary mock_library; 262 test::MockGSSAPILibrary mock_library;
263 HttpAuthGSSAPI auth_gssapi(&mock_library, "Negotiate", 263 HttpAuthGSSAPI auth_gssapi(&mock_library, "Negotiate",
264 CHROME_GSS_SPNEGO_MECH_OID_DESC); 264 CHROME_GSS_SPNEGO_MECH_OID_DESC);
265 std::string first_challenge_text = "Negotiate"; 265 std::string first_challenge_text = "Negotiate";
266 HttpAuthChallengeTokenizer first_challenge(first_challenge_text.begin(), 266 HttpAuthChallengeTokenizer first_challenge(first_challenge_text.begin(),
267 first_challenge_text.end()); 267 first_challenge_text.end());
268 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_ACCEPT, 268 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_ACCEPT,
269 auth_gssapi.ParseChallenge(&first_challenge)); 269 auth_gssapi.ParseChallenge(&first_challenge));
270 270
271 EstablishInitialContext(&mock_library); 271 EstablishInitialContext(&mock_library);
272 std::string auth_token; 272 std::string auth_token;
273 EXPECT_EQ(OK, auth_gssapi.GenerateAuthToken(NULL, "HTTP/intranet.google.com", 273 EXPECT_EQ(OK, auth_gssapi.GenerateAuthToken(NULL, "HTTP/intranet.google.com",
274 &auth_token, 274 std::string(), &auth_token,
275 base::Bind(&UnexpectedCallback))); 275 base::Bind(&UnexpectedCallback)));
276 std::string second_challenge_text = "Negotiate =happyjoy="; 276 std::string second_challenge_text = "Negotiate =happyjoy=";
277 HttpAuthChallengeTokenizer second_challenge(second_challenge_text.begin(), 277 HttpAuthChallengeTokenizer second_challenge(second_challenge_text.begin(),
278 second_challenge_text.end()); 278 second_challenge_text.end());
279 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_INVALID, 279 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_INVALID,
280 auth_gssapi.ParseChallenge(&second_challenge)); 280 auth_gssapi.ParseChallenge(&second_challenge));
281 } 281 }
282 282
283 } // namespace net 283 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698