/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/tests/test_http.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-11 16:29:33 UTC
  • mfrom: (4285.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090411162933-dtrs0q12d9qvbgk6
(vila) Fix realm extraction for http basic authentication

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
 
216
216
class TestAuthHeader(tests.TestCase):
217
217
 
218
 
    def parse_header(self, header):
219
 
        ah =  _urllib2_wrappers.AbstractAuthHandler()
220
 
        return ah._parse_auth_header(header)
 
218
    def parse_header(self, header, auth_handler_class=None):
 
219
        if auth_handler_class is None:
 
220
            auth_handler_class = _urllib2_wrappers.AbstractAuthHandler
 
221
        self.auth_handler =  auth_handler_class()
 
222
        return self.auth_handler._parse_auth_header(header)
221
223
 
222
224
    def test_empty_header(self):
223
225
        scheme, remainder = self.parse_header('')
235
237
        self.assertEquals('basic', scheme)
236
238
        self.assertEquals('realm="Thou should not pass"', remainder)
237
239
 
 
240
    def test_basic_extract_realm(self):
 
241
        scheme, remainder = self.parse_header(
 
242
            'Basic realm="Thou should not pass"',
 
243
            _urllib2_wrappers.BasicAuthHandler)
 
244
        match, realm = self.auth_handler.extract_realm(remainder)
 
245
        self.assertTrue(match is not None)
 
246
        self.assertEquals('Thou should not pass', realm)
 
247
 
238
248
    def test_digest_header(self):
239
249
        scheme, remainder = self.parse_header(
240
250
            'Digest realm="Thou should not pass"')
1533
1543
        self.assertEquals(expected_prompt, stdout.read(len(expected_prompt)))
1534
1544
        self._check_password_prompt(t._unqualified_scheme, 'joe',
1535
1545
                                    stdout.readline())
1536
 
 
 
1546
 
1537
1547
    def test_prompt_for_password(self):
1538
1548
        if self._testing_pycurl():
1539
1549
            raise tests.TestNotApplicable(