Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHGd43810fe52b0: tests: port inline extensions in test-http.t to Python 3
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | tests/test-http.t (18 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 |
updating to branch default | updating to branch default | ||||
4 files updated, 0 files merged, 0 files removed, 0 files unresolved | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||||
try to clone via stream but missing requirements, so should use pull instead | try to clone via stream but missing requirements, so should use pull instead | ||||
$ cat > $TESTTMP/removesupportedformat.py << EOF | $ cat > $TESTTMP/removesupportedformat.py << EOF | ||||
> from mercurial import localrepo | > from mercurial import localrepo | ||||
> def extsetup(ui): | > def extsetup(ui): | ||||
> localrepo.localrepository.supportedformats.remove('generaldelta') | > localrepo.localrepository.supportedformats.remove(b'generaldelta') | ||||
> EOF | > EOF | ||||
$ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --stream http://localhost:$HGPORT/ copy3 | $ hg clone --config extensions.rsf=$TESTTMP/removesupportedformat.py --stream http://localhost:$HGPORT/ copy3 | ||||
warning: stream clone requested but client is missing requirements: generaldelta | warning: stream clone requested but client is missing requirements: generaldelta | ||||
(see https://www.mercurial-scm.org/wiki/MissingRequirement for more information) | (see https://www.mercurial-scm.org/wiki/MissingRequirement for more information) | ||||
requesting all changes | requesting all changes | ||||
adding changesets | adding changesets | ||||
adding manifests | adding manifests | ||||
test http authentication | test http authentication | ||||
+ use the same server to test server side streaming preference | + use the same server to test server side streaming preference | ||||
$ cd test | $ cd test | ||||
$ cat << EOT > userpass.py | $ cat << EOT > userpass.py | ||||
> import base64 | > import base64 | ||||
> from mercurial.hgweb import common | > from mercurial.hgweb import common | ||||
> def perform_authentication(hgweb, req, op): | > def perform_authentication(hgweb, req, op): | ||||
> auth = req.headers.get('Authorization') | > auth = req.headers.get(b'Authorization') | ||||
> if not auth: | > if not auth: | ||||
> raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', | > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who', | ||||
> [('WWW-Authenticate', 'Basic Realm="mercurial"')]) | > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')]) | ||||
> if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']: | > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', b'pass']: | ||||
> raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no') | > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no') | ||||
> def extsetup(): | > def extsetup(): | ||||
> common.permhooks.insert(0, perform_authentication) | > common.permhooks.insert(0, perform_authentication) | ||||
> EOT | > EOT | ||||
$ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \ | $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \ | ||||
> --config server.preferuncompressed=True \ | > --config server.preferuncompressed=True \ | ||||
> --config web.push_ssl=False --config web.allow_push=* -A ../access.log | > --config web.push_ssl=False --config web.allow_push=* -A ../access.log | ||||
$ cat pid >> $DAEMON_PIDS | $ cat pid >> $DAEMON_PIDS | ||||
Create dummy authentication handler that looks for cookies. It doesn't do anything | Create dummy authentication handler that looks for cookies. It doesn't do anything | ||||
useful. It just raises an HTTP 500 with details about the Cookie request header. | useful. It just raises an HTTP 500 with details about the Cookie request header. | ||||
We raise HTTP 500 because its message is printed in the abort message. | We raise HTTP 500 because its message is printed in the abort message. | ||||
$ cat > cookieauth.py << EOF | $ cat > cookieauth.py << EOF | ||||
> from mercurial import util | > from mercurial import util | ||||
> from mercurial.hgweb import common | > from mercurial.hgweb import common | ||||
> def perform_authentication(hgweb, req, op): | > def perform_authentication(hgweb, req, op): | ||||
> cookie = req.headers.get('Cookie') | > cookie = req.headers.get(b'Cookie') | ||||
> if not cookie: | > if not cookie: | ||||
> raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'no-cookie') | > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, b'no-cookie') | ||||
> raise common.ErrorResponse(common.HTTP_SERVER_ERROR, 'Cookie: %s' % cookie) | > raise common.ErrorResponse(common.HTTP_SERVER_ERROR, b'Cookie: %s' % cookie) | ||||
> def extsetup(): | > def extsetup(): | ||||
> common.permhooks.insert(0, perform_authentication) | > common.permhooks.insert(0, perform_authentication) | ||||
> EOF | > EOF | ||||
$ hg serve --config extensions.cookieauth=cookieauth.py -R test -p $HGPORT -d --pid-file=pid | $ hg serve --config extensions.cookieauth=cookieauth.py -R test -p $HGPORT -d --pid-file=pid | ||||
$ cat pid > $DAEMON_PIDS | $ cat pid > $DAEMON_PIDS | ||||
Request without cookie sent should fail due to lack of cookie | Request without cookie sent should fail due to lack of cookie |