summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-23 20:15:00 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-23 20:15:00 +0000
commita950ac48188421b7b19a205e10648cbfbda0a88f (patch)
tree1f256c9645a4364722d16161901110fb96bbcd3c
parentfe9d18904e553876bc9c738753ac6f2dae2577d1 (diff)
downloadchromium_src-a950ac48188421b7b19a205e10648cbfbda0a88f.zip
chromium_src-a950ac48188421b7b19a205e10648cbfbda0a88f.tar.gz
chromium_src-a950ac48188421b7b19a205e10648cbfbda0a88f.tar.bz2
Add a unit test which checks that Negotiate is chosen over NTLM.
Negotiate is chosen over NTLM on Windows, but currently is not on Linux or OSX since support has nat been added yet. BUG=32824 TEST=Added new unit test and ran it. Review URL: http://codereview.chromium.org/554043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36968 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x[-rw-r--r--]net/http/http_auth_unittest.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/net/http/http_auth_unittest.cc b/net/http/http_auth_unittest.cc
index 4c21fcf..a960d70 100644..100755
--- a/net/http/http_auth_unittest.cc
+++ b/net/http/http_auth_unittest.cc
@@ -15,6 +15,7 @@ namespace net {
TEST(HttpAuthTest, ChooseBestChallenge) {
static const struct {
const char* headers;
+ const char* challenge_scheme;
const char* challenge_realm;
} tests[] = {
{
@@ -22,6 +23,7 @@ TEST(HttpAuthTest, ChooseBestChallenge) {
"www-authenticate: Basic realm=\"BasicRealm\"\n",
// Basic is the only challenge type, pick it.
+ "basic",
"BasicRealm",
},
{
@@ -30,6 +32,7 @@ TEST(HttpAuthTest, ChooseBestChallenge) {
// Fake is the only challenge type, but it is unsupported.
"",
+ "",
},
{
"www-authenticate: Basic realm=\"FooBar\"\n"
@@ -38,6 +41,7 @@ TEST(HttpAuthTest, ChooseBestChallenge) {
"www-authenticate: Digest realm=\"DigestRealm\", nonce=\"aaaaaaaaaa\"\n",
// Pick Digset over Basic
+ "digest",
"DigestRealm",
},
{
@@ -46,6 +50,21 @@ TEST(HttpAuthTest, ChooseBestChallenge) {
// Handle null header value.
"",
+ "",
+ },
+ {
+ "WWW-Authenticate: Negotiate\n"
+ "WWW-Authenticate: NTLM\n",
+
+ // Negotiate is not currently support on non-Windows platforms, so
+ // the choice varies depending on platform.
+#if defined(OS_WIN)
+ "negotiate",
+ "",
+#else
+ "ntlm",
+ "",
+#endif
}
};
GURL origin("http://www.example.com");
@@ -55,7 +74,7 @@ TEST(HttpAuthTest, ChooseBestChallenge) {
std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n");
headers_with_status_line += tests[i].headers;
scoped_refptr<net::HttpResponseHeaders> headers(
- new net::HttpResponseHeaders(
+ new net::HttpResponseHeaders(
net::HttpUtil::AssembleRawHeaders(
headers_with_status_line.c_str(),
headers_with_status_line.length())));
@@ -67,8 +86,10 @@ TEST(HttpAuthTest, ChooseBestChallenge) {
&handler);
if (handler) {
+ EXPECT_STREQ(tests[i].challenge_scheme, handler->scheme().c_str());
EXPECT_STREQ(tests[i].challenge_realm, handler->realm().c_str());
} else {
+ EXPECT_STREQ("", tests[i].challenge_scheme);
EXPECT_STREQ("", tests[i].challenge_realm);
}
}
@@ -80,8 +101,6 @@ TEST(HttpAuthTest, ChooseBestChallengeConnectionBased) {
const char* challenge_realm;
} tests[] = {
{
- // TODO(cbentzel): Add tests for both Negotiate and NTLM once Negotiate
- // is supported on all platforms.
"WWW-Authenticate: NTLM\r\n",
"",
@@ -108,7 +127,7 @@ TEST(HttpAuthTest, ChooseBestChallengeConnectionBased) {
std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n");
headers_with_status_line += tests[i].headers;
scoped_refptr<net::HttpResponseHeaders> headers(
- new net::HttpResponseHeaders(
+ new net::HttpResponseHeaders(
net::HttpUtil::AssembleRawHeaders(
headers_with_status_line.c_str(),
headers_with_status_line.length())));