comparison tests/test-hgweb-auth.py @ 40663:c53f0ead5781

http: allow 'auth.prefix' to have a username consistent with the URI It may be a little weird to put a username in the prefix, but the documentation doesn't disallow it, and silently disallowing it has caused confusion[1]. The username must match what is passed in (which seems to be from the URI via a circuitous route), as well as 'auth.username' if it was specified. I thought about printing a warning for a mismatch, but we already don't print a warning if the 'auth.username' and URI username don't match. This change allows the first and second last new test cases to work as expected. It looks like this would have been a problem since at least 0593e8f81c71. [1] https://www.mercurial-scm.org/pipermail/mercurial/2018-November/051069.html
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 16 Nov 2018 17:56:36 -0500
parents 32bc3815efae
children 30dd20a56f3e
comparison
equal deleted inserted replaced
40662:93e5d18251d6 40663:c53f0ead5781
102 'y.prefix': 'http://example.org/foo', 102 'y.prefix': 'http://example.org/foo',
103 'y.username': 'y', 103 'y.username': 'y',
104 'y.password': 'ypassword'}, 104 'y.password': 'ypassword'},
105 urls=['http://y@example.org/foo/bar']) 105 urls=['http://y@example.org/foo/bar'])
106 106
107 print('\n*** Test user matching with name in prefix\n')
108
109 # prefix, username and URL have the same user
110 test({'x.prefix': 'https://example.org/foo',
111 'x.username': None,
112 'x.password': 'xpassword',
113 'y.prefix': 'http://y@example.org/foo',
114 'y.username': 'y',
115 'y.password': 'ypassword'},
116 urls=['http://y@example.org/foo'])
117 # Prefix has a different user from username and URL
118 test({'y.prefix': 'http://z@example.org/foo',
119 'y.username': 'y',
120 'y.password': 'ypassword'},
121 urls=['http://y@example.org/foo'])
122 # Prefix has a different user from URL; no username
123 test({'y.prefix': 'http://z@example.org/foo',
124 'y.password': 'ypassword'},
125 urls=['http://y@example.org/foo'])
126 # Prefix and URL have same user, but doesn't match username
127 test({'y.prefix': 'http://y@example.org/foo',
128 'y.username': 'z',
129 'y.password': 'ypassword'},
130 urls=['http://y@example.org/foo'])
131 # Prefix and URL have the same user; no username
132 test({'y.prefix': 'http://y@example.org/foo',
133 'y.password': 'ypassword'},
134 urls=['http://y@example.org/foo'])
135 # Prefix user, but no URL user or username
136 test({'y.prefix': 'http://y@example.org/foo',
137 'y.password': 'ypassword'},
138 urls=['http://example.org/foo'])
139
107 def testauthinfo(fullurl, authurl): 140 def testauthinfo(fullurl, authurl):
108 print('URIs:', fullurl, authurl) 141 print('URIs:', fullurl, authurl)
109 pm = urlreq.httppasswordmgrwithdefaultrealm() 142 pm = urlreq.httppasswordmgrwithdefaultrealm()
110 pm.add_password(*util.url(fullurl).authinfo()[1]) 143 pm.add_password(*util.url(fullurl).authinfo()[1])
111 print(pm.find_user_password('test', authurl)) 144 print(pm.find_user_password('test', authurl))