diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 14:17:14 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 14:17:14 +0000 |
commit | 36c8e5f7523eb31c11fce92246cdaca4e7af4f36 (patch) | |
tree | 117a4786075700fb0b86b843304964c694adf533 /net/http/http_auth_handler_digest_unittest.cc | |
parent | 7ec0cb21f022b28c20e6e44e5f38f9ed6bc13a16 (diff) | |
download | chromium_src-36c8e5f7523eb31c11fce92246cdaca4e7af4f36.zip chromium_src-36c8e5f7523eb31c11fce92246cdaca4e7af4f36.tar.gz chromium_src-36c8e5f7523eb31c11fce92246cdaca4e7af4f36.tar.bz2 |
HttpAuthHandler's are no longer refcounted.
Since HttpAuthHandler objects are no longer contained inside of the
HttpAuthCache, the lifetime of the handlers is more clearly defined.
TEST=net_unittests (including some changes)
BUG=42222
Review URL: http://codereview.chromium.org/2635004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49052 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_auth_handler_digest_unittest.cc')
-rw-r--r-- | net/http/http_auth_handler_digest_unittest.cc | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/net/http/http_auth_handler_digest_unittest.cc b/net/http/http_auth_handler_digest_unittest.cc index 304656ff..b1782f6 100644 --- a/net/http/http_auth_handler_digest_unittest.cc +++ b/net/http/http_auth_handler_digest_unittest.cc @@ -5,6 +5,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "base/basictypes.h" +#include "net/base/net_errors.h" #include "net/http/http_auth_handler_digest.h" namespace net { @@ -100,14 +101,25 @@ TEST(HttpAuthHandlerDigestTest, ParseChallenge) { } }; + GURL origin("http://www.example.com"); + scoped_ptr<HttpAuthHandlerDigest::Factory> factory( + new HttpAuthHandlerDigest::Factory()); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - std::string challenge(tests[i].challenge); - - scoped_refptr<HttpAuthHandlerDigest> digest = new HttpAuthHandlerDigest(1); - HttpAuth::ChallengeTokenizer tok(challenge.begin(), challenge.end()); - bool ok = digest->ParseChallenge(&tok); - - EXPECT_EQ(tests[i].parsed_success, ok); + scoped_ptr<HttpAuthHandler> handler; + int rv = factory->CreateAuthHandlerFromString(tests[i].challenge, + HttpAuth::AUTH_SERVER, + origin, + BoundNetLog(), + &handler); + if (tests[i].parsed_success) { + EXPECT_EQ(OK, rv); + } else { + EXPECT_NE(OK, rv); + continue; + } + ASSERT_TRUE(handler != NULL); + HttpAuthHandlerDigest* digest = + static_cast<HttpAuthHandlerDigest*>(handler.get()); EXPECT_STREQ(tests[i].parsed_realm, digest->realm_.c_str()); EXPECT_STREQ(tests[i].parsed_nonce, digest->nonce_.c_str()); EXPECT_STREQ(tests[i].parsed_domain, digest->domain_.c_str()); @@ -250,13 +262,20 @@ TEST(HttpAuthHandlerDigestTest, AssembleCredentials) { } }; GURL origin("http://www.example.com"); + scoped_ptr<HttpAuthHandlerDigest::Factory> factory( + new HttpAuthHandlerDigest::Factory()); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - scoped_refptr<HttpAuthHandlerDigest> digest = new HttpAuthHandlerDigest(1); - std::string challenge = tests[i].challenge; - HttpAuth::ChallengeTokenizer tok(challenge.begin(), challenge.end()); - EXPECT_TRUE(digest->InitFromChallenge(&tok, HttpAuth::AUTH_SERVER, origin, - BoundNetLog())); - + scoped_ptr<HttpAuthHandler> handler; + int rv = factory->CreateAuthHandlerFromString(tests[i].challenge, + HttpAuth::AUTH_SERVER, + origin, + BoundNetLog(), + &handler); + EXPECT_EQ(OK, rv); + ASSERT_TRUE(handler != NULL); + + HttpAuthHandlerDigest* digest = + static_cast<HttpAuthHandlerDigest*>(handler.get()); std::string creds = digest->AssembleCredentials(tests[i].req_method, tests[i].req_path, tests[i].username, |