/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/http_utils.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from cStringIO import StringIO
18
17
import re
19
18
import urllib2
20
19
 
21
20
 
22
 
from bzrlib import (
 
21
from .. import (
23
22
    errors,
24
23
    osutils,
25
24
    tests,
26
25
    transport,
27
26
    )
28
 
from bzrlib.smart import (
 
27
from ..sixish import (
 
28
    BytesIO,
 
29
    )
 
30
from ..smart import (
29
31
    medium,
30
32
    )
31
 
from bzrlib.tests import http_server
32
 
from bzrlib.transport import chroot
 
33
from . import http_server
 
34
from ..transport import chroot
33
35
 
34
36
 
35
37
class HTTPServerWithSmarts(http_server.HttpServer):
46
48
class SmartRequestHandler(http_server.TestingHTTPRequestHandler):
47
49
    """Extend TestingHTTPRequestHandler to support smart client POSTs.
48
50
 
49
 
    XXX: This duplicates a fair bit of the logic in bzrlib.transport.http.wsgi.
 
51
    XXX: This duplicates a fair bit of the logic in breezy.transport.http.wsgi.
50
52
    """
51
53
 
52
54
    def do_POST(self):
81
83
        request_bytes = self.rfile.read(data_length)
82
84
        protocol_factory, unused_bytes = medium._get_protocol_factory_for_bytes(
83
85
            request_bytes)
84
 
        out_buffer = StringIO()
 
86
        out_buffer = BytesIO()
85
87
        smart_protocol_request = protocol_factory(t, out_buffer.write, '/')
86
88
        # Perhaps there should be a SmartServerHTTPMedium that takes care of
87
89
        # feeding the bytes in the http request to the smart_protocol_request,
446
448
        if realm != self.auth_realm:
447
449
            return False
448
450
        user = auth['username']
449
 
        if not self.password_of.has_key(user):
 
451
        if user not in self.password_of:
450
452
            return False
451
453
        algorithm= auth['algorithm']
452
454
        if algorithm != 'MD5':