/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: Vincent Ladeuil
  • Date: 2007-12-20 14:14:21 UTC
  • mto: (3134.1.1 trunk) (3111.1.11 175524)
  • mto: This revision was merged to the branch mainline in revision 3137.
  • Revision ID: v.ladeuil+lp@free.fr-20071220141421-1m9i2monq5d9zgno
Fix #177643 by making pycurl handle url-embedded credentials again.

* bzrlib/tests/test_http.py:
Define proper tests for pycurl instead of replacing the urllib
ones (a correct refactoring is already under work elsewhere). Add
KnownFailures to document limitations in the pycurl
implementation (cant prompt for password, no support for
authentication.conf, cant handle a nonce change for digest auth).
(TestAuth.test_no_prompt_for_password_when_using_auth_config): Fix
typo.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase._remote_path): Don't mention user and passwords
in urls since bothe implementations handle credentials separately.
(HttpTransportBase._create_auth): Share default credentials
creation between both implementation.

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._get_curl): Save user provided credentials.
(PyCurlTransport._set_curl_options): Set USERPWD explicitely from
credentials if any have been provided in the url.

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib._remote_path): Deleted, pushed to base class.
(HttpTransport_urllib._perform): Simplified.

* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractAuthHandler._build_password_prompt): Fix typo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1321
1321
        self.assertEquals(expected_prompt, actual_prompt)
1322
1322
 
1323
1323
    def test_no_prompt_for_password_when_using_auth_config(self):
1324
 
        user =' joe'
 
1324
        user ='joe'
1325
1325
        password = 'foo'
1326
1326
        stdin_content = 'bar\n'  # Not the right password
1327
1327
        self.server.add_user(user, password)
1395
1395
            osutils.set_or_unset_env(name, value)
1396
1396
 
1397
1397
 
1398
 
class TestHTTPBasicAuth(TestWithTransport_pycurl, TestHTTPAuth,
1399
 
                        TestCaseWithWebserver):
 
1398
class TestHTTPBasicAuth(TestHTTPAuth, TestCaseWithWebserver):
1400
1399
    """Test http basic authentication scheme"""
1401
1400
 
 
1401
    _transport = HttpTransport_urllib
 
1402
 
1402
1403
    def create_transport_readonly_server(self):
1403
1404
        return HTTPBasicAuthServer()
1404
1405
 
1405
1406
 
1406
 
class TestHTTPProxyBasicAuth(TestWithTransport_pycurl, 
1407
 
                             TestProxyAuth, TestCaseWithWebserver):
 
1407
class TestHTTPProxyBasicAuth(TestProxyAuth, TestCaseWithWebserver):
1408
1408
    """Test proxy basic authentication scheme"""
1409
1409
 
 
1410
    _transport = HttpTransport_urllib
 
1411
 
1410
1412
    def create_transport_readonly_server(self):
1411
1413
        return ProxyBasicAuthServer()
1412
1414
 
1430
1432
        self.assertEqual(2, self.server.auth_required_errors)
1431
1433
 
1432
1434
 
1433
 
class TestHTTPDigestAuth(TestWithTransport_pycurl,
1434
 
                         TestHTTPAuth, TestDigestAuth, TestCaseWithWebserver):
 
1435
class TestHTTPDigestAuth(TestHTTPAuth, TestDigestAuth, TestCaseWithWebserver):
1435
1436
    """Test http digest authentication scheme"""
1436
1437
 
 
1438
    _transport = HttpTransport_urllib
 
1439
 
1437
1440
    def create_transport_readonly_server(self):
1438
1441
        return HTTPDigestAuthServer()
1439
1442
 
1440
1443
 
1441
 
class TestHTTPProxyDigestAuth(TestWithTransport_pycurl, TestProxyAuth,
1442
 
                              TestDigestAuth, TestCaseWithWebserver):
 
1444
class TestHTTPProxyDigestAuth(TestProxyAuth, TestDigestAuth,
 
1445
                              TestCaseWithWebserver):
1443
1446
    """Test proxy digest authentication scheme"""
1444
1447
 
 
1448
    _transport = HttpTransport_urllib
 
1449
 
1445
1450
    def create_transport_readonly_server(self):
1446
1451
        return ProxyDigestAuthServer()
1447
1452
 
 
1453
 
 
1454
class TestAuth_pycurl(object):
 
1455
    "Tests that can't be applied to pycurl."""
 
1456
 
 
1457
    def test_prompt_for_password(self):
 
1458
        raise tests.KnownFailure(
 
1459
            'pycurl cannot prompt, it handles auth by embedding'
 
1460
            ' user:pass in urls only')
 
1461
 
 
1462
    def test_no_prompt_for_password_when_using_auth_config(self):
 
1463
        raise tests.KnownFailure(
 
1464
            'pycurl does not support authentication.conf'
 
1465
            ' since it cannot prompt')
 
1466
 
 
1467
 
 
1468
class TestHTTPBasicAuth_pycurl(TestWithTransport_pycurl, TestAuth_pycurl,
 
1469
                               TestHTTPBasicAuth):
 
1470
     """Test http basic authentication scheme for pycurl"""
 
1471
 
 
1472
 
 
1473
class TestHTTPProxyBasicAuth_pycurl(TestWithTransport_pycurl, TestAuth_pycurl,
 
1474
                                    TestHTTPProxyBasicAuth):
 
1475
     """Test proxy basic authentication scheme for pycurl"""
 
1476
 
 
1477
 
 
1478
class TestHTTPDigestAuth_pycurl(TestWithTransport_pycurl, TestAuth_pycurl,
 
1479
                                TestHTTPDigestAuth):
 
1480
     """Test http digest authentication scheme for pycurl"""
 
1481
 
 
1482
     def test_changing_nonce(self):
 
1483
         raise tests.KnownFailure(
 
1484
             'pycurl does not handle a nonce change')
 
1485
 
 
1486
 
 
1487
class TestHTTPProxyDigestAuth_pycurl(TestWithTransport_pycurl, TestAuth_pycurl,
 
1488
                                     TestHTTPProxyDigestAuth):
 
1489
     """Test http digest authentication scheme for pycurl"""
 
1490
 
 
1491
     def test_changing_nonce(self):
 
1492
         raise tests.KnownFailure(
 
1493
             'pycurl does not handle a nonce change')
 
1494