comparison tests/test-http.t @ 41585:549af2fa089f

tests: extract the http server authentication extension to a single module We had 4 copy/pastes of this, and no coverage for http digests (which are currently broken on py3).
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 05 Feb 2019 09:37:23 -0500
parents 28a4fb793ba1
children 46432c04f010
comparison
equal deleted inserted replaced
41584:a4cd77a425a3 41585:549af2fa089f
169 169
170 test http authentication 170 test http authentication
171 + use the same server to test server side streaming preference 171 + use the same server to test server side streaming preference
172 172
173 $ cd test 173 $ cd test
174 $ cat << EOT > userpass.py 174
175 > import base64 175 $ hg serve --config extensions.x=$TESTDIR/httpserverauth.py -p $HGPORT2 -d \
176 > from mercurial.hgweb import common 176 > --pid-file=pid --config server.preferuncompressed=True \
177 > def perform_authentication(hgweb, req, op):
178 > auth = req.headers.get(b'Authorization')
179 > if not auth:
180 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
181 > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
182 > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', b'pass']:
183 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
184 > def extsetup(ui):
185 > common.permhooks.insert(0, perform_authentication)
186 > EOT
187 $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \
188 > --config server.preferuncompressed=True \
189 > --config web.push_ssl=False --config web.allow_push=* -A ../access.log 177 > --config web.push_ssl=False --config web.allow_push=* -A ../access.log
190 $ cat pid >> $DAEMON_PIDS 178 $ cat pid >> $DAEMON_PIDS
191 179
192 $ cat << EOF > get_pass.py 180 $ cat << EOF > get_pass.py
193 > import getpass 181 > import getpass