OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ftp/ftp_auth_cache.h" | 5 #include "net/ftp/ftp_auth_cache.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
| 14 using base::ASCIIToUTF16; |
14 using net::FtpAuthCache; | 15 using net::FtpAuthCache; |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 const base::string16 kBogus(ASCIIToUTF16("bogus")); | 19 const base::string16 kBogus(ASCIIToUTF16("bogus")); |
19 const base::string16 kOthername(ASCIIToUTF16("othername")); | 20 const base::string16 kOthername(ASCIIToUTF16("othername")); |
20 const base::string16 kOtherword(ASCIIToUTF16("otherword")); | 21 const base::string16 kOtherword(ASCIIToUTF16("otherword")); |
21 const base::string16 kPassword(ASCIIToUTF16("password")); | 22 const base::string16 kPassword(ASCIIToUTF16("password")); |
22 const base::string16 kPassword1(ASCIIToUTF16("password1")); | 23 const base::string16 kPassword1(ASCIIToUTF16("password1")); |
23 const base::string16 kPassword2(ASCIIToUTF16("password2")); | 24 const base::string16 kPassword2(ASCIIToUTF16("password2")); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 cache.Add(GURL("ftp://last_host"), | 151 cache.Add(GURL("ftp://last_host"), |
151 net::AuthCredentials(kUsername, kPassword)); | 152 net::AuthCredentials(kUsername, kPassword)); |
152 EXPECT_TRUE(cache.Lookup(GURL("ftp://host0")) == NULL); | 153 EXPECT_TRUE(cache.Lookup(GURL("ftp://host0")) == NULL); |
153 | 154 |
154 // Remaining entries should not get evicted. | 155 // Remaining entries should not get evicted. |
155 for (size_t i = 1; i < FtpAuthCache::kMaxEntries; i++) { | 156 for (size_t i = 1; i < FtpAuthCache::kMaxEntries; i++) { |
156 EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + base::IntToString(i)))); | 157 EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + base::IntToString(i)))); |
157 } | 158 } |
158 EXPECT_TRUE(cache.Lookup(GURL("ftp://last_host"))); | 159 EXPECT_TRUE(cache.Lookup(GURL("ftp://last_host"))); |
159 } | 160 } |
OLD | NEW |