Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: net/ftp/ftp_directory_listing_parser_ls_unittest.cc

Issue 8970023: FTP: work around server bugs resulting in negative file size being sent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_directory_listing_parser_unittest.h" 5 #include "net/ftp/ftp_directory_listing_parser_unittest.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "net/ftp/ftp_directory_listing_parser_ls.h" 10 #include "net/ftp/ftp_directory_listing_parser_ls.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 2009, 5, 18, 0, 0 }, 43 2009, 5, 18, 0, 0 },
44 { "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming", 44 { "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming",
45 FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, 45 FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
46 1993, 12, 8, 15, 54 }, 46 1993, 12, 8, 15, 54 },
47 { "drwxrwxrwx 1 owner group 1024 Sep 13 0:30 audio", 47 { "drwxrwxrwx 1 owner group 1024 Sep 13 0:30 audio",
48 FtpDirectoryListingEntry::DIRECTORY, "audio", -1, 48 FtpDirectoryListingEntry::DIRECTORY, "audio", -1,
49 1994, 9, 13, 0, 30 }, 49 1994, 9, 13, 0, 30 },
50 { "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub", 50 { "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub",
51 FtpDirectoryListingEntry::SYMLINK, "pub", -1, 51 FtpDirectoryListingEntry::SYMLINK, "pub", -1,
52 2008, 9, 18, 0, 0 }, 52 2008, 9, 18, 0, 0 },
53 { "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
54 FtpDirectoryListingEntry::FILE, "README", -1,
55 2007, 11, 1, 0, 0 },
53 56
54 // Tests for the wu-ftpd variant: 57 // Tests for the wu-ftpd variant:
55 { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub", 58 { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub",
56 FtpDirectoryListingEntry::DIRECTORY, "pub", -1, 59 FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
57 2009, 3, 27, 0, 0 }, 60 2009, 3, 27, 0, 0 },
58 { "lrwxrwxrwx 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub", 61 { "lrwxrwxrwx 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub",
59 FtpDirectoryListingEntry::SYMLINK, "pub", -1, 62 FtpDirectoryListingEntry::SYMLINK, "pub", -1,
60 2008, 9, 18, 0, 0 }, 63 2008, 9, 18, 0, 0 },
61 { "drwxr-xr-x (?) (?) 4096 Apr 8 2007 jigdo", 64 { "drwxr-xr-x (?) (?) 4096 Apr 8 2007 jigdo",
62 FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1, 65 FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 157 }
155 } 158 }
156 159
157 TEST_F(FtpDirectoryListingParserLsTest, Bad) { 160 TEST_F(FtpDirectoryListingParserLsTest, Bad) {
158 const char* bad_cases[] = { 161 const char* bad_cases[] = {
159 " foo", 162 " foo",
160 "garbage", 163 "garbage",
161 "-rw-r--r-- ftp ftp", 164 "-rw-r--r-- ftp ftp",
162 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README", 165 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README",
163 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README", 166 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README",
164 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README",
165 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README", 167 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README",
166 "-rw-r--r-- 1 ftp ftp", 168 "-rw-r--r-- 1 ftp ftp",
167 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README", 169 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README",
168 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", 170 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README",
169 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
170 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", 171 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README",
171 "drwxrwxrwx 1 owner group 1024 Sep 13 0:3 audio", 172 "drwxrwxrwx 1 owner group 1024 Sep 13 0:3 audio",
172 173
173 "-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub", 174 "-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub",
174 }; 175 };
175 for (size_t i = 0; i < arraysize(bad_cases); i++) { 176 for (size_t i = 0; i < arraysize(bad_cases); i++) {
176 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 177 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
177 bad_cases[i])); 178 bad_cases[i]));
178 179
179 std::vector<FtpDirectoryListingEntry> entries; 180 std::vector<FtpDirectoryListingEntry> entries;
180 EXPECT_FALSE(ParseFtpDirectoryListingLs(GetSingleLineTestCase(bad_cases[i]), 181 EXPECT_FALSE(ParseFtpDirectoryListingLs(GetSingleLineTestCase(bad_cases[i]),
181 GetMockCurrentTime(), 182 GetMockCurrentTime(),
182 &entries)); 183 &entries));
183 } 184 }
184 } 185 }
185 186
186 } // namespace 187 } // namespace
187 188
188 } // namespace net 189 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698