~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_utils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-06 20:45:48 UTC
  • mfrom: (4728.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091006204548-bjnc3z4k256ppimz
MutableTree.has_changes() does not require a tree parameter anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
        """Get the server instance for the secondary transport."""
134
134
        if self.__secondary_server is None:
135
135
            self.__secondary_server = self.create_transport_secondary_server()
136
 
            self.__secondary_server.setUp()
137
 
            self.addCleanup(self.__secondary_server.tearDown)
 
136
            self.start_server(self.__secondary_server)
138
137
        return self.__secondary_server
139
138
 
140
139
 
297
296
 
298
297
    def authorized(self):
299
298
        tcs = self.server.test_case_server
300
 
        if tcs.auth_scheme != 'digest':
301
 
            return False
302
299
 
303
300
        auth_header = self.headers.get(tcs.auth_header_recv, None)
304
301
        if auth_header is None:
319
316
        self.send_header(tcs.auth_header_sent,header)
320
317
 
321
318
 
 
319
class DigestAndBasicAuthRequestHandler(DigestAuthRequestHandler):
 
320
    """Implements a digest and basic authentication of a request.
 
321
 
 
322
    I.e. the server proposes both schemes and the client should choose the best
 
323
    one it can handle, which, in that case, should be digest, the only scheme
 
324
    accepted here.
 
325
    """
 
326
 
 
327
    def send_header_auth_reqed(self):
 
328
        tcs = self.server.test_case_server
 
329
        self.send_header(tcs.auth_header_sent,
 
330
                         'Basic realm="%s"' % tcs.auth_realm)
 
331
        header = 'Digest realm="%s", ' % tcs.auth_realm
 
332
        header += 'nonce="%s", algorithm="%s", qop="auth"' % (tcs.auth_nonce,
 
333
                                                              'MD5')
 
334
        self.send_header(tcs.auth_header_sent,header)
 
335
 
 
336
 
322
337
class AuthServer(http_server.HttpServer):
323
338
    """Extends HttpServer with a dictionary of passwords.
324
339
 
410
425
 
411
426
        return response_digest == auth['response']
412
427
 
 
428
 
413
429
class HTTPAuthServer(AuthServer):
414
430
    """An HTTP server requiring authentication"""
415
431
 
447
463
        self.init_http_auth()
448
464
 
449
465
 
 
466
class HTTPBasicAndDigestAuthServer(DigestAuthServer, HTTPAuthServer):
 
467
    """An HTTP server requiring basic or digest authentication"""
 
468
 
 
469
    def __init__(self, protocol_version=None):
 
470
        DigestAuthServer.__init__(self, DigestAndBasicAuthRequestHandler,
 
471
                                  'basicdigest',
 
472
                                  protocol_version=protocol_version)
 
473
        self.init_http_auth()
 
474
        # We really accept Digest only
 
475
        self.auth_scheme = 'digest'
 
476
 
 
477
 
450
478
class ProxyBasicAuthServer(ProxyAuthServer):
451
479
    """A proxy server requiring basic authentication"""
452
480
 
465
493
        self.init_proxy_auth()
466
494
 
467
495
 
 
496
class ProxyBasicAndDigestAuthServer(DigestAuthServer, ProxyAuthServer):
 
497
    """An proxy server requiring basic or digest authentication"""
 
498
 
 
499
    def __init__(self, protocol_version=None):
 
500
        DigestAuthServer.__init__(self, DigestAndBasicAuthRequestHandler,
 
501
                                  'basicdigest',
 
502
                                  protocol_version=protocol_version)
 
503
        self.init_proxy_auth()
 
504
        # We really accept Digest only
 
505
        self.auth_scheme = 'digest'
 
506
 
 
507