nlopess         Thu Nov 23 17:37:16 2006 UTC

  Modified files:              
    /php-src/ext/ftp/tests      .cvsignore 004.phpt 005.phpt server.inc 
  Log:
  MFB
  
http://cvs.php.net/viewvc.cgi/php-src/ext/ftp/tests/.cvsignore?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/ftp/tests/.cvsignore
diff -u /dev/null php-src/ext/ftp/tests/.cvsignore:1.2
--- /dev/null   Thu Nov 23 17:37:16 2006
+++ php-src/ext/ftp/tests/.cvsignore    Thu Nov 23 17:37:16 2006
@@ -0,0 +1,8 @@
+*.diff
+*.log
+*.exp
+*.out
+*.php
+*.gcda
+*.gcno
+*.mem
http://cvs.php.net/viewvc.cgi/php-src/ext/ftp/tests/004.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/ftp/tests/004.phpt
diff -u /dev/null php-src/ext/ftp/tests/004.phpt:1.2
--- /dev/null   Thu Nov 23 17:37:16 2006
+++ php-src/ext/ftp/tests/004.phpt      Thu Nov 23 17:37:16 2006
@@ -0,0 +1,79 @@
+--TEST--
+FTP with bogus parameters
+--SKIPIF--
+<?php
+require 'skipif.inc';
+?>
+--FILE--
+<?php
+require 'server.inc';
+
+$ftp = ftp_connect('127.0.0.1', $port);
+if (!$ftp) die("Couldn't connect to the server");
+
+var_dump(ftp_login($ftp, 'user', 'pass'));
+
+var_dump(ftp_systype($ftp));
+
+/* some bogus usage */
+var_dump(ftp_alloc($ftp, array()));
+var_dump(ftp_cdup($ftp, 0));
+var_dump(ftp_chdir($ftp, array()));
+var_dump(ftp_chmod($ftp, 0666));
+var_dump(ftp_get($ftp, 1234,12));
+var_dump(ftp_close());
+var_dump(ftp_connect('sfjkfjaksfjkasjf'));
+var_dump(ftp_delete($ftp, array()));
+var_dump(ftp_exec($ftp, array()));
+
+var_dump(ftp_systype($ftp, 0));
+var_dump(ftp_pwd($ftp, array()));
+
+var_dump(ftp_login($ftp));
+var_dump(ftp_login($ftp, 'user', 'bogus'));
+
+var_dump(ftp_quit($ftp));
+?>
+--EXPECTF--
+bool(true)
+string(4) "UNIX"
+
+Warning: ftp_alloc() expects parameter 2 to be long, array given in %s004.php 
on line 12
+bool(false)
+
+Warning: ftp_cdup() expects exactly 1 parameter, 2 given in %s004.php on line 
13
+NULL
+
+Warning: ftp_chdir() expects parameter 2 to be string, array given in 
%s004.php on line 14
+NULL
+
+Warning: ftp_chmod() expects exactly 3 parameters, 2 given in 
/cvs/php5/ext/ftp/tests/004.php on line 15
+bool(false)
+
+Warning: ftp_get() expects at least 4 parameters, 3 given in 
/cvs/php5/ext/ftp/tests/004.php on line 16
+NULL
+
+Warning: ftp_close() expects exactly 1 parameter, 0 given in %s004.php on line 
17
+NULL
+
+Warning: ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or 
service not known in %s004.php on line 18
+bool(false)
+
+Warning: ftp_delete() expects parameter 2 to be string, array given in 
%s004.php on line 19
+NULL
+
+Warning: ftp_exec() expects parameter 2 to be string, array given in %s004.php 
on line 20
+NULL
+
+Warning: ftp_systype() expects exactly 1 parameter, 2 given in %s004.php on 
line 22
+NULL
+
+Warning: ftp_pwd() expects exactly 1 parameter, 2 given in %s004.php on line 23
+NULL
+
+Warning: ftp_login() expects exactly 3 parameters, 1 given in %s004.php on 
line 25
+NULL
+
+Warning: ftp_login(): Not logged in. in %s004.php on line 26
+bool(false)
+bool(true)
http://cvs.php.net/viewvc.cgi/php-src/ext/ftp/tests/005.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/ftp/tests/005.phpt
diff -u /dev/null php-src/ext/ftp/tests/005.phpt:1.2
--- /dev/null   Thu Nov 23 17:37:16 2006
+++ php-src/ext/ftp/tests/005.phpt      Thu Nov 23 17:37:16 2006
@@ -0,0 +1,86 @@
+--TEST--
+FTP with bogus server responses
+--SKIPIF--
+<?php
+require 'skipif.inc';
+?>
+--FILE--
+<?php
+$bogus = 1;
+require 'server.inc';
+
+$ftp = ftp_connect('127.0.0.1', $port);
+if (!$ftp) die("Couldn't connect to the server");
+
+var_dump(ftp_login($ftp, 'anonymous', '[EMAIL PROTECTED]'));
+
+var_dump(ftp_alloc($ftp, 400));
+var_dump(ftp_cdup($ftp));
+var_dump(ftp_chdir($ftp, '~'));
+var_dump(ftp_chmod($ftp, 0666, 'x'));
+var_dump(ftp_delete($ftp, 'x'));
+var_dump(ftp_exec($ftp, 'x'));
+var_dump(ftp_fget($ftp, STDOUT, 'x', 0));
+var_dump(ftp_fput($ftp, 'x', fopen(__FILE__, 'r'), 0));
+var_dump(ftp_get($ftp, 'x', 'y', 0));
+var_dump(ftp_mdtm($ftp, 'x'));
+var_dump(ftp_mkdir($ftp, 'x'));
+var_dump(ftp_nb_continue($ftp));
+var_dump(ftp_nb_fget($ftp, STDOUT, 'x', 0));
+var_dump(ftp_nb_fput($ftp, 'x', fopen(__FILE__, 'r'), 0));
+var_dump(ftp_systype($ftp));
+var_dump(ftp_pwd($ftp));
+var_dump(ftp_size($ftp, ''));
+var_dump(ftp_rmdir($ftp, ''));
+
+?>
+--EXPECTF--
+bool(true)
+bool(false)
+
+Warning: ftp_cdup(): Command not implemented (1). in %s005.php on line 11
+bool(false)
+
+Warning: ftp_chdir(): Command not implemented (2). in %s005.php on line 12
+bool(false)
+
+Warning: ftp_chmod(): Command not implemented (3). in %s005.php on line 13
+bool(false)
+
+Warning: ftp_delete(): Command not implemented (4). in %s005.php on line 14
+bool(false)
+
+Warning: ftp_exec(): Command not implemented (5). in %s005.php on line 15
+bool(false)
+
+Warning: ftp_fget(): Command not implemented (6). in %s005.php on line 16
+bool(false)
+
+Warning: ftp_fput(): Command not implemented (7). in %s005.php on line 17
+bool(false)
+
+Warning: ftp_get(): Command not implemented (8). in %s005.php on line 18
+bool(false)
+int(-1)
+
+Warning: ftp_mkdir(): Command not implemented (10). in %s005.php on line 20
+bool(false)
+
+Warning: ftp_nb_continue(): no nbronous transfer to continue. in %s005.php on 
line 21
+int(0)
+
+Warning: ftp_nb_fget(): Command not implemented (11). in %s005.php on line 22
+int(0)
+
+Warning: ftp_nb_fput(): Command not implemented (12). in %s005.php on line 23
+int(0)
+
+Warning: ftp_systype(): Command not implemented (13). in %s005.php on line 24
+bool(false)
+
+Warning: ftp_pwd(): Command not implemented (14). in %s005.php on line 25
+bool(false)
+int(-1)
+
+Warning: ftp_rmdir(): Command not implemented (16). in %s005.php on line 27
+bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/ftp/tests/server.inc?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/ftp/tests/server.inc
diff -u php-src/ext/ftp/tests/server.inc:1.2 
php-src/ext/ftp/tests/server.inc:1.3
--- php-src/ext/ftp/tests/server.inc:1.2        Sun Nov 19 18:38:11 2006
+++ php-src/ext/ftp/tests/server.inc    Thu Nov 23 17:37:16 2006
@@ -57,6 +57,10 @@
 fputs($s, "220----- PHP FTP server 0.3 -----\r\n220 Service ready\r\n");
 $buf = fread($s, 2048);
 
