~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testsftp.py

  • Committer: Robey Pointer
  • Date: 2005-11-07 07:56:31 UTC
  • mto: (1185.49.5 sftp-fix)
  • mto: This revision was merged to the branch mainline in revision 1518.
  • Revision ID: robey@lag.net-20051107075631-95a57ed02ee8cca0
fix sftp urls to support the ietf draft url spec wrt relative vs absolute sftp urls (this will break existing branch urls); fix username/password parsing in sftp urls; add unit tests to make sure sftp url parsing is working

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
        url = self._sftp_url
110
110
        return SFTPTransport(url)
111
111
 
 
112
 
 
113
class FakeSFTPTransport (object):
 
114
    _sftp = object()
 
115
fake = FakeSFTPTransport()
 
116
 
 
117
 
 
118
class SFTPNonServerTest (unittest.TestCase):
 
119
    def test_parse_url(self):
 
120
        from bzrlib.transport.sftp import SFTPTransport
 
121
        s = SFTPTransport('sftp://simple.example.com/%2fhome/source', clone_from=fake)
 
122
        self.assertEquals(s._host, 'simple.example.com')
 
123
        self.assertEquals(s._port, 22)
 
124
        self.assertEquals(s._path, '/home/source')
 
125
        self.assert_(s._password is None)
 
126
        
 
127
        s = SFTPTransport('sftp://ro%62ey:h%40t@example.com:2222/relative', clone_from=fake)
 
128
        self.assertEquals(s._host, 'example.com')
 
129
        self.assertEquals(s._port, 2222)
 
130
        self.assertEquals(s._username, 'robey')
 
131
        self.assertEquals(s._password, 'h@t')
 
132
        self.assertEquals(s._path, 'relative')
 
133
        
 
134
 
112
135
if not paramiko_loaded:
113
136
    del SFTPTransportTest
 
137
    del SFTPNonServerTest