| Index: net/http/http_auth_cache_unittest.cc
|
| diff --git a/net/http/http_auth_cache_unittest.cc b/net/http/http_auth_cache_unittest.cc
|
| index d782f5ecba14801a3ede0b59459ec071d60654fc..3134658fd919b3b1f84c96eb75b4abec7912d12e 100644
|
| --- a/net/http/http_auth_cache_unittest.cc
|
| +++ b/net/http/http_auth_cache_unittest.cc
|
| @@ -19,7 +19,7 @@ namespace {
|
|
|
| class MockAuthHandler : public HttpAuthHandler {
|
| public:
|
| - MockAuthHandler(HttpAuth::Scheme scheme,
|
| + MockAuthHandler(const std::string& scheme,
|
| const std::string& realm,
|
| HttpAuth::Target target) {
|
| // Can't use initializer list since these are members of the base class.
|
| @@ -85,7 +85,7 @@ TEST(HttpAuthCacheTest, Basic) {
|
| // "Realm4"
|
|
|
| scoped_ptr<HttpAuthHandler> realm1_handler(
|
| - new MockAuthHandler(HttpAuth::AUTH_SCHEME_BASIC,
|
| + new MockAuthHandler("basic",
|
| kRealm1,
|
| HttpAuth::AUTH_SERVER));
|
| cache.Add(origin, realm1_handler->realm(), realm1_handler->auth_scheme(),
|
| @@ -94,7 +94,7 @@ TEST(HttpAuthCacheTest, Basic) {
|
| "/foo/bar/index.html");
|
|
|
| scoped_ptr<HttpAuthHandler> realm2_handler(
|
| - new MockAuthHandler(HttpAuth::AUTH_SCHEME_BASIC,
|
| + new MockAuthHandler("basic",
|
| kRealm2,
|
| HttpAuth::AUTH_SERVER));
|
| cache.Add(origin, realm2_handler->realm(), realm2_handler->auth_scheme(),
|
| @@ -103,7 +103,7 @@ TEST(HttpAuthCacheTest, Basic) {
|
| "/foo2/index.html");
|
|
|
| scoped_ptr<HttpAuthHandler> realm3_basic_handler(
|
| - new MockAuthHandler(HttpAuth::AUTH_SCHEME_BASIC,
|
| + new MockAuthHandler("basic",
|
| kRealm3,
|
| HttpAuth::AUTH_PROXY));
|
| cache.Add(origin, realm3_basic_handler->realm(),
|
| @@ -113,7 +113,7 @@ TEST(HttpAuthCacheTest, Basic) {
|
| "");
|
|
|
| scoped_ptr<HttpAuthHandler> realm3_digest_handler(
|
| - new MockAuthHandler(HttpAuth::AUTH_SCHEME_DIGEST,
|
| + new MockAuthHandler("digest",
|
| kRealm3,
|
| HttpAuth::AUTH_PROXY));
|
| cache.Add(origin, realm3_digest_handler->realm(),
|
| @@ -123,7 +123,7 @@ TEST(HttpAuthCacheTest, Basic) {
|
| "/baz/index.html");
|
|
|
| scoped_ptr<HttpAuthHandler> realm4_basic_handler(
|
| - new MockAuthHandler(HttpAuth::AUTH_SCHEME_BASIC,
|
| + new MockAuthHandler("basic",
|
| kRealm4,
|
| HttpAuth::AUTH_SERVER));
|
| cache.Add(origin, realm4_basic_handler->realm(),
|
| @@ -133,24 +133,24 @@ TEST(HttpAuthCacheTest, Basic) {
|
| "/");
|
|
|
| // There is no Realm5
|
| - entry = cache.Lookup(origin, kRealm5, HttpAuth::AUTH_SCHEME_BASIC);
|
| + entry = cache.Lookup(origin, kRealm5, "basic");
|
| EXPECT_TRUE(NULL == entry);
|
|
|
| // While Realm3 does exist, the origin scheme is wrong.
|
| entry = cache.Lookup(GURL("https://www.google.com"), kRealm3,
|
| - HttpAuth::AUTH_SCHEME_BASIC);
|
| + "basic");
|
| EXPECT_TRUE(NULL == entry);
|
|
|
| // Realm, origin scheme ok, authentication scheme wrong
|
| entry = cache.Lookup
|
| - (GURL("http://www.google.com"), kRealm1, HttpAuth::AUTH_SCHEME_DIGEST);
|
| + (GURL("http://www.google.com"), kRealm1, "digest");
|
| EXPECT_TRUE(NULL == entry);
|
|
|
| // Valid lookup by origin, realm, scheme.
|
| entry = cache.Lookup(
|
| - GURL("http://www.google.com:80"), kRealm3, HttpAuth::AUTH_SCHEME_BASIC);
|
| + GURL("http://www.google.com:80"), kRealm3, "basic");
|
| ASSERT_FALSE(NULL == entry);
|
| - EXPECT_EQ(HttpAuth::AUTH_SCHEME_BASIC, entry->scheme());
|
| + EXPECT_EQ("basic", entry->scheme());
|
| EXPECT_EQ(kRealm3, entry->realm());
|
| EXPECT_EQ("Basic realm=Realm3", entry->auth_challenge());
|
| EXPECT_EQ(ASCIIToUTF16("realm3-basic-user"), entry->credentials().username());
|
| @@ -160,9 +160,9 @@ TEST(HttpAuthCacheTest, Basic) {
|
| // Valid lookup by origin, realm, scheme when there's a duplicate
|
| // origin, realm in the cache
|
| entry = cache.Lookup(
|
| - GURL("http://www.google.com:80"), kRealm3, HttpAuth::AUTH_SCHEME_DIGEST);
|
| + GURL("http://www.google.com:80"), kRealm3, "digest");
|
| ASSERT_FALSE(NULL == entry);
|
| - EXPECT_EQ(HttpAuth::AUTH_SCHEME_DIGEST, entry->scheme());
|
| + EXPECT_EQ("digest", entry->scheme());
|
| EXPECT_EQ(kRealm3, entry->realm());
|
| EXPECT_EQ("Digest realm=Realm3", entry->auth_challenge());
|
| EXPECT_EQ(ASCIIToUTF16("realm3-digest-user"),
|
| @@ -171,9 +171,9 @@ TEST(HttpAuthCacheTest, Basic) {
|
| entry->credentials().password());
|
|
|
| // Valid lookup by realm.
|
| - entry = cache.Lookup(origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC);
|
| + entry = cache.Lookup(origin, kRealm2, "basic");
|
| ASSERT_FALSE(NULL == entry);
|
| - EXPECT_EQ(HttpAuth::AUTH_SCHEME_BASIC, entry->scheme());
|
| + EXPECT_EQ("basic", entry->scheme());
|
| EXPECT_EQ(kRealm2, entry->realm());
|
| EXPECT_EQ("Basic realm=Realm2", entry->auth_challenge());
|
| EXPECT_EQ(ASCIIToUTF16("realm2-user"), entry->credentials().username());
|
| @@ -181,9 +181,9 @@ TEST(HttpAuthCacheTest, Basic) {
|
|
|
| // Check that subpaths are recognized.
|
| HttpAuthCache::Entry* realm2_entry = cache.Lookup(
|
| - origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC);
|
| + origin, kRealm2, "basic");
|
| HttpAuthCache::Entry* realm4_entry = cache.Lookup(
|
| - origin, kRealm4, HttpAuth::AUTH_SCHEME_BASIC);
|
| + origin, kRealm4, "basic");
|
| EXPECT_FALSE(NULL == realm2_entry);
|
| EXPECT_FALSE(NULL == realm4_entry);
|
| // Realm4 applies to '/' and Realm2 applies to '/foo2/'.
|
| @@ -210,7 +210,7 @@ TEST(HttpAuthCacheTest, Basic) {
|
|
|
| // Confirm we find the same realm, different auth scheme by path lookup
|
| HttpAuthCache::Entry* realm3_digest_entry =
|
| - cache.Lookup(origin, kRealm3, HttpAuth::AUTH_SCHEME_DIGEST);
|
| + cache.Lookup(origin, kRealm3, "digest");
|
| EXPECT_FALSE(NULL == realm3_digest_entry);
|
| entry = cache.LookupByPath(origin, "/baz/index.html");
|
| EXPECT_TRUE(realm3_digest_entry == entry);
|
| @@ -221,7 +221,7 @@ TEST(HttpAuthCacheTest, Basic) {
|
|
|
| // Confirm we find the same realm, different auth scheme by path lookup
|
| HttpAuthCache::Entry* realm3DigestEntry =
|
| - cache.Lookup(origin, kRealm3, HttpAuth::AUTH_SCHEME_DIGEST);
|
| + cache.Lookup(origin, kRealm3, "digest");
|
| EXPECT_FALSE(NULL == realm3DigestEntry);
|
| entry = cache.LookupByPath(origin, "/baz/index.html");
|
| EXPECT_TRUE(realm3DigestEntry == entry);
|
| @@ -233,7 +233,7 @@ TEST(HttpAuthCacheTest, Basic) {
|
| // Lookup using empty path (may be used for proxy).
|
| entry = cache.LookupByPath(origin, "");
|
| EXPECT_FALSE(NULL == entry);
|
| - EXPECT_EQ(HttpAuth::AUTH_SCHEME_BASIC, entry->scheme());
|
| + EXPECT_EQ("basic", entry->scheme());
|
| EXPECT_EQ(kRealm3, entry->realm());
|
| }
|
|
|
| @@ -278,7 +278,7 @@ TEST(HttpAuthCacheTest, AddToExistingEntry) {
|
|
|
| scoped_ptr<HttpAuthHandler> handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_BASIC, "MyRealm", HttpAuth::AUTH_SERVER));
|
| + "basic", "MyRealm", HttpAuth::AUTH_SERVER));
|
| HttpAuthCache::Entry* orig_entry = cache.Add(
|
| origin, handler->realm(), handler->auth_scheme(), auth_challenge,
|
| CreateASCIICredentials("user1", "password1"), "/x/y/z/");
|
| @@ -288,7 +288,7 @@ TEST(HttpAuthCacheTest, AddToExistingEntry) {
|
| CreateASCIICredentials("user3", "password3"), "/z/y");
|
|
|
| HttpAuthCache::Entry* entry = cache.Lookup(
|
| - origin, "MyRealm", HttpAuth::AUTH_SCHEME_BASIC);
|
| + origin, "MyRealm", "basic");
|
|
|
| EXPECT_TRUE(entry == orig_entry);
|
| EXPECT_EQ(ASCIIToUTF16("user3"), entry->credentials().username());
|
| @@ -304,19 +304,19 @@ TEST(HttpAuthCacheTest, Remove) {
|
|
|
| scoped_ptr<HttpAuthHandler> realm1_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_BASIC, kRealm1, HttpAuth::AUTH_SERVER));
|
| + "basic", kRealm1, HttpAuth::AUTH_SERVER));
|
|
|
| scoped_ptr<HttpAuthHandler> realm2_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_BASIC, kRealm2, HttpAuth::AUTH_SERVER));
|
| + "basic", kRealm2, HttpAuth::AUTH_SERVER));
|
|
|
| scoped_ptr<HttpAuthHandler> realm3_basic_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_BASIC, kRealm3, HttpAuth::AUTH_SERVER));
|
| + "basic", kRealm3, HttpAuth::AUTH_SERVER));
|
|
|
| scoped_ptr<HttpAuthHandler> realm3_digest_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_DIGEST, kRealm3, HttpAuth::AUTH_SERVER));
|
| + "digest", kRealm3, HttpAuth::AUTH_SERVER));
|
|
|
| HttpAuthCache cache;
|
| cache.Add(origin, realm1_handler->realm(), realm1_handler->auth_scheme(),
|
| @@ -333,43 +333,43 @@ TEST(HttpAuthCacheTest, Remove) {
|
|
|
| // Fails, because there is no realm "Realm5".
|
| EXPECT_FALSE(cache.Remove(
|
| - origin, kRealm5, HttpAuth::AUTH_SCHEME_BASIC,
|
| + origin, kRealm5, "basic",
|
| AuthCredentials(kAlice, k123)));
|
|
|
| // Fails because the origin is wrong.
|
| EXPECT_FALSE(cache.Remove(GURL("http://foobar2.com:100"),
|
| kRealm1,
|
| - HttpAuth::AUTH_SCHEME_BASIC,
|
| + "basic",
|
| AuthCredentials(kAlice, k123)));
|
|
|
| // Fails because the username is wrong.
|
| EXPECT_FALSE(cache.Remove(
|
| - origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC,
|
| + origin, kRealm1, "basic",
|
| AuthCredentials(kAlice2, k123)));
|
|
|
| // Fails because the password is wrong.
|
| EXPECT_FALSE(cache.Remove(
|
| - origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC,
|
| + origin, kRealm1, "basic",
|
| AuthCredentials(kAlice, k1234)));
|
|
|
| // Fails because the authentication type is wrong.
|
| EXPECT_FALSE(cache.Remove(
|
| - origin, kRealm1, HttpAuth::AUTH_SCHEME_DIGEST,
|
| + origin, kRealm1, "digest",
|
| AuthCredentials(kAlice, k123)));
|
|
|
| // Succeeds.
|
| EXPECT_TRUE(cache.Remove(
|
| - origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC,
|
| + origin, kRealm1, "basic",
|
| AuthCredentials(kAlice, k123)));
|
|
|
| // Fails because we just deleted the entry!
|
| EXPECT_FALSE(cache.Remove(
|
| - origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC,
|
| + origin, kRealm1, "basic",
|
| AuthCredentials(kAlice, k123)));
|
|
|
| // Succeed when there are two authentication types for the same origin,realm.
|
| EXPECT_TRUE(cache.Remove(
|
| - origin, kRealm3, HttpAuth::AUTH_SCHEME_DIGEST,
|
| + origin, kRealm3, "digest",
|
| AuthCredentials(kRoot, kWileCoyote)));
|
|
|
| // Succeed as above, but when entries were added in opposite order
|
| @@ -377,13 +377,13 @@ TEST(HttpAuthCacheTest, Remove) {
|
| realm3_digest_handler->auth_scheme(), "digest realm=Realm3",
|
| AuthCredentials(kRoot, kWileCoyote), "/");
|
| EXPECT_TRUE(cache.Remove(
|
| - origin, kRealm3, HttpAuth::AUTH_SCHEME_BASIC,
|
| + origin, kRealm3, "basic",
|
| AuthCredentials(kAdmin, kPassword)));
|
|
|
| // Make sure that removing one entry still leaves the other available for
|
| // lookup.
|
| HttpAuthCache::Entry* entry = cache.Lookup(
|
| - origin, kRealm3, HttpAuth::AUTH_SCHEME_DIGEST);
|
| + origin, kRealm3, "digest");
|
| EXPECT_FALSE(NULL == entry);
|
| }
|
|
|
| @@ -392,7 +392,7 @@ TEST(HttpAuthCacheTest, UpdateStaleChallenge) {
|
| GURL origin("http://foobar2.com");
|
| scoped_ptr<HttpAuthHandler> digest_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_DIGEST, kRealm1, HttpAuth::AUTH_PROXY));
|
| + "digest", kRealm1, HttpAuth::AUTH_PROXY));
|
| HttpAuthCache::Entry* entry_pre = cache.Add(
|
| origin,
|
| digest_handler->realm(),
|
| @@ -443,19 +443,19 @@ TEST(HttpAuthCacheTest, UpdateAllFrom) {
|
|
|
| scoped_ptr<HttpAuthHandler> realm1_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_BASIC, kRealm1, HttpAuth::AUTH_SERVER));
|
| + "basic", kRealm1, HttpAuth::AUTH_SERVER));
|
|
|
| scoped_ptr<HttpAuthHandler> realm2_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_BASIC, kRealm2, HttpAuth::AUTH_PROXY));
|
| + "basic", kRealm2, HttpAuth::AUTH_PROXY));
|
|
|
| scoped_ptr<HttpAuthHandler> realm3_digest_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_DIGEST, kRealm3, HttpAuth::AUTH_SERVER));
|
| + "digest", kRealm3, HttpAuth::AUTH_SERVER));
|
|
|
| scoped_ptr<HttpAuthHandler> realm4_handler(
|
| new MockAuthHandler(
|
| - HttpAuth::AUTH_SCHEME_BASIC, kRealm4, HttpAuth::AUTH_SERVER));
|
| + "basic", kRealm4, HttpAuth::AUTH_SERVER));
|
|
|
| HttpAuthCache first_cache;
|
| HttpAuthCache::Entry* entry;
|
| @@ -489,19 +489,19 @@ TEST(HttpAuthCacheTest, UpdateAllFrom) {
|
| second_cache.UpdateAllFrom(first_cache);
|
|
|
| // Copied from first_cache.
|
| - entry = second_cache.Lookup(origin, kRealm1, HttpAuth::AUTH_SCHEME_BASIC);
|
| + entry = second_cache.Lookup(origin, kRealm1, "basic");
|
| EXPECT_TRUE(NULL != entry);
|
| EXPECT_EQ(kAlice, entry->credentials().username());
|
| EXPECT_EQ(k123, entry->credentials().password());
|
|
|
| // Copied from first_cache.
|
| - entry = second_cache.Lookup(origin, kRealm2, HttpAuth::AUTH_SCHEME_BASIC);
|
| + entry = second_cache.Lookup(origin, kRealm2, "basic");
|
| EXPECT_TRUE(NULL != entry);
|
| EXPECT_EQ(kAlice2, entry->credentials().username());
|
| EXPECT_EQ(k1234, entry->credentials().password());
|
|
|
| // Overwritten from first_cache.
|
| - entry = second_cache.Lookup(origin, kRealm3, HttpAuth::AUTH_SCHEME_DIGEST);
|
| + entry = second_cache.Lookup(origin, kRealm3, "digest");
|
| EXPECT_TRUE(NULL != entry);
|
| EXPECT_EQ(kRoot, entry->credentials().username());
|
| EXPECT_EQ(kWileCoyote, entry->credentials().password());
|
| @@ -515,7 +515,7 @@ TEST(HttpAuthCacheTest, UpdateAllFrom) {
|
| EXPECT_EQ(kWileCoyote, entry->credentials().password());
|
|
|
| // Left intact in second_cache.
|
| - entry = second_cache.Lookup(origin, kRealm4, HttpAuth::AUTH_SCHEME_BASIC);
|
| + entry = second_cache.Lookup(origin, kRealm4, "basic");
|
| EXPECT_TRUE(NULL != entry);
|
| EXPECT_EQ(kAdmin, entry->credentials().username());
|
| EXPECT_EQ(kRoot, entry->credentials().password());
|
| @@ -540,7 +540,7 @@ class HttpAuthCacheEvictionTest : public testing::Test {
|
| }
|
|
|
| void AddPathToRealm(int realm_i, int path_i) {
|
| - cache_.Add(origin_, GenerateRealm(realm_i), HttpAuth::AUTH_SCHEME_BASIC, "",
|
| + cache_.Add(origin_, GenerateRealm(realm_i), "basic", "",
|
| AuthCredentials(kUsername, kPassword),
|
| GeneratePath(realm_i, path_i));
|
| }
|
| @@ -548,7 +548,7 @@ class HttpAuthCacheEvictionTest : public testing::Test {
|
| void CheckRealmExistence(int realm_i, bool exists) {
|
| const HttpAuthCache::Entry* entry =
|
| cache_.Lookup(
|
| - origin_, GenerateRealm(realm_i), HttpAuth::AUTH_SCHEME_BASIC);
|
| + origin_, GenerateRealm(realm_i), "basic");
|
| if (exists) {
|
| EXPECT_FALSE(entry == NULL);
|
| EXPECT_EQ(GenerateRealm(realm_i), entry->realm());
|
|
|