##// END OF EJS Templates
test-http: test http authentication...
Mads Kiilerich -
r15026:f32a2989 stable
parent child Browse files
Show More
@@ -1,115 +1,164 b''
1
1
2 $ hg init test
2 $ hg init test
3 $ cd test
3 $ cd test
4 $ echo foo>foo
4 $ echo foo>foo
5 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
5 $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
6 $ echo foo>foo.d/foo
6 $ echo foo>foo.d/foo
7 $ echo bar>foo.d/bAr.hg.d/BaR
7 $ echo bar>foo.d/bAr.hg.d/BaR
8 $ echo bar>foo.d/baR.d.hg/bAR
8 $ echo bar>foo.d/baR.d.hg/bAR
9 $ hg commit -A -m 1
9 $ hg commit -A -m 1
10 adding foo
10 adding foo
11 adding foo.d/bAr.hg.d/BaR
11 adding foo.d/bAr.hg.d/BaR
12 adding foo.d/baR.d.hg/bAR
12 adding foo.d/baR.d.hg/bAR
13 adding foo.d/foo
13 adding foo.d/foo
14 $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log
14 $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log
15 $ hg --config server.uncompressed=False serve -p $HGPORT1 -d --pid-file=../hg2.pid
15 $ hg --config server.uncompressed=False serve -p $HGPORT1 -d --pid-file=../hg2.pid
16
16
17 Test server address cannot be reused
17 Test server address cannot be reused
18
18
19 $ hg serve -p $HGPORT1 2>&1
19 $ hg serve -p $HGPORT1 2>&1
20 abort: cannot start server at ':$HGPORT1': Address already in use
20 abort: cannot start server at ':$HGPORT1': Address already in use
21 [255]
21 [255]
22 $ cd ..
22 $ cd ..
23 $ cat hg1.pid hg2.pid >> $DAEMON_PIDS
23 $ cat hg1.pid hg2.pid >> $DAEMON_PIDS
24
24
25 clone via stream
25 clone via stream
26
26
27 $ hg clone --uncompressed http://localhost:$HGPORT/ copy 2>&1
27 $ hg clone --uncompressed http://localhost:$HGPORT/ copy 2>&1
28 streaming all changes
28 streaming all changes
29 6 files to transfer, 606 bytes of data
29 6 files to transfer, 606 bytes of data
30 transferred * bytes in * seconds (*/sec) (glob)
30 transferred * bytes in * seconds (*/sec) (glob)
31 updating to branch default
31 updating to branch default
32 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
33 $ hg verify -R copy
33 $ hg verify -R copy
34 checking changesets
34 checking changesets
35 checking manifests
35 checking manifests
36 crosschecking files in changesets and manifests
36 crosschecking files in changesets and manifests
37 checking files
37 checking files
38 4 files, 1 changesets, 4 total revisions
38 4 files, 1 changesets, 4 total revisions
39
39
40 try to clone via stream, should use pull instead
40 try to clone via stream, should use pull instead
41
41
42 $ hg clone --uncompressed http://localhost:$HGPORT1/ copy2
42 $ hg clone --uncompressed http://localhost:$HGPORT1/ copy2
43 requesting all changes
43 requesting all changes
44 adding changesets
44 adding changesets
45 adding manifests
45 adding manifests
46 adding file changes
46 adding file changes
47 added 1 changesets with 4 changes to 4 files
47 added 1 changesets with 4 changes to 4 files
48 updating to branch default
48 updating to branch default
49 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
49 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
50
50
51 clone via pull
51 clone via pull
52
52
53 $ hg clone http://localhost:$HGPORT1/ copy-pull
53 $ hg clone http://localhost:$HGPORT1/ copy-pull
54 requesting all changes
54 requesting all changes
55 adding changesets
55 adding changesets
56 adding manifests
56 adding manifests
57 adding file changes
57 adding file changes
58 added 1 changesets with 4 changes to 4 files
58 added 1 changesets with 4 changes to 4 files
59 updating to branch default
59 updating to branch default
60 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 $ hg verify -R copy-pull
61 $ hg verify -R copy-pull
62 checking changesets
62 checking changesets
63 checking manifests
63 checking manifests
64 crosschecking files in changesets and manifests
64 crosschecking files in changesets and manifests
65 checking files
65 checking files
66 4 files, 1 changesets, 4 total revisions
66 4 files, 1 changesets, 4 total revisions
67 $ cd test
67 $ cd test
68 $ echo bar > bar
68 $ echo bar > bar
69 $ hg commit -A -d '1 0' -m 2
69 $ hg commit -A -d '1 0' -m 2
70 adding bar
70 adding bar
71 $ cd ..
71 $ cd ..
72
72
73 incoming via HTTP
73 incoming via HTTP
74
74
75 $ hg clone http://localhost:$HGPORT1/ --rev 0 partial
75 $ hg clone http://localhost:$HGPORT1/ --rev 0 partial
76 adding changesets
76 adding changesets
77 adding manifests
77 adding manifests
78 adding file changes
78 adding file changes
79 added 1 changesets with 4 changes to 4 files
79 added 1 changesets with 4 changes to 4 files
80 updating to branch default
80 updating to branch default
81 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
81 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
82 $ cd partial
82 $ cd partial
83 $ touch LOCAL
83 $ touch LOCAL
84 $ hg ci -qAm LOCAL
84 $ hg ci -qAm LOCAL
85 $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n'
85 $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n'
86 comparing with http://localhost:$HGPORT1/
86 comparing with http://localhost:$HGPORT1/
87 searching for changes
87 searching for changes
88 2
88 2
89 $ cd ..
89 $ cd ..
90
90
91 pull
91 pull
92
92
93 $ cd copy-pull
93 $ cd copy-pull
94 $ echo '[hooks]' >> .hg/hgrc
94 $ echo '[hooks]' >> .hg/hgrc
95 $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup' >> .hg/hgrc
95 $ echo 'changegroup = python "$TESTDIR"/printenv.py changegroup' >> .hg/hgrc
96 $ hg pull
96 $ hg pull
97 pulling from http://localhost:$HGPORT1/
97 pulling from http://localhost:$HGPORT1/
98 searching for changes
98 searching for changes
99 adding changesets
99 adding changesets
100 adding manifests
100 adding manifests
101 adding file changes
101 adding file changes
102 added 1 changesets with 1 changes to 1 files
102 added 1 changesets with 1 changes to 1 files
103 changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=http://localhost:$HGPORT1/
103 changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=http://localhost:$HGPORT1/
104 (run 'hg update' to get a working copy)
104 (run 'hg update' to get a working copy)
105 $ cd ..
105 $ cd ..
106
106
107 clone from invalid URL
107 clone from invalid URL
108
108
109 $ hg clone http://localhost:$HGPORT/bad
109 $ hg clone http://localhost:$HGPORT/bad
110 abort: HTTP Error 404: Not Found
110 abort: HTTP Error 404: Not Found
111 [255]
111 [255]
112
112
113 test http authentication
114
115 $ cd test
116 $ cat << EOT > userpass.py
117 > import base64
118 > from mercurial.hgweb import common
119 > def perform_authentication(hgweb, req, op):
120 > auth = req.env.get('HTTP_AUTHORIZATION')
121 > if not auth:
122 > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who',
123 > [('WWW-Authenticate', 'Basic Realm="mercurial"')])
124 > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']:
125 > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no')
126 > def extsetup():
127 > common.permhooks.insert(0, perform_authentication)
128 > EOT
129 $ hg --config extensions.x=userpass.py serve -p $HGPORT2 -d --pid-file=pid
130 $ cat pid >> $DAEMON_PIDS
131
132 $ hg id http://localhost:$HGPORT2/
133 abort: http authorization required
134 [255]
135 $ hg id http://user@localhost:$HGPORT2/
136 abort: http authorization required
137 [255]
138 $ hg id http://user:pass@localhost:$HGPORT2/
139 5fed3813f7f5
140 $ echo '[auth]' >> .hg/hgrc
141 $ echo 'l.schemes=http' >> .hg/hgrc
142 $ echo 'l.prefix=lo' >> .hg/hgrc
143 $ echo 'l.username=user' >> .hg/hgrc
144 $ echo 'l.password=pass' >> .hg/hgrc
145 $ hg id http://localhost:$HGPORT2/
146 5fed3813f7f5
147 $ hg id http://localhost:$HGPORT2/
148 5fed3813f7f5
149 $ hg id http://user@localhost:$HGPORT2/
150 5fed3813f7f5
151 $ hg id http://user:pass@localhost:$HGPORT2/
152 5fed3813f7f5
153 $ hg id http://user2@localhost:$HGPORT2/
154 abort: http authorization required
155 [255]
156 $ hg id http://user:pass2@localhost:$HGPORT2/
157 abort: HTTP Error 403: no
158 [255]
159
160 $ cd ..
161
113 check error log
162 check error log
114
163
115 $ cat error.log
164 $ cat error.log
General Comments 0
You need to be logged in to leave comments. Login now