summaryrefslogtreecommitdiffstats
path: root/net/ftp/ftp_network_transaction_unittest.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-24 21:46:50 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-24 21:46:50 +0000
commitb1c7cc42d026a073d1db2e7fa293be525e936738 (patch)
treeff24b7ee9676f5b6ab1f49106bddd329ef3da7e2 /net/ftp/ftp_network_transaction_unittest.cc
parent63cdfb96a08d384963ee792c4a6687009b0dc10b (diff)
downloadchromium_src-b1c7cc42d026a073d1db2e7fa293be525e936738.zip
chromium_src-b1c7cc42d026a073d1db2e7fa293be525e936738.tar.gz
chromium_src-b1c7cc42d026a073d1db2e7fa293be525e936738.tar.bz2
Correctly talk to VMS servers (translate UNIX paths to VMS and vice versa).
This way we get a native VMS listing and not a UNIX emulation mode, which is slightly different than native UNIX and confuses the parser. TEST=Covered by net_unittests. BUG=22193 Review URL: http://codereview.chromium.org/215058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_network_transaction_unittest.cc')
-rw-r--r--net/ftp/ftp_network_transaction_unittest.cc123
1 files changed, 123 insertions, 0 deletions
diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc
index 54b0501..ba765a7 100644
--- a/net/ftp/ftp_network_transaction_unittest.cc
+++ b/net/ftp/ftp_network_transaction_unittest.cc
@@ -186,6 +186,82 @@ class FtpMockControlSocketDirectoryListing : public FtpMockControlSocket {
DISALLOW_COPY_AND_ASSIGN(FtpMockControlSocketDirectoryListing);
};
+class FtpMockControlSocketVMSDirectoryListing : public FtpMockControlSocket {
+ public:
+ FtpMockControlSocketVMSDirectoryListing() {
+ }
+
+ virtual MockWriteResult OnWrite(const std::string& data) {
+ if (InjectFault())
+ return MockWriteResult(true, data.length());
+ switch (state()) {
+ case PRE_SYST:
+ return Verify("SYST\r\n", data, PRE_PWD, "215 VMS\r\n");
+ case PRE_PWD:
+ return Verify("PWD\r\n", data, PRE_TYPE,
+ "257 \"ANONYMOUS_ROOT:[000000]\"\r\n");
+ case PRE_SIZE:
+ return Verify("SIZE ANONYMOUS_ROOT:[000000]dir\r\n", data, PRE_MDTM,
+ "550 I can only retrieve regular files\r\n");
+ case PRE_MDTM:
+ return Verify("MDTM ANONYMOUS_ROOT:[000000]dir\r\n", data, PRE_RETR,
+ "213 20070221112533\r\n");
+ case PRE_RETR:
+ return Verify("RETR ANONYMOUS_ROOT:[000000]dir\r\n", data, PRE_CWD,
+ "550 Can't download directory\r\n");
+ case PRE_CWD:
+ return Verify("CWD ANONYMOUS_ROOT:[dir]\r\n", data, PRE_LIST,
+ "200 OK\r\n");
+ case PRE_LIST:
+ return Verify("LIST *.*;0\r\n", data, PRE_QUIT, "200 OK\r\n");
+ default:
+ return FtpMockControlSocket::OnWrite(data);
+ }
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FtpMockControlSocketVMSDirectoryListing);
+};
+
+class FtpMockControlSocketVMSDirectoryListingRootDirectory
+ : public FtpMockControlSocket {
+ public:
+ FtpMockControlSocketVMSDirectoryListingRootDirectory() {
+ }
+
+ virtual MockWriteResult OnWrite(const std::string& data) {
+ if (InjectFault())
+ return MockWriteResult(true, data.length());
+ switch (state()) {
+ case PRE_SYST:
+ return Verify("SYST\r\n", data, PRE_PWD, "215 VMS\r\n");
+ case PRE_PWD:
+ return Verify("PWD\r\n", data, PRE_TYPE,
+ "257 \"ANONYMOUS_ROOT:[000000]\"\r\n");
+ case PRE_SIZE:
+ return Verify("SIZE ANONYMOUS_ROOT\r\n", data, PRE_MDTM,
+ "550 I can only retrieve regular files\r\n");
+ case PRE_MDTM:
+ return Verify("MDTM ANONYMOUS_ROOT\r\n", data, PRE_RETR,
+ "213 20070221112533\r\n");
+ case PRE_RETR:
+ return Verify("RETR ANONYMOUS_ROOT\r\n", data, PRE_CWD,
+ "550 Can't download directory\r\n");
+ case PRE_CWD:
+ return Verify("CWD ANONYMOUS_ROOT:[000000]\r\n", data, PRE_LIST,
+ "200 OK\r\n");
+ case PRE_LIST:
+ return Verify("LIST *.*;0\r\n", data, PRE_QUIT, "200 OK\r\n");
+ default:
+ return FtpMockControlSocket::OnWrite(data);
+ }
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(
+ FtpMockControlSocketVMSDirectoryListingRootDirectory);
+};
+
class FtpMockControlSocketFileDownload : public FtpMockControlSocket {
public:
FtpMockControlSocketFileDownload() {
@@ -212,6 +288,38 @@ class FtpMockControlSocketFileDownload : public FtpMockControlSocket {
DISALLOW_COPY_AND_ASSIGN(FtpMockControlSocketFileDownload);
};
+class FtpMockControlSocketVMSFileDownload : public FtpMockControlSocket {
+ public:
+ FtpMockControlSocketVMSFileDownload() {
+ }
+
+ virtual MockWriteResult OnWrite(const std::string& data) {
+ if (InjectFault())
+ return MockWriteResult(true, data.length());
+ switch (state()) {
+ case PRE_SYST:
+ return Verify("SYST\r\n", data, PRE_PWD, "215 VMS\r\n");
+ case PRE_PWD:
+ return Verify("PWD\r\n", data, PRE_TYPE,
+ "257 \"ANONYMOUS_ROOT:[000000]\"\r\n");
+ case PRE_SIZE:
+ return Verify("SIZE ANONYMOUS_ROOT:[000000]file\r\n", data, PRE_MDTM,
+ "213 18\r\n");
+ case PRE_MDTM:
+ return Verify("MDTM ANONYMOUS_ROOT:[000000]file\r\n", data, PRE_RETR,
+ "213 20070221112533\r\n");
+ case PRE_RETR:
+ return Verify("RETR ANONYMOUS_ROOT:[000000]file\r\n", data, PRE_QUIT,
+ "200 OK\r\n");
+ default:
+ return FtpMockControlSocket::OnWrite(data);
+ }
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FtpMockControlSocketVMSFileDownload);
+};
+
class FtpMockControlSocketEscaping : public FtpMockControlSocket {
public:
FtpMockControlSocketEscaping() {
@@ -491,6 +599,16 @@ TEST_F(FtpNetworkTransactionTest, DirectoryTransactionMultilineWelcomeShort) {
ExecuteTransaction(&ctrl_socket, "ftp://host", OK);
}
+TEST_F(FtpNetworkTransactionTest, DirectoryTransactionVMS) {
+ FtpMockControlSocketVMSDirectoryListing ctrl_socket;
+ ExecuteTransaction(&ctrl_socket, "ftp://host/dir", OK);
+}
+
+TEST_F(FtpNetworkTransactionTest, DirectoryTransactionVMSRootDirectory) {
+ FtpMockControlSocketVMSDirectoryListingRootDirectory ctrl_socket;
+ ExecuteTransaction(&ctrl_socket, "ftp://host", OK);
+}
+
TEST_F(FtpNetworkTransactionTest, DownloadTransaction) {
FtpMockControlSocketFileDownload ctrl_socket;
ExecuteTransaction(&ctrl_socket, "ftp://host/file", OK);
@@ -514,6 +632,11 @@ TEST_F(FtpNetworkTransactionTest, DownloadTransactionShortReads5) {
ExecuteTransaction(&ctrl_socket, "ftp://host/file", OK);
}
+TEST_F(FtpNetworkTransactionTest, DownloadTransactionVMS) {
+ FtpMockControlSocketVMSFileDownload ctrl_socket;
+ ExecuteTransaction(&ctrl_socket, "ftp://host/file", OK);
+}
+
TEST_F(FtpNetworkTransactionTest, DownloadTransactionAcceptedDataConnection) {
FtpMockControlSocketFileDownloadAcceptedDataConnection ctrl_socket;
std::string mock_data("mock-data");