~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ftp_transport.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-10 19:37:20 UTC
  • mfrom: (4222.3.15 username)
  • Revision ID: pqm@pqm.ubuntu.com-20090410193720-nyej7ft1k2yoyhui
(Jelmer) Prompt for user names for http if they are not in the
        configuration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
from cStringIO import StringIO
 
18
import getpass
18
19
import sys
19
20
 
20
21
from bzrlib import (
84
85
            scheme, self.user, self.password, host, port, path)
85
86
        return url
86
87
 
 
88
    def test_no_prompt_for_username(self):
 
89
        """ensure getpass.getuser() is used if there's no username in the 
 
90
        configuration.""",
 
91
        self.get_server().add_user(getpass.getuser(), self.password)
 
92
        t = self.get_transport()
 
93
        ui.ui_factory = tests.TestUIFactory(stdin=self.password + '\n',
 
94
                                            stdout=tests.StringIOWrapper())
 
95
        # Issue a request to the server to connect
 
96
        t.put_bytes('foo', 'test bytes\n')
 
97
        self.assertEqual('test bytes\n', t.get_bytes('foo'))
 
98
        # Only the password should've been read
 
99
        self.assertEqual('', ui.ui_factory.stdin.readline())
 
100
 
87
101
    def test_prompt_for_password(self):
88
102
        t = self.get_transport()
89
103
        ui.ui_factory = tests.TestUIFactory(stdin=self.password+'\n',