~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testhttp.py

  • Committer: Robey Pointer
  • Date: 2005-11-21 23:22:59 UTC
  • mto: (1185.49.17 sftp-fix)
  • mto: This revision was merged to the branch mainline in revision 1518.
  • Revision ID: robey@lag.net-20051121232259-224d536cb891cd10
allow user:pass@ info in http urls to be used for auth; this should be easily expandable later to use auth config files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# (C) 2005 Canonical
2
2
 
3
3
from bzrlib.selftest import TestCase
4
 
from bzrlib.transport.http import HttpTransport
5
 
 
 
4
from bzrlib.transport.http import HttpTransport, extract_auth
 
5
 
 
6
class FakeManager (object):
 
7
    def __init__(self):
 
8
        self.credentials = []
 
9
        
 
10
    def add_password(self, realm, host, username, password):
 
11
        self.credentials.append([realm, host, username, password])
 
12
 
 
13
        
6
14
class TestHttpUrls(TestCase):
 
15
    def test_url_parsing(self):
 
16
        f = FakeManager()
 
17
        url = extract_auth('http://example.com', f)
 
18
        self.assertEquals('http://example.com', url)
 
19
        self.assertEquals(0, len(f.credentials))
 
20
        url = extract_auth('http://user:pass@www.bazaar-ng.org/bzr/bzr.dev', f)
 
21
        self.assertEquals('http://www.bazaar-ng.org/bzr/bzr.dev', url)
 
22
        self.assertEquals(1, len(f.credentials))
 
23
        self.assertEquals([None, 'www.bazaar-ng.org', 'user', 'pass'], f.credentials[0])
 
24
        
7
25
    def test_abs_url(self):
8
26
        """Construction of absolute http URLs"""
9
27
        t = HttpTransport('http://bazaar-ng.org/bzr/bzr.dev/')