tests/test-push-http.t
author Yuya Nishihara <yuya@tcha.org>
Wed, 05 Sep 2012 23:59:27 +0900
changeset 17456 59a168019255
parent 17455 2212af23c9de
child 17466 d5a3bda6e170
permissions -rw-r--r--
hgweb: respond 403 forbidden for ssl required error It's preferable to report "ssl required" as an error, so that the client can detect error and exit with 255. Currently hg exits with 1, which is "nothing to push."
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15446
c5c9ca3719f9 tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents: 15131
diff changeset
     1
  $ "$TESTDIR/hghave" serve || exit 80
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     2
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
     3
  $ hg init test
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
     4
  $ cd test
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
     5
  $ echo a > a
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
     6
  $ hg ci -Ama
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
     7
  adding a
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
     8
  $ cd ..
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
     9
  $ hg clone test test2
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    10
  updating to branch default
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    11
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    12
  $ cd test2
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    13
  $ echo a >> a
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    14
  $ hg ci -mb
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    15
  $ req() {
12743
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12643
diff changeset
    16
  >     hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12643
diff changeset
    17
  >     cat hg.pid >> $DAEMON_PIDS
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12643
diff changeset
    18
  >     hg --cwd ../test2 push http://localhost:$HGPORT/
17455
2212af23c9de test-push-http: include exit status of hg push
Yuya Nishihara <yuya@tcha.org>
parents: 17018
diff changeset
    19
  >     exitstatus=$?
13449
8b1125eb361e test-push-http: use killdaemons.py instead of kill to avoid test unreliability
Gilles Moris <gilles.moris@free.fr>
parents: 13446
diff changeset
    20
  >     "$TESTDIR/killdaemons.py"
12743
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12643
diff changeset
    21
  >     echo % serve errors
4c4aeaab2339 check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 12643
diff changeset
    22
  >     cat errors.log
17455
2212af23c9de test-push-http: include exit status of hg push
Yuya Nishihara <yuya@tcha.org>
parents: 17018
diff changeset
    23
  >     return $exitstatus
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    24
  > }
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    25
  $ cd ../test
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    26
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    27
expect ssl error
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    28
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    29
  $ req
12643
d08bb64888bc tests: reintroduce ":$HGPORT" in test output
Mads Kiilerich <mads@kiilerich.com>
parents: 12483
diff changeset
    30
  pushing to http://localhost:$HGPORT/
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    31
  searching for changes
17456
59a168019255 hgweb: respond 403 forbidden for ssl required error
Yuya Nishihara <yuya@tcha.org>
parents: 17455
diff changeset
    32
  abort: HTTP Error 403: ssl required
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    33
  % serve errors
17456
59a168019255 hgweb: respond 403 forbidden for ssl required error
Yuya Nishihara <yuya@tcha.org>
parents: 17455
diff changeset
    34
  [255]
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    35
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    36
expect authorization error
6167
f53b9a383476 tests: easier hg serve error diagnosis
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 5386
diff changeset
    37
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    38
  $ echo '[web]' > .hg/hgrc
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    39
  $ echo 'push_ssl = false' >> .hg/hgrc
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    40
  $ req
12643
d08bb64888bc tests: reintroduce ":$HGPORT" in test output
Mads Kiilerich <mads@kiilerich.com>
parents: 12483
diff changeset
    41
  pushing to http://localhost:$HGPORT/
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    42
  searching for changes
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    43
  abort: authorization failed
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    44
  % serve errors
17455
2212af23c9de test-push-http: include exit status of hg push
Yuya Nishihara <yuya@tcha.org>
parents: 17018
diff changeset
    45
  [255]
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    46
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    47
expect authorization error: must have authorized user
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    48
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    49
  $ echo 'allow_push = unperson' >> .hg/hgrc
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    50
  $ req
12643
d08bb64888bc tests: reintroduce ":$HGPORT" in test output
Mads Kiilerich <mads@kiilerich.com>
parents: 12483
diff changeset
    51
  pushing to http://localhost:$HGPORT/
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    52
  searching for changes
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    53
  abort: authorization failed
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    54
  % serve errors
17455
2212af23c9de test-push-http: include exit status of hg push
Yuya Nishihara <yuya@tcha.org>
parents: 17018
diff changeset
    55
  [255]
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    56
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    57
expect success
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    58
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    59
  $ echo 'allow_push = *' >> .hg/hgrc
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    60
  $ echo '[hooks]' >> .hg/hgrc
17018
e7fdfc702d9f tests: consistently use printenv.py the same MSYS/Windows-compatible way
Mads Kiilerich <mads@kiilerich.com>
parents: 16982
diff changeset
    61
  $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup 0" >> .hg/hgrc
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    62
  $ req