+
+function user_auth($buf) {
+       global $user, $s, $ssl;
+
 if (!empty($ssl)) {
        if ($buf !== "AUTH TLS\r\n") {
                fputs($s, "500 Syntax error, command unrecognized.\r\n");
@@ -118,12 +122,19 @@
                exit;
        }
 }
+}
+
+user_auth($buf);
 
 $cwd = '/';
+$num_bogus_cmds = 0;
 
 while($buf = fread($s, 4098)) {
 
-       if ($buf === "HELP\r\n") {
+       if (!empty($bogus)) {
+               fputs($s, "502 Command not implemented 
(".$num_bogus_cmds++.").\r\n");
+
+       } else if ($buf === "HELP\r\n") {
                fputs($s, "214-There is help available for the following 
commands:\r\n");
                fputs($s, " USER\r\n");
                fputs($s, " HELP\r\n");
@@ -139,6 +150,9 @@
                change_dir('..');
                fputs($s, "250 CDUP command successful.\r\n");
 
+       } elseif ($buf === "SYST\r\n") {
+               fputs($s, "215 UNIX Type: L8.\r\n");
+
        } elseif ($buf === "QUIT\r\n") {
                break;
 
@@ -146,6 +160,9 @@
                change_dir($m[1]);
                fputs($s, "250 CWD command successful.\r\n");
 
+       } else if(preg_match('/^USER /', $buf)) {
+               user_auth($buf);
+
        } else {
                fputs($s, "500 Syntax error, command unrecognized.\r\n");
                dump_and_exit($buf);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to