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)) |