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

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

Issue 7584018: FTP: fix directory listing parsing for Hylafax (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months 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
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 FtpDirectoryListingEntry::FILE, "test", 123, 101 FtpDirectoryListingEntry::FILE, "test", 123,
102 2011, 5, 23, 0, 0 }, 102 2011, 5, 23, 0, 0 },
103 { "drwxrwxr-x 1 ftp ftp 4096 19 \xd0\xbe\xd0\xba\xd1\x82 2011 dir", 103 { "drwxrwxr-x 1 ftp ftp 4096 19 \xd0\xbe\xd0\xba\xd1\x82 2011 dir",
104 FtpDirectoryListingEntry::DIRECTORY, "dir", -1, 104 FtpDirectoryListingEntry::DIRECTORY, "dir", -1,
105 2011, 10, 19, 0, 0 }, 105 2011, 10, 19, 0, 0 },
106 106
107 // Plan9 sends entry type "a" for append-only files. 107 // Plan9 sends entry type "a" for append-only files.
108 { "ar-xr-xr-x 2 none none 512 Apr 26 17:52 plan9", 108 { "ar-xr-xr-x 2 none none 512 Apr 26 17:52 plan9",
109 FtpDirectoryListingEntry::FILE, "plan9", 512, 109 FtpDirectoryListingEntry::FILE, "plan9", 512,
110 1994, 4, 26, 17, 52 }, 110 1994, 4, 26, 17, 52 },
111
112 // Hylafax sends a shorter permission listing.
113 { "drwxrwx 2 10 4096 Jul 28 02:41 tmp",
114 FtpDirectoryListingEntry::DIRECTORY, "tmp", -1,
115 1994, 7, 28, 2, 41 },
111 }; 116 };
112 for (size_t i = 0; i < arraysize(good_cases); i++) { 117 for (size_t i = 0; i < arraysize(good_cases); i++) {
113 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 118 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
114 good_cases[i].input)); 119 good_cases[i].input));
115 120
116 std::vector<FtpDirectoryListingEntry> entries; 121 std::vector<FtpDirectoryListingEntry> entries;
117 EXPECT_TRUE(ParseFtpDirectoryListingLs( 122 EXPECT_TRUE(ParseFtpDirectoryListingLs(
118 GetSingleLineTestCase(good_cases[i].input), 123 GetSingleLineTestCase(good_cases[i].input),
119 GetMockCurrentTime(), 124 GetMockCurrentTime(),
120 &entries)); 125 &entries));
(...skipping 25 matching lines...) Expand all
146 &entries)); 151 &entries));
147 EXPECT_EQ(0U, entries.size()); 152 EXPECT_EQ(0U, entries.size());
148 } 153 }
149 } 154 }
150 155
151 TEST_F(FtpDirectoryListingParserLsTest, Bad) { 156 TEST_F(FtpDirectoryListingParserLsTest, Bad) {
152 const char* bad_cases[] = { 157 const char* bad_cases[] = {
153 " foo", 158 " foo",
154 "garbage", 159 "garbage",
155 "-rw-r--r-- ftp ftp", 160 "-rw-r--r-- ftp ftp",
156 "-rw-r--rgb ftp ftp 528 Nov 01 2007 README",
157 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README", 161 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README",
158 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README", 162 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README",
159 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README", 163 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README",
160 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README", 164 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README",
161 "-rw-r--r-- 1 ftp ftp", 165 "-rw-r--r-- 1 ftp ftp",
162 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README",
163 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README", 166 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README",
164 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", 167 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README",
165 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", 168 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
166 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", 169 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README",
167 "drwxrwxrwx 1 owner group 1024 Sep 13 0:3 audio", 170 "drwxrwxrwx 1 owner group 1024 Sep 13 0:3 audio",
168 171
169 "-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub", 172 "-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub",
170 }; 173 };
171 for (size_t i = 0; i < arraysize(bad_cases); i++) { 174 for (size_t i = 0; i < arraysize(bad_cases); i++) {
172 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 175 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
173 bad_cases[i])); 176 bad_cases[i]));
174 177
175 std::vector<FtpDirectoryListingEntry> entries; 178 std::vector<FtpDirectoryListingEntry> entries;
176 EXPECT_FALSE(ParseFtpDirectoryListingLs(GetSingleLineTestCase(bad_cases[i]), 179 EXPECT_FALSE(ParseFtpDirectoryListingLs(GetSingleLineTestCase(bad_cases[i]),
177 GetMockCurrentTime(), 180 GetMockCurrentTime(),
178 &entries)); 181 &entries));
179 } 182 }
180 } 183 }
181 184
182 } // namespace 185 } // namespace
183 186
184 } // namespace net 187 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.cc ('k') | net/ftp/ftp_directory_listing_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698