2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
3 * Copyright 2009-2010 Detlef Riekenberg
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
24 /* needed for IInternetZoneManagerEx2 */
25 #define _WIN32_IE 0x0700
27 #include <wine/test.h>
38 #define DEFINE_EXPECT(func) \
39 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
41 #define SET_EXPECT(func) \
42 expect_ ## func = TRUE
44 #define CHECK_EXPECT(func) \
46 ok(expect_ ##func, "unexpected call " #func "\n"); \
47 expect_ ## func = FALSE; \
48 called_ ## func = TRUE; \
51 #define CHECK_EXPECT2(func) \
53 ok(expect_ ##func, "unexpected call " #func "\n"); \
54 called_ ## func = TRUE; \
57 #define CHECK_CALLED(func) \
59 ok(called_ ## func, "expected " #func "\n"); \
60 expect_ ## func = called_ ## func = FALSE; \
63 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input
);
64 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input2
);
65 DEFINE_EXPECT(ParseUrl_SECURITY_URL_expected
);
66 DEFINE_EXPECT(ParseUrl_SECURITY_URL_http
);
67 DEFINE_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
69 static HRESULT (WINAPI
*pCoInternetCreateSecurityManager
)(IServiceProvider
*, IInternetSecurityManager
**, DWORD
);
70 static HRESULT (WINAPI
*pCoInternetCreateZoneManager
)(IServiceProvider
*, IInternetZoneManager
**, DWORD
);
71 static HRESULT (WINAPI
*pCoInternetGetSecurityUrl
)(LPCWSTR
, LPWSTR
*, PSUACTION
, DWORD
);
72 static HRESULT (WINAPI
*pCoInternetGetSecurityUrlEx
)(IUri
*, IUri
**, PSUACTION
, DWORD_PTR
);
73 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
74 static HRESULT (WINAPI
*pCoInternetGetSession
)(DWORD
, IInternetSession
**, DWORD
);
76 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
77 '/','b','l','a','n','k','.','h','t','m',0};
78 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
79 static const WCHAR url3
[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
80 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
81 '%','2','e','j','p','g',0};
82 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
83 '.','w','i','n','e','t','e','s','t',0};
84 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
85 static const WCHAR url7
[] = {'f','t','p',':','/','/','z','o','n','e','3',
86 '.','w','i','n','e','t','e','s','t','/','f','i','l','e','.','t','e','s','t',0};
87 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
88 static const WCHAR url9
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
89 '.','w','i','n','e','t','e','s','t', '/','s','i','t','e','/','a','b','o','u','t',0};
90 static const WCHAR url10
[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
93 static const WCHAR url4e
[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
96 static const WCHAR winetestW
[] = {'w','i','n','e','t','e','s','t',0};
97 static const WCHAR security_urlW
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g',0};
98 static const WCHAR security_url2W
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g','2',0};
99 static const WCHAR security_expectedW
[] = {'w','i','n','e','t','e','s','t',':','z','i','p',0};
100 static const WCHAR winetest_to_httpW
[] = {'w','i','n','e','t','e','s','t',':','h',0};
102 static const BYTE secid1
[] = {'f','i','l','e',':',0,0,0,0};
103 static const BYTE secid5
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
104 '.','w','i','n','e','t','e','s','t',3,0,0,0};
105 static const BYTE secid6
[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
106 static const BYTE secid7
[] = {'f','t','p',':','z','o','n','e','3',
107 '.','w','i','n','e','t','e','s','t',3,0,0,0};
108 static const BYTE secid10
[] =
109 {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
110 static const BYTE secid10_2
[] =
111 {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
113 static const GUID CLSID_TestActiveX
=
114 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
116 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
117 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
=
118 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
120 static int called_securl_http
;
122 static struct secmgr_test
{
130 {url1
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
131 {url2
, 100, 0x80041001, 0, NULL
, E_INVALIDARG
},
132 {url3
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
133 {url5
, 3, S_OK
, sizeof(secid5
), secid5
, S_OK
},
134 {url6
, 3, S_OK
, sizeof(secid6
), secid6
, S_OK
},
135 {url7
, 3, S_OK
, sizeof(secid7
), secid7
, S_OK
}
138 static int strcmp_w(const WCHAR
*str1
, const WCHAR
*str2
)
140 DWORD len1
= lstrlenW(str1
);
141 DWORD len2
= lstrlenW(str2
);
143 if(len1
!=len2
) return 1;
144 return memcmp(str1
, str2
, len1
*sizeof(WCHAR
));
147 static inline void heap_free(void *mem
)
149 HeapFree(GetProcessHeap(), 0, mem
);
152 static inline LPWSTR
a2w(LPCSTR str
)
157 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
158 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
159 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
165 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
166 LPWSTR strAW
= a2w(strA
);
167 DWORD ret
= lstrcmpW(strAW
, strB
);
172 static void test_SecurityManager(void)
175 IInternetSecurityManager
*secmgr
= NULL
;
177 DWORD zone
, size
, policy
;
180 if(!pCoInternetCreateSecurityManager
) {
184 trace("Testing security manager...\n");
186 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
187 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
191 for(i
=0; i
< sizeof(secmgr_tests
)/sizeof(secmgr_tests
[0]); i
++) {
193 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, secmgr_tests
[i
].url
,
195 ok(hres
== secmgr_tests
[i
].zone_hres
/* IE <=6 */
196 || (FAILED(secmgr_tests
[i
].zone_hres
) && hres
== E_INVALIDARG
), /* IE7 */
197 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
198 i
, hres
, secmgr_tests
[i
].zone_hres
);
200 ok(zone
== secmgr_tests
[i
].zone
, "[%d] zone=%d, expected %d\n", i
, zone
,
201 secmgr_tests
[i
].zone
);
203 ok(zone
== secmgr_tests
[i
].zone
|| zone
== -1, "[%d] zone=%d\n", i
, zone
);
206 memset(buf
, 0xf0, sizeof(buf
));
207 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[i
].url
,
209 ok(hres
== secmgr_tests
[i
].secid_hres
,
210 "[%d] GetSecurityId failed: %08x, expected %08x\n",
211 i
, hres
, secmgr_tests
[i
].secid_hres
);
212 if(secmgr_tests
[i
].secid
) {
213 ok(size
== secmgr_tests
[i
].secid_size
, "[%d] size=%d, expected %d\n",
214 i
, size
, secmgr_tests
[i
].secid_size
);
215 ok(!memcmp(buf
, secmgr_tests
[i
].secid
, size
), "[%d] wrong secid\n", i
);
220 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url10
, &zone
, 0);
221 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
222 ok(zone
== 3, "zone=%d, expected 3\n", zone
);
224 /* win2k3 translates %20 into a space */
226 memset(buf
, 0xf0, sizeof(buf
));
227 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url10
, buf
, &size
, 0);
228 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
229 ok(size
== sizeof(secid10
) ||
230 size
== sizeof(secid10_2
), /* win2k3 */
232 ok(!memcmp(buf
, secid10
, size
) ||
233 !memcmp(buf
, secid10_2
, size
), /* win2k3 */
237 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, NULL
, &zone
, 0);
238 ok(hres
== E_INVALIDARG
, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres
);
239 ok(zone
== 100 || zone
== -1, "zone=%d\n", zone
);
242 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, NULL
, buf
, &size
, 0);
243 ok(hres
== E_INVALIDARG
,
244 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
245 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
247 ok(hres
== E_INVALIDARG
,
248 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
249 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
251 ok(hres
== E_INVALIDARG
,
252 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
254 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, NULL
, URLACTION_SCRIPT_RUN
, (BYTE
*)&policy
,
255 sizeof(WCHAR
), NULL
, 0, 0, 0);
256 ok(hres
== E_INVALIDARG
, "ProcessUrlAction failed: %08x, expected E_INVALIDARG\n", hres
);
258 IInternetSecurityManager_Release(secmgr
);
261 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
262 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
263 static BOOL
is_ie_hardened(void)
266 DWORD ie_harden
, type
, size
;
269 if(RegOpenKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
270 0, KEY_QUERY_VALUE
, &zone_map
) == ERROR_SUCCESS
) {
271 size
= sizeof(DWORD
);
272 if (RegQueryValueExA(zone_map
, "IEHarden", NULL
, &type
, (LPBYTE
) &ie_harden
, &size
) != ERROR_SUCCESS
||
276 RegCloseKey(zone_map
);
279 return ie_harden
!= 0;
282 static void test_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
284 DWORD res
, size
, policy
, reg_policy
;
289 /* FIXME: HKEY_CURRENT_USER is most of the time the default but this can be changed on a system.
290 * The test should be changed to cope with that, if need be.
292 res
= RegOpenKeyA(HKEY_CURRENT_USER
,
293 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
294 if(res
!= ERROR_SUCCESS
) {
295 ok(0, "Could not open zone key\n");
299 wsprintf(buf
, "%X", action
);
300 size
= sizeof(DWORD
);
301 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
303 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
305 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
306 sizeof(WCHAR
), NULL
, 0, 0, 0);
307 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
308 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
309 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
312 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
313 sizeof(DWORD
), URLZONEREG_DEFAULT
);
314 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
315 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
316 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
321 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
322 sizeof(DWORD
), URLZONEREG_DEFAULT
);
323 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
324 ok(policy
== reg_policy
, "(%x) policy=%x, expected %x\n", action
, policy
, reg_policy
);
326 if(policy
!= URLPOLICY_QUERY
) {
327 if(winetest_interactive
|| ! is_ie_hardened()) {
328 BOOL expect_parse_call
= !called_securl_http
;
331 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
332 sizeof(WCHAR
), NULL
, 0, 0, 0);
333 if(reg_policy
== URLPOLICY_DISALLOW
)
334 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
336 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
337 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
340 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
342 if(reg_policy
== URLPOLICY_DISALLOW
)
343 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
345 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
346 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
349 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
350 sizeof(DWORD
), NULL
, 0, 0, 0);
351 if(reg_policy
== URLPOLICY_DISALLOW
)
352 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
354 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
355 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
358 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
359 sizeof(WCHAR
), (BYTE
*)0xdeadbeef, 16, 0, 0);
360 if(reg_policy
== URLPOLICY_DISALLOW
)
361 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
363 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
364 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
367 if(expect_parse_call
)
368 SET_EXPECT(ParseUrl_SECURITY_URL_http
);
369 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, winetest_to_httpW
, action
, (BYTE
*)&policy
,
370 sizeof(DWORD
), NULL
, 0, 0, 0);
371 if(expect_parse_call
)
372 CHECK_CALLED(ParseUrl_SECURITY_URL_http
);
373 if(reg_policy
== URLPOLICY_DISALLOW
)
374 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
376 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
377 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
379 skip("IE running in Enhanced Security Configuration\n");
384 static void test_special_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
390 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
391 sizeof(DWORD
), URLZONEREG_DEFAULT
);
392 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
393 ok(policy
== URLPOLICY_DISALLOW
, "(%x) policy=%x, expected URLPOLICY_DISALLOW\n", action
, policy
);
396 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
397 sizeof(WCHAR
), NULL
, 0, 0, 0);
398 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
401 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
402 sizeof(DWORD
), NULL
, 0, 0, 0);
403 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
404 ok(policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
407 static void test_activex(IInternetSecurityManager
*secmgr
)
409 DWORD policy
, policy_size
;
410 struct CONFIRMSAFETY cs
;
415 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
,
416 sizeof(DWORD
), (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
417 ok(hres
== S_OK
, "ProcessUrlAction(URLACTION_ACTIVEX_RUN) failed: %08x\n", hres
);
418 ok(policy
== URLPOLICY_ALLOW
|| policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
420 cs
.clsid
= CLSID_TestActiveX
;
421 cs
.pUnk
= (IUnknown
*)0xdeadbeef;
423 hres
= IInternetSecurityManager_QueryCustomPolicy(secmgr
, url1
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
424 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
425 ok(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
), "QueryCusromPolicy failed: %08x\n", hres
);
428 static void test_polices(void)
430 IInternetZoneManager
*zonemgr
= NULL
;
431 IInternetSecurityManager
*secmgr
= NULL
;
434 trace("testing polices...\n");
436 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
437 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
438 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
439 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
441 test_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_RUN
);
442 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_RUN
);
443 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY
);
444 test_url_action(secmgr
, zonemgr
, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS
);
445 test_url_action(secmgr
, zonemgr
, 0xdeadbeef);
447 test_special_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_OVERRIDE_SAFETY
);
448 test_special_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY
);
450 test_activex(secmgr
);
452 IInternetSecurityManager_Release(secmgr
);
453 IInternetZoneManager_Release(zonemgr
);
456 static void test_CoInternetCreateZoneManager(void)
458 IInternetZoneManager
*zonemgr
= NULL
;
459 IUnknown
*punk
= NULL
;
462 trace("simple zone manager tests...\n");
464 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
465 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
469 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IUnknown
, (void **) &punk
);
470 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
472 IUnknown_Release(punk
);
474 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManager
, (void **) &punk
);
475 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
477 IUnknown_Release(punk
);
480 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx
, (void **) &punk
);
482 IUnknown_Release(punk
);
484 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx2
, (void **) &punk
);
485 ok(hr
== S_OK
|| broken(hr
== ERROR_NOINTERFACE
/* some W2K3 */),
486 "got 0x%x (expected S_OK)\n", hr
);
488 IUnknown_Release(punk
);
490 win_skip("InternetZoneManagerEx2 not supported\n");
494 win_skip("InternetZoneManagerEx not supported\n");
496 hr
= IInternetZoneManager_Release(zonemgr
);
497 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
501 static void test_CreateZoneEnumerator(void)
503 IInternetZoneManager
*zonemgr
= NULL
;
510 trace("testing zone enumerator...\n");
512 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
513 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
518 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, NULL
, 0);
519 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef),
520 "got 0x%x with 0x%x (expected E_INVALIDARG with 0xdeadbeef)\n", hr
, dwEnum
);
523 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, NULL
, &dwCount
, 0);
524 ok((hr
== E_INVALIDARG
) && (dwCount
== 0xdeadbeef),
525 "got 0x%x and 0x%x (expected E_INVALIDARG and 0xdeadbeef)\n", hr
, dwCount
);
529 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0xffffffff);
530 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
531 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
532 hr
, dwEnum
, dwCount
);
536 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 1);
537 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
538 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
539 hr
, dwEnum
, dwCount
);
544 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
545 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
550 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum2
, &dwCount2
, 0);
551 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
553 /* native urlmon has an incrementing counter for dwEnum */
554 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum2
);
555 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
558 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
559 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
561 /* Destroy the Enumerator twice is detected and handled in native urlmon */
562 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
563 ok((hr
== E_INVALIDARG
), "got 0x%x (expected E_INVALIDARG)\n", hr
);
566 /* ::Release succeed also, when a ::DestroyZoneEnumerator is missing */
567 hr
= IInternetZoneManager_Release(zonemgr
);
568 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
571 static void test_GetZoneActionPolicy(void)
573 IInternetZoneManager
*zonemgr
= NULL
;
576 DWORD action
= URLACTION_CREDENTIALS_USE
; /* Implemented on all IE versions */
578 trace("testing GetZoneActionPolixy...\n");
580 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
581 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
585 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
586 sizeof(DWORD
), URLZONEREG_DEFAULT
);
587 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
588 ok(*(DWORD
*)buf
== URLPOLICY_CREDENTIALS_SILENT_LOGON_OK
||
589 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_MUST_PROMPT_USER
||
590 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT
||
591 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY
,
592 "unexpected policy=%d\n", *(DWORD
*)buf
);
594 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, NULL
,
595 sizeof(DWORD
), URLZONEREG_DEFAULT
);
596 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
598 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
599 2, URLZONEREG_DEFAULT
);
600 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
602 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1fff, buf
,
603 sizeof(DWORD
), URLZONEREG_DEFAULT
);
604 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
605 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
607 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 13, action
, buf
,
608 sizeof(DWORD
), URLZONEREG_DEFAULT
);
609 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
611 IInternetZoneManager_Release(zonemgr
);
614 static void test_GetZoneAt(void)
616 IInternetZoneManager
*zonemgr
= NULL
;
623 trace("testing GetZoneAt...\n");
625 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
626 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
630 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
635 /* this crashes with native urlmon */
636 IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, 0, NULL
);
640 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, 0xdeadbeef, 0, &dwZone
);
641 ok(hr
== E_INVALIDARG
,
642 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
644 for (i
= 0; i
< dwCount
; i
++)
647 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, i
, &dwZone
);
648 ok(hr
== S_OK
, "#%d: got x%x with %d (expected S_OK)\n", i
, hr
, dwZone
);
652 /* MSDN (index .. must be .. less than or equal to) is wrong */
653 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, dwCount
, &dwZone
);
654 ok(hr
== E_INVALIDARG
,
655 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
657 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
658 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
661 hr
= IInternetZoneManager_Release(zonemgr
);
662 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
665 static void test_GetZoneAttributes(void)
667 IInternetZoneManager
*zonemgr
= NULL
;
668 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 32];
669 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
673 trace("testing GetZoneAttributes...\n");
675 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
676 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
680 /* native urlmon has Zone "0" up to Zone "4" since IE4 */
681 for (i
= 0; i
< 5; i
++) {
682 memset(buffer
, -1, sizeof(buffer
));
683 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, i
, pZA
);
684 ok(hr
== S_OK
, "#%d: got 0x%x (expected S_OK)\n", i
, hr
);
687 /* IE8 no longer set cbSize */
688 memset(buffer
, -1, sizeof(buffer
));
690 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
691 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
692 ok((pZA
->cbSize
== 0) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
693 "got cbSize = %d (expected 0)\n", pZA
->cbSize
);
695 memset(buffer
, -1, sizeof(buffer
));
697 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
698 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
699 ok((pZA
->cbSize
== 64) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
700 "got cbSize = %d (expected 64)\n", pZA
->cbSize
);
702 memset(buffer
, -1, sizeof(buffer
));
703 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
704 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
705 ok((pZA
->cbSize
== 0xffffffff) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
706 "got cbSize = 0x%x (expected 0xffffffff)\n", pZA
->cbSize
);
708 /* IE8 no longer fail on invalid zones */
709 memset(buffer
, -1, sizeof(buffer
));
710 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0xdeadbeef, pZA
);
711 ok(hr
== S_OK
|| (hr
== E_FAIL
),
712 "got 0x%x (expected S_OK or E_FAIL)\n", hr
);
714 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, NULL
);
715 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
717 hr
= IInternetZoneManager_Release(zonemgr
);
718 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
721 static void test_InternetSecurityMarshalling(void)
723 IInternetSecurityManager
*secmgr
= NULL
;
728 trace("testing marshalling...\n");
730 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
731 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
735 hres
= IInternetSecurityManager_QueryInterface(secmgr
, &IID_IUnknown
, (void**)&unk
);
736 ok(hres
== S_OK
, "QueryInterface returned: %08x\n", hres
);
738 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
739 ok(hres
== S_OK
, "CreateStreamOnHGlobal returned: %08x\n", hres
);
741 hres
= CoMarshalInterface(stream
, &IID_IInternetSecurityManager
, unk
, MSHCTX_INPROC
, NULL
, MSHLFLAGS_NORMAL
);
742 /* Not supported in W98 */
743 ok(hres
== S_OK
|| broken(hres
== REGDB_E_IIDNOTREG
),
744 "CoMarshalInterface returned: %08x\n", hres
);
746 IStream_Release(stream
);
747 IUnknown_Release(unk
);
748 IInternetSecurityManager_Release(secmgr
);
751 static void test_InternetGetSecurityUrl(void)
753 const WCHAR url5_out
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
754 '.','w','i','n','e','t','e','s','t',0};
755 const WCHAR url7_out
[] = {'f','t','p',':','z','o','n','e','3','.','w','i','n','e','t','e','s','t',0};
757 const WCHAR
*in
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
758 const WCHAR
*out_default
[] = {url2
, url3
, url4
, url5_out
, url7_out
, url8
, url5_out
, url10
};
759 const WCHAR
*out_securl
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
765 trace("testing CoInternetGetSecurityUrl...\n");
767 for(i
=0; i
<sizeof(in
)/sizeof(WCHAR
*); i
++) {
768 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_DEFAULT
, 0);
769 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
771 ok(!strcmp_w(sec
, out_default
[i
]), "(%d) Got %s, expected %s\n",
772 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_default
[i
]));
776 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_SECURITY_URL_ONLY
, 0);
777 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
779 ok(!strcmp_w(sec
, out_securl
[i
]), "(%d) Got %s, expected %s\n",
780 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_securl
[i
]));
785 SET_EXPECT(ParseUrl_SECURITY_URL_input2
);
786 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
787 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
789 hres
= pCoInternetGetSecurityUrl(security_url2W
, &sec
, PSU_DEFAULT
, 0);
790 ok(hres
== S_OK
, "CoInternetGetSecurityUrl returned 0x%08x, expected S_OK\n", hres
);
792 CHECK_CALLED(ParseUrl_SECURITY_URL_input2
);
793 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
794 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
797 static HRESULT WINAPI
InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
*iface
,
798 REFIID riid
, void **ppv
)
800 ok(0, "unexpected call\n");
801 return E_NOINTERFACE
;
804 static ULONG WINAPI
InternetProtocolInfo_AddRef(IInternetProtocolInfo
*iface
)
809 static ULONG WINAPI
InternetProtocolInfo_Release(IInternetProtocolInfo
*iface
)
814 static HRESULT WINAPI
InternetProtocolInfo_ParseUrl(IInternetProtocolInfo
*iface
, LPCWSTR pwzUrl
,
815 PARSEACTION ParseAction
, DWORD dwParseFlags
, LPWSTR pwzResult
, DWORD cchResult
,
816 DWORD
*pcchResult
, DWORD dwReserved
)
818 const WCHAR
*ret
= NULL
;
820 ok(pwzResult
!= NULL
, "pwzResult == NULL\n");
821 ok(pcchResult
!= NULL
, "pcchResult == NULL\n");
822 ok(!dwParseFlags
, "Expected 0, but got 0x%08x\n", dwParseFlags
);
824 switch(ParseAction
) {
825 case PARSE_SECURITY_URL
:
826 if(!strcmp_w(pwzUrl
, security_urlW
)) {
827 CHECK_EXPECT(ParseUrl_SECURITY_URL_input
);
828 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
829 ret
= security_expectedW
;
830 } else if(!strcmp_w(pwzUrl
, security_url2W
)) {
831 CHECK_EXPECT(ParseUrl_SECURITY_URL_input2
);
832 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
833 ret
= security_expectedW
;
834 } else if(!strcmp_w(pwzUrl
, security_expectedW
)) {
835 CHECK_EXPECT(ParseUrl_SECURITY_URL_expected
);
836 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
837 ret
= security_expectedW
;
838 } else if(!strcmp_w(pwzUrl
, winetest_to_httpW
)) {
839 switch(++called_securl_http
) {
841 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
844 CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
845 ok(cchResult
== lstrlenW(url9
)+1, "Got %d\n", cchResult
);
848 todo_wine
CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
852 ok(0, "Unexpected call, pwzUrl=%s\n", wine_dbgstr_w(pwzUrl
));
855 case PARSE_SECURITY_DOMAIN
:
857 CHECK_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
859 ok(!strcmp_w(pwzUrl
, security_expectedW
), "Expected %s but got %s\n",
860 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(pwzUrl
));
861 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
862 ret
= security_expectedW
;
865 ok(0, "Unexpected call, ParseAction=%d pwzUrl=%s\n", ParseAction
,
866 wine_dbgstr_w(pwzUrl
));
872 *pcchResult
= lstrlenW(ret
)+1;
873 if(*pcchResult
> cchResult
)
875 memcpy(pwzResult
, ret
, (*pcchResult
+1)*sizeof(WCHAR
));
879 static HRESULT WINAPI
InternetProtocolInfo_CombineUrl(IInternetProtocolInfo
*iface
,
880 LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
, DWORD dwCombineFlags
,
881 LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
883 ok(0, "unexpected call\n");
887 static HRESULT WINAPI
InternetProtocolInfo_CompareUrl(IInternetProtocolInfo
*iface
,
888 LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
890 ok(0, "unexpected call\n");
894 static HRESULT WINAPI
InternetProtocolInfo_QueryInfo(IInternetProtocolInfo
*iface
,
895 LPCWSTR pwzUrl
, QUERYOPTION OueryOption
, DWORD dwQueryFlags
, LPVOID pBuffer
,
896 DWORD cbBuffer
, DWORD
*pcbBuf
, DWORD dwReserved
)
898 ok(0, "unexpected call\n");
902 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
= {
903 InternetProtocolInfo_QueryInterface
,
904 InternetProtocolInfo_AddRef
,
905 InternetProtocolInfo_Release
,
906 InternetProtocolInfo_ParseUrl
,
907 InternetProtocolInfo_CombineUrl
,
908 InternetProtocolInfo_CompareUrl
,
909 InternetProtocolInfo_QueryInfo
912 static IInternetProtocolInfo protocol_info
= { &InternetProtocolInfoVtbl
};
914 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
916 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
)) {
917 *ppv
= &protocol_info
;
921 ok(0, "unexpected call\n");
922 return E_NOINTERFACE
;
925 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
930 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
935 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
936 REFIID riid
, void **ppv
)
938 ok(0, "unexpected call\n");
942 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
944 ok(0, "unexpected call\n");
948 static const IClassFactoryVtbl ClassFactoryVtbl
= {
949 ClassFactory_QueryInterface
,
951 ClassFactory_Release
,
952 ClassFactory_CreateInstance
,
953 ClassFactory_LockServer
956 static IClassFactory protocol_cf
= { &ClassFactoryVtbl
};
958 static void register_protocols(void)
960 IInternetSession
*session
;
963 hres
= pCoInternetGetSession(0, &session
, 0);
964 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
968 hres
= IInternetSession_RegisterNameSpace(session
, &protocol_cf
, &IID_NULL
,
969 winetestW
, 0, NULL
, 0);
970 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
972 IInternetSession_Release(session
);
975 static void unregister_protocols(void) {
976 IInternetSession
*session
;
979 hr
= pCoInternetGetSession(0, &session
, 0);
980 ok(hr
== S_OK
, "CoInternetGetSession failed: 0x%08x\n", hr
);
984 hr
= IInternetSession_UnregisterNameSpace(session
, &protocol_cf
, winetestW
);
985 ok(hr
== S_OK
, "UnregisterNameSpace failed: 0x%08x\n", hr
);
987 IInternetSession_Release(session
);
990 static const struct {
993 const char *security_uri
;
994 HRESULT security_hres
;
995 const char *default_uri
;
996 HRESULT default_hres
;
998 } sec_url_ex_tests
[] = {
999 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,"*:index.html",S_OK
,"*:index.htm",S_OK
},
1000 {"file://c:\\Index.htm",Uri_CREATE_FILE_USE_DOS_PATH
,"file:///c:/Index.htm",S_OK
,"file:///c:/Index.htm",S_OK
},
1001 {"file:some%20file%2ejpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1002 {"file:some file.jpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1003 {"http://www.zone3.winetest/",0,"http://www.zone3.winetest/",S_OK
,"http://www.zone3.winetest/",S_OK
},
1004 {"about:blank",0,"about:blank",S_OK
,"about:blank",S_OK
},
1005 {"ftp://zone3.winetest/file.test",0,"ftp://zone3.winetest/file.test",S_OK
,"ftp://zone3.winetest/file.test",S_OK
},
1006 {"test:123abc",0,"test:123abc",S_OK
,"test:123abc",S_OK
},
1007 {"http:google.com/test.file",0,"http:google.com/test.file",S_OK
,"http:google.com/test.file",S_OK
},
1008 {"ftp://test@ftp.winehq.org/",0,"ftp://ftp.winehq.org/",S_OK
,"ftp://ftp.winehq.org/",S_OK
},
1009 {"test://google@ftp.winehq.org/",0,"test://google@ftp.winehq.org/",S_OK
,"test://google@ftp.winehq.org/",S_OK
}
1012 static void test_InternetGetSecurityUrlEx(void)
1016 IUri
*uri
= NULL
, *result
= NULL
;
1018 trace("testing CoInternetGetSecurityUrlEx...\n");
1020 hr
= pCoInternetGetSecurityUrlEx(NULL
, NULL
, PSU_DEFAULT
, 0);
1021 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1023 result
= (void*) 0xdeadbeef;
1024 hr
= pCoInternetGetSecurityUrlEx(NULL
, &result
, PSU_DEFAULT
, 0);
1025 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1026 ok(result
== (void*) 0xdeadbeef, "'result' was %p\n", result
);
1028 for(i
= 0; i
< sizeof(sec_url_ex_tests
)/sizeof(sec_url_ex_tests
[0]); ++i
) {
1029 LPWSTR uriW
= a2w(sec_url_ex_tests
[i
].uri
);
1032 hr
= pCreateUri(uriW
, sec_url_ex_tests
[i
].create_flags
, 0, &uri
);
1033 ok(hr
== S_OK
, "CreateUri returned 0x%08x on test %d\n", hr
, i
);
1037 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1038 if(sec_url_ex_tests
[i
].todo
) {
1040 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1041 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1042 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1044 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1045 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1046 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1051 hr
= IUri_GetDisplayUri(result
, &received
);
1052 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1054 if(sec_url_ex_tests
[i
].todo
) {
1056 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1057 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1058 wine_dbgstr_w(received
), i
);
1060 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1061 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1062 wine_dbgstr_w(received
), i
);
1065 SysFreeString(received
);
1067 if(result
) IUri_Release(result
);
1070 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1071 if(sec_url_ex_tests
[i
].todo
) {
1073 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1074 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1075 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1077 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1078 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1079 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1084 hr
= IUri_GetDisplayUri(result
, &received
);
1085 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1087 if(sec_url_ex_tests
[i
].todo
) {
1089 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1090 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1091 wine_dbgstr_w(received
), i
);
1093 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1094 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1095 wine_dbgstr_w(received
), i
);
1098 SysFreeString(received
);
1100 if(result
) IUri_Release(result
);
1103 if(uri
) IUri_Release(uri
);
1108 static void test_InternetGetSecurityUrlEx_Pluggable(void)
1111 IUri
*uri
= NULL
, *result
;
1113 trace("testing CoInternetGetSecurityUrlEx for plugable protocols...\n");
1115 hr
= pCreateUri(security_urlW
, 0, 0, &uri
);
1116 ok(hr
== S_OK
, "CreateUri returned 0x%08x\n", hr
);
1118 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1119 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1120 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1122 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1123 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1125 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1126 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1127 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1130 BSTR received
= NULL
;
1132 hr
= IUri_GetAbsoluteUri(result
, &received
);
1133 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1135 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1136 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1138 SysFreeString(received
);
1140 if(result
) IUri_Release(result
);
1144 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1145 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1147 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1148 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1150 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1151 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1154 BSTR received
= NULL
;
1156 hr
= IUri_GetAbsoluteUri(result
, &received
);
1157 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1159 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1160 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1162 SysFreeString(received
);
1164 if(result
) IUri_Release(result
);
1166 if(uri
) IUri_Release(uri
);
1173 hurlmon
= GetModuleHandle("urlmon.dll");
1174 pCoInternetCreateSecurityManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateSecurityManager");
1175 pCoInternetCreateZoneManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateZoneManager");
1176 pCoInternetGetSecurityUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrl");
1177 pCoInternetGetSecurityUrlEx
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrlEx");
1178 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
1179 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
1181 if (!pCoInternetCreateSecurityManager
|| !pCoInternetCreateZoneManager
||
1182 !pCoInternetGetSecurityUrl
) {
1183 win_skip("Various CoInternet* functions not present in IE 4.0\n");
1187 OleInitialize(NULL
);
1188 register_protocols();
1190 test_InternetGetSecurityUrl();
1192 if(!pCoInternetGetSecurityUrlEx
|| !pCreateUri
)
1193 win_skip("Skipping CoInternetGetSecurityUrlEx tests, IE too old\n");
1195 test_InternetGetSecurityUrlEx();
1196 test_InternetGetSecurityUrlEx_Pluggable();
1199 test_SecurityManager();
1201 test_CoInternetCreateZoneManager();
1202 test_CreateZoneEnumerator();
1203 test_GetZoneActionPolicy();
1205 test_GetZoneAttributes();
1206 test_InternetSecurityMarshalling();
1208 unregister_protocols();