Show More
@@ -110,6 +110,55 b' clone from invalid URL' | |||
|
110 | 110 | abort: HTTP Error 404: Not Found |
|
111 | 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 | 162 | check error log |
|
114 | 163 | |
|
115 | 164 | $ cat error.log |
General Comments 0
You need to be logged in to leave comments.
Login now