~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_utils.py

  • Committer: Vincent Ladeuil
  • Date: 2007-12-21 11:41:15 UTC
  • mto: (3146.3.1 179368) (3156.2.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 3158.
  • Revision ID: v.ladeuil+lp@free.fr-20071221114115-357b0nvt3uq5v55h
Test parametrization for protocol versions achieved. Tests are failing :)

* bzrlib/tests/test_http_implementations.py:
(TransportAdapter, TransportProtocolAdapter,
TransportProtocolAuthenticationAdapter): Adpaters for the
combinations we care about.
(load_tests): List the classes that needs to be adpated and apply
the associated parametrization.
(TestPost.test_post_body_is_received): Don't use
transport.get_transport since we already know the transport class
we want to test.
(TestSpecificRequestHandler.create_transport_readonly_server,
LimitedRangeHTTPServer.__init__,
TestLimitedRangeRequestServer.create_transport_readonly_server,
TestProxyHttpServer.create_transport_secondary_server,
TestHTTPRedirections.create_transport_secondary_server,
TestHTTPSilentRedirections.create_transport_secondary_server,
TestAuth.create_transport_readonly_server,
TestAuth.create_transport_readonly_server): Add protocol_version
parameter to constructors.

* bzrlib/tests/http_utils.py:
(HTTPServerRedirecting, AuthServer, DigestAuthServer,
HTTPBasicAuthServer, HTTPDigestAuthServer, ProxyBasicAuthServer,
ProxyDigestAuthServer): Add protocol_version parameter to
constructors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
class HTTPServerRedirecting(http_server.HttpServer):
146
146
    """An HttpServer redirecting to another server """
147
147
 
148
 
    def __init__(self, request_handler=RedirectRequestHandler):
149
 
        http_server.HttpServer.__init__(self, request_handler)
 
148
    def __init__(self, request_handler=RedirectRequestHandler,
 
149
                 protocol_version=None):
 
150
        http_server.HttpServer.__init__(self, request_handler,
 
151
                                        protocol_version=protocol_version)
150
152
        # redirections is a list of tuples (source, target, code)
151
153
        # - source is a regexp for the paths requested
152
154
        # - target is a replacement for re.sub describing where
307
309
    auth_error_code = None
308
310
    auth_realm = "Thou should not pass"
309
311
 
310
 
    def __init__(self, request_handler, auth_scheme):
311
 
        http_server.HttpServer.__init__(self, request_handler)
 
312
    def __init__(self, request_handler, auth_scheme,
 
313
                 protocol_version=None):
 
314
        http_server.HttpServer.__init__(self, request_handler,
 
315
                                        protocol_version=protocol_version)
312
316
        self.auth_scheme = auth_scheme
313
317
        self.password_of = {}
314
318
        self.auth_required_errors = 0
337
341
 
338
342
    auth_nonce = 'now!'
339
343
 
340
 
    def __init__(self, request_handler, auth_scheme):
341
 
        AuthServer.__init__(self, request_handler, auth_scheme)
 
344
    def __init__(self, request_handler, auth_scheme,
 
345
                 protocol_version=None):
 
346
        AuthServer.__init__(self, request_handler, auth_scheme,
 
347
                            protocol_version=protocol_version)
342
348
 
343
349
    def digest_authorized(self, auth, command):
344
350
        nonce = auth['nonce']
399
405
class HTTPBasicAuthServer(HTTPAuthServer):
400
406
    """An HTTP server requiring basic authentication"""
401
407
 
402
 
    def __init__(self):
403
 
        HTTPAuthServer.__init__(self, BasicAuthRequestHandler, 'basic')
 
408
    def __init__(self, protocol_version=None):
 
409
        HTTPAuthServer.__init__(self, BasicAuthRequestHandler, 'basic',
 
410
                                protocol_version=protocol_version)
404
411
        self.init_http_auth()
405
412
 
406
413
 
407
414
class HTTPDigestAuthServer(DigestAuthServer, HTTPAuthServer):
408
415
    """An HTTP server requiring digest authentication"""
409
416
 
410
 
    def __init__(self):
411
 
        DigestAuthServer.__init__(self, DigestAuthRequestHandler, 'digest')
 
417
    def __init__(self, protocol_version=None):
 
418
        DigestAuthServer.__init__(self, DigestAuthRequestHandler, 'digest',
 
419
                                  protocol_version=protocol_version)
412
420
        self.init_http_auth()
413
421
 
414
422
 
415
423
class ProxyBasicAuthServer(ProxyAuthServer):
416
424
    """A proxy server requiring basic authentication"""
417
425
 
418
 
    def __init__(self):
419
 
        ProxyAuthServer.__init__(self, BasicAuthRequestHandler, 'basic')
 
426
    def __init__(self, protocol_version=None):
 
427
        ProxyAuthServer.__init__(self, BasicAuthRequestHandler, 'basic',
 
428
                                 protocol_version=protocol_version)
420
429
        self.init_proxy_auth()
421
430
 
422
431
 
423
432
class ProxyDigestAuthServer(DigestAuthServer, ProxyAuthServer):
424
433
    """A proxy server requiring basic authentication"""
425
434
 
426
 
    def __init__(self):
427
 
        ProxyAuthServer.__init__(self, DigestAuthRequestHandler, 'digest')
 
435
    def __init__(self, protocol_version=None):
 
436
        ProxyAuthServer.__init__(self, DigestAuthRequestHandler, 'digest',
 
437
                                 protocol_version=protocol_version)
428
438
        self.init_proxy_auth()
429
439
 
430
440