Rev 3525: Allows empty passwords with pyftpdlib ftp test server. in file:///net/bigmamac/Volumes/home/vila/src/bzr/experimental/more-ftp/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Mar 17 08:50:18 GMT 2009


At file:///net/bigmamac/Volumes/home/vila/src/bzr/experimental/more-ftp/

------------------------------------------------------------
revno: 3525
revision-id: v.ladeuil+lp at free.fr-20090317085017-3z3rqqt7uku3sc22
parent: v.ladeuil+lp at free.fr-20090317081926-yzoqbtmef0lvifes
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: pyftpdlib
timestamp: Tue 2009-03-17 09:50:17 +0100
message:
  Allows empty passwords with pyftpdlib ftp test server.
  
  * bzrlib/tests/test_ftp_transport.py:
  (TestFTPServerUI.test_no_prompt_for_password_when_using_auth_config):
  Explicitly test empty password.
  
  * bzrlib/tests/ftp_server/pyftpdlib_based.py:
  (ftpserver.proto_cmds): Override PASS to allow empty passwords.
-------------- next part --------------
=== modified file 'BRANCH.TODO'
--- a/BRANCH.TODO	2009-03-17 08:14:00 +0000
+++ b/BRANCH.TODO	2009-03-17 08:50:17 +0000
@@ -3,8 +3,6 @@
 # 
 #
 
-- explicit test to forbid empty password for ftp ? Or try using
-   arg_needed = None for the PASS command as suggested.
 - handle unicode or utf-8 encoded paths
 - explicit test for chmod and path with spaces
 

=== modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py'
--- a/bzrlib/tests/ftp_server/pyftpdlib_based.py	2009-03-17 08:14:00 +0000
+++ b/bzrlib/tests/ftp_server/pyftpdlib_based.py	2009-03-17 08:50:17 +0000
@@ -124,6 +124,15 @@
     auth_needed=True, arg_needed=True, check_path=False,
     help='Syntax: SITE CHMOD <SP>  octal_mode_bits file-name (chmod file)',
     )
+ftpserver.proto_cmds['PASS'] = ftpserver._CommandProperty(
+    perm=None,
+    auth_needed=False,
+    # An empty password is valid, hence the arg is neither mandatory not
+    # forbidden
+    arg_needed=None,
+    check_path=False,
+    help='Syntax: PASS [<SP> password] (set user password).',
+    )
 
 
 class ftp_server(ftpserver.FTPServer):
@@ -131,7 +140,7 @@
     def __init__(self, address, handler, authorizer):
         ftpserver.FTPServer.__init__(self, address, handler)
         self.authorizer = authorizer
-        # Worth backporting updstream ?
+        # Worth backporting upstream ?
         self.addr = self.socket.getsockname()
 
 

=== modified file 'bzrlib/tests/test_ftp_transport.py'
--- a/bzrlib/tests/test_ftp_transport.py	2009-03-03 15:47:49 +0000
+++ b/bzrlib/tests/test_ftp_transport.py	2009-03-17 08:50:17 +0000
@@ -108,3 +108,18 @@
         self.assertEqual('test bytes\n', t.get_bytes('foo'))
         # stdin should have  been left untouched
         self.assertEqual('precious\n', ui.ui_factory.stdin.readline())
+
+    def test_empty_password(self):
+        # Override the default user/password from setUp
+        self.user = 'jim'
+        self.password = ''
+        self.get_server().add_user(self.user, self.password)
+        t = self.get_transport()
+        ui.ui_factory = tests.TestUIFactory(stdin=self.password+'\n',
+                                            stdout=tests.StringIOWrapper())
+        # Issue a request to the server to connect
+        t.has('whatever/not/existing')
+        # stdin should be empty (the provided password have been consumed),
+        # even if the password is empty, it's followed by a newline.
+        self.assertEqual('', ui.ui_factory.stdin.readline())
+



More information about the bazaar-commits mailing list