comparison tests/test-http.t @ 37733:d43810fe52b0

tests: port inline extensions in test-http.t to Python 3 Differential Revision: https://phab.mercurial-scm.org/D3342
author Augie Fackler <augie@google.com>
date Fri, 13 Apr 2018 21:22:05 -0400
parents 330ada7e8ea5
children b4b7427b5786
comparison
equal deleted inserted replaced
37732:35632d392279 37733:d43810fe52b0
59 try to clone via stream but missing requirements, so should use pull instead 59 try to clone via stream but missing requirements, so should use pull instead
60 60
61 $ cat > $TESTTMP/removesupportedformat.py << EOF 61 $ cat > $TESTTMP/removesupportedformat.py << EOF
62 > from mercurial import localrepo 62 > from mercurial import localrepo
63 > def extsetup(ui): 63 > def extsetup(ui):
64 > localrepo.localrepository.supportedformats.remove('generaldelta') 64 > localrepo.localrepository.supportedformats.remove(b'generaldelta')
65 > EOF 65 > EOF
66 66
67 $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --stream http://localhost:$HGPORT/ copy3 67 $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --stream http://localhost:$HGPORT/ copy3
68 warning: stream clone requested but client is missing requirements: generaldelta 68 warning: stream clone requested but client is missing requirements: generaldelta
69 (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information) 69 (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information)
168 $ cd test 168 $ cd test
169 $ cat << EOT > userpass.py 169 $ cat << EOT > userpass.py
170 > import base64 170 > import base64
171 > from mercurial.hgweb import common 171 > from mercurial.hgweb import common
172 > def perform_authentication(hgweb, req, op): 172 > def perform_authentication(hgweb, req, op):
173 > auth = req.headers.get('Authorization') 173 > auth = req.headers.get(b'Authorization')
174 > if not auth: 174 > if not auth:
175 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', 175 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
176 > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) 176 > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
177 > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']: 177 > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', b'pass']:
178 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no') 178 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
179 > def extsetup(): 179 > def extsetup():
180 > common.permhooks.insert(0, perform_authentication) 180 > common.permhooks.insert(0, perform_authentication)
181 > EOT 181 > EOT
182 $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \ 182 $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \
183 > --config server.preferuncompressed=True \ 183 > --config server.preferuncompressed=True \
512 512
513 $ cat > cookieauth.py << EOF 513 $ cat > cookieauth.py << EOF
514 > from mercurial import util 514 > from mercurial import util
515 > from mercurial.hgweb import common 515 > from mercurial.hgweb import common
516 > def perform_authentication(hgweb, req, op): 516 > def perform_authentication(hgweb, req, op):
517 > cookie = req.headers.get('Cookie') 517 > cookie = req.headers.get(b'Cookie')
518 > if not cookie: 518 > if not cookie:
519 > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'no-cookie') 519 > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, b'no-cookie')
520 > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'Cookie: %s' % cookie) 520 > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, b'Cookie: %s' % cookie)
521 > def extsetup(): 521 > def extsetup():
522 > common.permhooks.insert(0, perform_authentication) 522 > common.permhooks.insert(0, perform_authentication)
523 > EOF 523 > EOF
524 524
525 $ hg serve --config extensions.cookieauth=cookieauth.py -R test -p $HGPORT -d --pid-file=pid 525 $ hg serve --config extensions.cookieauth=cookieauth.py -R test -p $HGPORT -d --pid-file=pid