/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp.py

  • Committer: Vincent Ladeuil
  • Date: 2007-09-05 07:27:49 UTC
  • mto: (2804.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 2805.
  • Revision ID: v.ladeuil+lp@free.fr-20070905072749-qiud9xt21loarqyy
Fix #137044 by prompting for a password if *none* is provided for ftp.

* bzrlib/transport/ftp.py:
(FtpTransport._create_connection): The fix: the test was inverted.
(_setup_medusa.test_authorizer.__init__): One user can be secured
by verifying his password.
(_setup_medusa.test_authorizer.authorize): Check the password if a
secured user have been declared. Let the doors wide open
otherwise (as before :-/).

* bzrlib/tests/test_ftp_transport.py:
(TestFTPServer.test_basic_exists): New class for UI related tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
            connection = ftplib.FTP()
131
131
            connection.connect(host=self._host, port=self._port)
132
132
            if self._user and self._user != 'anonymous' and \
133
 
                    password is not None: # '' is a valid password
 
133
                    password is None: # '' is a valid password
134
134
                get_password = bzrlib.ui.ui_factory.get_password
135
135
                password = get_password(prompt='FTP %(user)s@%(host)s password',
136
136
                                        user=self._user, host=self._host)
635
635
 
636
636
        def __init__(self, root):
637
637
            self.root = root
 
638
            # If secured_user is set secured_password will be checked
 
639
            self.secured_user = None
 
640
            self.secured_password = None
638
641
 
639
642
        def authorize(self, channel, username, password):
640
643
            """Return (success, reply_string, filesystem)"""
647
650
            else:
648
651
                channel.read_only = 0
649
652
 
650
 
            return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
 
653
            # Only 'foo' user is allowed for the tests
 
654
            if self.secured_user is not None \
 
655
                    and username == self.secured_user \
 
656
                    and password != self.secured_password:
 
657
                return 0, 'Password invalid.', None
 
658
            else:
 
659
                return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
651
660
 
652
661
 
653
662
    class ftp_channel(medusa.ftp_server.ftp_channel):