Mercurial > hg
annotate tests/test-hgweb-auth.py @ 42439:aae93201f758
mixedrepostorecache: fix a silly redundant updating of set
Differential Revision: https://phab.mercurial-scm.org/D6470
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 31 May 2019 22:38:04 -0700 |
parents | 30dd20a56f3e |
children | 2372284d9457 |
rev | line source |
---|---|
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
1 from __future__ import absolute_import, print_function |
28747
779addce6910
py3: use absolute_import in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
19378
diff
changeset
|
2 |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
3 from mercurial import demandimport; demandimport.enable() |
28747
779addce6910
py3: use absolute_import in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
19378
diff
changeset
|
4 from mercurial import ( |
28808
10c2ce44c35d
test-hgweb-auth: stop direct symbol import of mercurial.error.Abort
Yuya Nishihara <yuya@tcha.org>
parents:
28807
diff
changeset
|
5 error, |
37940
31c37e703cee
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py
Augie Fackler <augie@google.com>
parents:
36327
diff
changeset
|
6 pycompat, |
28807
736f64b23a24
test-hgweb-auth: alias ui as uimod
Yuya Nishihara <yuya@tcha.org>
parents:
28748
diff
changeset
|
7 ui as uimod, |
28747
779addce6910
py3: use absolute_import in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
19378
diff
changeset
|
8 url, |
779addce6910
py3: use absolute_import in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
19378
diff
changeset
|
9 util, |
779addce6910
py3: use absolute_import in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
19378
diff
changeset
|
10 ) |
37940
31c37e703cee
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py
Augie Fackler <augie@google.com>
parents:
36327
diff
changeset
|
11 from mercurial.utils import ( |
31c37e703cee
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py
Augie Fackler <augie@google.com>
parents:
36327
diff
changeset
|
12 stringutil, |
31c37e703cee
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py
Augie Fackler <augie@google.com>
parents:
36327
diff
changeset
|
13 ) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
14 |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28808
diff
changeset
|
15 urlerr = util.urlerr |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28808
diff
changeset
|
16 urlreq = util.urlreq |
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28808
diff
changeset
|
17 |
28807
736f64b23a24
test-hgweb-auth: alias ui as uimod
Yuya Nishihara <yuya@tcha.org>
parents:
28748
diff
changeset
|
18 class myui(uimod.ui): |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
19 def interactive(self): |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
20 return False |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
21 |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29377
diff
changeset
|
22 origui = myui.load() |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
23 |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
24 def writeauth(items): |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
25 ui = origui.copy() |
36327
58c1368ab629
py3: use dict.items() instead of dict.iteritems() in tests
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34023
diff
changeset
|
26 for name, value in items.items(): |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
27 ui.setconfig(b'auth', name, value) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
28 return ui |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
29 |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
30 def _stringifyauthinfo(ai): |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
31 if ai is None: |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
32 return ai |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
33 realm, authuris, user, passwd = ai |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
34 return (pycompat.strurl(realm), |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
35 [pycompat.strurl(u) for u in authuris], |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
36 pycompat.strurl(user), |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
37 pycompat.strurl(passwd), |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
38 ) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
39 |
15005
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
40 def test(auth, urls=None): |
37942
32bc3815efae
stringutil: flip the default of pprint() to bprefix=False
Yuya Nishihara <yuya@tcha.org>
parents:
37940
diff
changeset
|
41 print('CFG:', pycompat.sysstr(stringutil.pprint(auth, bprefix=True))) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
42 prefixes = set() |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
43 for k in auth: |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
44 prefixes.add(k.split(b'.', 1)[0]) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
45 for p in prefixes: |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
46 for name in (b'.username', b'.password'): |
15005
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
47 if (p + name) not in auth: |
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
48 auth[p + name] = p |
36327
58c1368ab629
py3: use dict.items() instead of dict.iteritems() in tests
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34023
diff
changeset
|
49 auth = dict((k, v) for k, v in auth.items() if v is not None) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
50 |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
51 ui = writeauth(auth) |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
52 |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
53 def _test(uri): |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
54 print('URI:', pycompat.strurl(uri)) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
55 try: |
29377
2c019aac6b99
url: extract password database from password manager
liscju <piotr.listkiewicz@gmail.com>
parents:
28883
diff
changeset
|
56 pm = url.passwordmgr(ui, urlreq.httppasswordmgrwithdefaultrealm()) |
15025
0593e8f81c71
http: pass user to readauthforuri() (fix 4a43e23b8c55)
Patrick Mezard <pmezard@gmail.com>
parents:
15024
diff
changeset
|
57 u, authinfo = util.url(uri).authinfo() |
15005
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
58 if authinfo is not None: |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
59 pm.add_password(*_stringifyauthinfo(authinfo)) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
60 print(' ', tuple(pycompat.strurl(a) for a in |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
61 pm.find_user_password('test', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
62 pycompat.strurl(u)))) |
28808
10c2ce44c35d
test-hgweb-auth: stop direct symbol import of mercurial.error.Abort
Yuya Nishihara <yuya@tcha.org>
parents:
28807
diff
changeset
|
63 except error.Abort: |
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
64 print(' ','abort') |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
65 |
15005
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
66 if not urls: |
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
67 urls = [ |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
68 b'http://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
69 b'http://example.org/foo/bar', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
70 b'http://example.org/bar', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
71 b'https://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
72 b'https://example.org/foo/bar', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
73 b'https://example.org/bar', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
74 b'https://x@example.org/bar', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
75 b'https://y@example.org/bar', |
15005
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
76 ] |
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
77 for u in urls: |
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
78 _test(u) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
79 |
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
80 |
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
81 print('\n*** Test in-uri schemes\n') |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
82 test({b'x.prefix': b'http://example.org'}) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
83 test({b'x.prefix': b'https://example.org'}) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
84 test({b'x.prefix': b'http://example.org', b'x.schemes': b'https'}) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
85 test({b'x.prefix': b'https://example.org', b'x.schemes': b'http'}) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
86 |
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
87 print('\n*** Test separately configured schemes\n') |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
88 test({b'x.prefix': b'example.org', b'x.schemes': b'http'}) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
89 test({b'x.prefix': b'example.org', b'x.schemes': b'https'}) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
90 test({b'x.prefix': b'example.org', b'x.schemes': b'http https'}) |
8333
89c80c3dc584
allow http authentication information to be specified in the configuration
Sune Foldager <cryo@cyanite.org>
parents:
diff
changeset
|
91 |
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
92 print('\n*** Test prefix matching\n') |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
93 test({b'x.prefix': b'http://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
94 b'y.prefix': b'http://example.org/bar'}) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
95 test({b'x.prefix': b'http://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
96 b'y.prefix': b'http://example.org/foo/bar'}) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
97 test({b'x.prefix': b'*', b'y.prefix': b'https://example.org/bar'}) |
15005
4a43e23b8c55
hgweb: do not ignore [auth] if url has a username (issue2822)
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
98 |
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
99 print('\n*** Test user matching\n') |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
100 test({b'x.prefix': b'http://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
101 b'x.username': None, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
102 b'x.password': b'xpassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
103 urls=[b'http://y@example.org/foo']) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
104 test({b'x.prefix': b'http://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
105 b'x.username': None, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
106 b'x.password': b'xpassword', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
107 b'y.prefix': b'http://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
108 b'y.username': b'y', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
109 b'y.password': b'ypassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
110 urls=[b'http://y@example.org/foo']) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
111 test({b'x.prefix': b'http://example.org/foo/bar', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
112 b'x.username': None, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
113 b'x.password': b'xpassword', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
114 b'y.prefix': b'http://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
115 b'y.username': b'y', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
116 b'y.password': b'ypassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
117 urls=[b'http://y@example.org/foo/bar']) |
15024
0f1311e829c9
http: strip credentials from urllib2 manager URIs (issue2885)
Patrick Mezard <pmezard@gmail.com>
parents:
15005
diff
changeset
|
118 |
40663
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
119 print('\n*** Test user matching with name in prefix\n') |
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
120 |
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
121 # prefix, username and URL have the same user |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
122 test({b'x.prefix': b'https://example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
123 b'x.username': None, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
124 b'x.password': b'xpassword', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
125 b'y.prefix': b'http://y@example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
126 b'y.username': b'y', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
127 b'y.password': b'ypassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
128 urls=[b'http://y@example.org/foo']) |
40663
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
129 # Prefix has a different user from username and URL |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
130 test({b'y.prefix': b'http://z@example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
131 b'y.username': b'y', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
132 b'y.password': b'ypassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
133 urls=[b'http://y@example.org/foo']) |
40663
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
134 # Prefix has a different user from URL; no username |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
135 test({b'y.prefix': b'http://z@example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
136 b'y.password': b'ypassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
137 urls=[b'http://y@example.org/foo']) |
40663
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
138 # Prefix and URL have same user, but doesn't match username |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
139 test({b'y.prefix': b'http://y@example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
140 b'y.username': b'z', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
141 b'y.password': b'ypassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
142 urls=[b'http://y@example.org/foo']) |
40663
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
143 # Prefix and URL have the same user; no username |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
144 test({b'y.prefix': b'http://y@example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
145 b'y.password': b'ypassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
146 urls=[b'http://y@example.org/foo']) |
40663
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
147 # Prefix user, but no URL user or username |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
148 test({b'y.prefix': b'http://y@example.org/foo', |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
149 b'y.password': b'ypassword'}, |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
150 urls=[b'http://example.org/foo']) |
40663
c53f0ead5781
http: allow 'auth.prefix' to have a username consistent with the URI
Matt Harbison <matt_harbison@yahoo.com>
parents:
37942
diff
changeset
|
151 |
15024
0f1311e829c9
http: strip credentials from urllib2 manager URIs (issue2885)
Patrick Mezard <pmezard@gmail.com>
parents:
15005
diff
changeset
|
152 def testauthinfo(fullurl, authurl): |
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
153 print('URIs:', fullurl, authurl) |
28883
032c4c2f802a
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless <timeless@mozdev.org>
parents:
28808
diff
changeset
|
154 pm = urlreq.httppasswordmgrwithdefaultrealm() |
41451
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
155 ai = _stringifyauthinfo(util.url(pycompat.bytesurl(fullurl)).authinfo()[1]) |
30dd20a56f3e
tests: port test-hgweb-auth.py to Python 3
Augie Fackler <augie@google.com>
parents:
40663
diff
changeset
|
156 pm.add_password(*ai) |
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
157 print(pm.find_user_password('test', authurl)) |
15024
0f1311e829c9
http: strip credentials from urllib2 manager URIs (issue2885)
Patrick Mezard <pmezard@gmail.com>
parents:
15005
diff
changeset
|
158 |
28748
c2ba5a810fa1
py3: use print_function in test-hgweb-auth.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28747
diff
changeset
|
159 print('\n*** Test urllib2 and util.url\n') |
15024
0f1311e829c9
http: strip credentials from urllib2 manager URIs (issue2885)
Patrick Mezard <pmezard@gmail.com>
parents:
15005
diff
changeset
|
160 testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo') |