12643
d08bb64888bc tests: reintroduce ":$HGPORT" in test output
Mads Kiilerich <mads@kiilerich.com>
parents: 12483
diff changeset
    63
  pushing to http://localhost:$HGPORT/
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    64
  searching for changes
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    65
  remote: adding changesets
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    66
  remote: adding manifests
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    67
  remote: adding file changes
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    68
  remote: added 1 changesets with 1 changes to 1 files
16982
9c892c830a72 tests/printenv.py: eliminate trailing spaces on output
Adrian Buehlmann <adrian@cadifra.com>
parents: 16913
diff changeset
    69
  remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http:*: (glob)
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    70
  % serve errors
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    71
  $ hg rollback
13446
1e497df514e2 rollback: clarifies the message about the reverted state (issue2628)
Gilles Moris <gilles.moris@free.fr>
parents: 13405
diff changeset
    72
  repository tip rolled back to revision 0 (undo serve)
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
    73
14093
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    74
expect success, server lacks the httpheader capability
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    75
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    76
  $ CAP=httpheader
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    77
  $ . "$TESTDIR/notcapable"
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    78
  $ req
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    79
  pushing to http://localhost:$HGPORT/
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    80
  searching for changes
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    81
  remote: adding changesets
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    82
  remote: adding manifests
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    83
  remote: adding file changes
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    84
  remote: added 1 changesets with 1 changes to 1 files
16982
9c892c830a72 tests/printenv.py: eliminate trailing spaces on output
Adrian Buehlmann <adrian@cadifra.com>
parents: 16913
diff changeset
    85
  remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http:*: (glob)
14093
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    86
  % serve errors
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    87
  $ hg rollback
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    88
  repository tip rolled back to revision 0 (undo serve)
ce99d887585f httprepo: long arguments support (issue2126)
Steven Brown <StevenGBrown@gmail.com>
parents: 14011
diff changeset
    89
13946
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
    90
expect success, server lacks the unbundlehash capability
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
    91
14011
b69471bdb678 tests: add script to disable a selected wire protocol capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13946
diff changeset
    92
  $ CAP=unbundlehash
b69471bdb678 tests: add script to disable a selected wire protocol capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13946
diff changeset
    93
  $ . "$TESTDIR/notcapable"
13946
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
    94
  $ req
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
    95
  pushing to http://localhost:$HGPORT/
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
    96
  searching for changes
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
    97
  remote: adding changesets
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
    98
  remote: adding manifests
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
    99
  remote: adding file changes
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
   100
  remote: added 1 changesets with 1 changes to 1 files
16982
9c892c830a72 tests/printenv.py: eliminate trailing spaces on output
Adrian Buehlmann <adrian@cadifra.com>
parents: 16913
diff changeset
   101
  remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http:*: (glob)
13946
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
   102
  % serve errors
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
   103
  $ hg rollback
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
   104
  repository tip rolled back to revision 0 (undo serve)
3c2f9f611ef6 tests: new test cases for the unbundlehash capability
Steven Brown <StevenGBrown@gmail.com>
parents: 13449
diff changeset
   105
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   106
expect authorization error: all users denied
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   107
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   108
  $ echo '[web]' > .hg/hgrc
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   109
  $ echo 'push_ssl = false' >> .hg/hgrc
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   110
  $ echo 'deny_push = *' >> .hg/hgrc
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   111
  $ req
12643
d08bb64888bc tests: reintroduce ":$HGPORT" in test output
Mads Kiilerich <mads@kiilerich.com>
parents: 12483
diff changeset
   112
  pushing to http://localhost:$HGPORT/
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   113
  searching for changes
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   114
  abort: authorization failed
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   115
  % serve errors
17455
2212af23c9de test-push-http: include exit status of hg push
Yuya Nishihara <yuya@tcha.org>
parents: 17018
diff changeset
   116
  [255]
2481
5c65b4e51610 add tests for push over http.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   117
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   118
expect authorization error: some users denied, users must be authenticated
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   119
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   120
  $ echo 'deny_push = unperson' >> .hg/hgrc
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   121
  $ req
12643
d08bb64888bc tests: reintroduce ":$HGPORT" in test output
Mads Kiilerich <mads@kiilerich.com>
parents: 12483
diff changeset
   122
  pushing to http://localhost:$HGPORT/
12483
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   123
  searching for changes
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   124
  abort: authorization failed
fecd4966f8d4 tests: unify test-push-http
Matt Mackall <mpm@selenic.com>
parents: 11469
diff changeset
   125
  % serve errors
17455
2212af23c9de test-push-http: include exit status of hg push
Yuya Nishihara <yuya@tcha.org>
parents: 17018
diff changeset
   126
  [255]
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 15933
diff changeset
   127
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 15933
diff changeset
   128
  $ cd ..