diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-15 06:43:48 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-15 06:43:48 +0000 |
commit | 515838ce76cb8bec7f51f6143cac74f113e247ad (patch) | |
tree | 71b70d594974310b35d1c8f7843aeda5717c044b /net/ftp/ftp_auth_cache_unittest.cc | |
parent | 92352a66515fd9a01f538529356ad45870109f28 (diff) | |
download | chromium_src-515838ce76cb8bec7f51f6143cac74f113e247ad.zip chromium_src-515838ce76cb8bec7f51f6143cac74f113e247ad.tar.gz chromium_src-515838ce76cb8bec7f51f6143cac74f113e247ad.tar.bz2 |
post-winhttp cleanup: refactor net/base/auth_cache into net/ftp/ftp_auth_cache.
Also moves AuthCache::HttpKey() --> GetSignonRealmKey().
Review URL: http://codereview.chromium.org/18218
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_auth_cache_unittest.cc')
-rw-r--r-- | net/ftp/ftp_auth_cache_unittest.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/net/ftp/ftp_auth_cache_unittest.cc b/net/ftp/ftp_auth_cache_unittest.cc new file mode 100644 index 0000000..1164540 --- /dev/null +++ b/net/ftp/ftp_auth_cache_unittest.cc @@ -0,0 +1,70 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "googleurl/src/gurl.h" +#include "net/ftp/ftp_auth_cache.h" +#include "testing/gtest/include/gtest/gtest.h" + +using net::AuthData; +using net::FtpAuthCache; + +TEST(FtpAuthCacheTest, LookupAddRemove) { + FtpAuthCache cache; + + GURL origin1("ftp://foo1"); + scoped_refptr<AuthData> data1(new AuthData()); + + GURL origin2("ftp://foo2"); + scoped_refptr<AuthData> data2(new AuthData()); + + GURL origin3("ftp://foo3"); + scoped_refptr<AuthData> data3(new AuthData()); + + // Lookup non-existent entry. + EXPECT_EQ(NULL, cache.Lookup(origin1)); + + // Add entry for origin1. + cache.Add(origin1, data1.get()); + EXPECT_EQ(data1.get(), cache.Lookup(origin1)); + + // Add an entry for origin2. + cache.Add(origin2, data2.get()); + EXPECT_EQ(data1.get(), cache.Lookup(origin1)); + EXPECT_EQ(data2.get(), cache.Lookup(origin2)); + + // Overwrite the entry for origin1. + cache.Add(origin1, data3.get()); + EXPECT_EQ(data3.get(), cache.Lookup(origin1)); + EXPECT_EQ(data2.get(), cache.Lookup(origin2)); + + // Remove entry of origin1. + cache.Remove(origin1); + EXPECT_EQ(NULL, cache.Lookup(origin1)); + EXPECT_EQ(data2.get(), cache.Lookup(origin2)); + + // Remove non-existent entry + cache.Remove(origin1); + EXPECT_EQ(NULL, cache.Lookup(origin1)); + EXPECT_EQ(data2.get(), cache.Lookup(origin2)); +} + +// Check that if the origin differs only by port number, it is considered +// a separate origin. +TEST(FtpAuthCacheTest, LookupWithPort) { + FtpAuthCache cache; + + GURL origin1("ftp://foo:80"); + scoped_refptr<AuthData> data1(new AuthData()); + + GURL origin2("ftp://foo:21"); + scoped_refptr<AuthData> data2(new AuthData()); + + cache.Add(origin1, data1.get()); + cache.Add(origin2, data2.get()); + + EXPECT_EQ(data1.get(), cache.Lookup(origin1)); + EXPECT_EQ(data2.get(), cache.Lookup(origin2)); +} + + |