Jacek Caban : urlmon: Added more policy tests.
Module: wine Branch: master Commit: 3a736c6677cecf588368c44314390ebff239df72 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3a736c6677cecf588368c44314... Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Mar 14 12:42:27 2008 +0100 urlmon: Added more policy tests. --- dlls/urlmon/tests/misc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 77 insertions(+), 1 deletions(-) diff --git a/dlls/urlmon/tests/misc.c b/dlls/urlmon/tests/misc.c index 40701db..77b00ad 100644 --- a/dlls/urlmon/tests/misc.c +++ b/dlls/urlmon/tests/misc.c @@ -744,7 +744,7 @@ static void test_SecurityManager(void) int i; IInternetSecurityManager *secmgr = NULL; BYTE buf[512]; - DWORD zone, size; + DWORD zone, size, policy; HRESULT hres; hres = CoInternetCreateSecurityManager(NULL, &secmgr, 0); @@ -798,9 +798,84 @@ static void test_SecurityManager(void) ok(hres == E_INVALIDARG, "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres); + hres = IInternetSecurityManager_ProcessUrlAction(secmgr, NULL, URLACTION_SCRIPT_RUN, (BYTE*)&policy, + sizeof(WCHAR), NULL, 0, 0, 0); + ok(hres == E_INVALIDARG, "ProcessUrlAction failed: %08x, expected E_INVALIDARG\n", hres); + IInternetSecurityManager_Release(secmgr); } +static void test_url_action(IInternetSecurityManager *secmgr, IInternetZoneManager *zonemgr, DWORD action) +{ + DWORD res, size, policy, reg_policy; + char buf[10]; + HKEY hkey; + HRESULT hres; + + res = RegOpenKeyA(HKEY_LOCAL_MACHINE, + "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey); + if(res != ERROR_SUCCESS) { + ok(0, "Could not open zone key\n"); + return; + } + + wsprintf(buf, "%X", action); + size = sizeof(DWORD); + res = RegQueryValueExA(hkey, buf, NULL, NULL, (BYTE*)®_policy, &size); + RegCloseKey(hkey); + if(res != ERROR_SUCCESS || size != sizeof(DWORD)) { + policy = 0xdeadbeef; + hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url9, action, (BYTE*)&policy, + sizeof(WCHAR), NULL, 0, 0, 0); + ok(hres == E_FAIL, "ProcessUrlAction(%x) failed: %08x, expected E_FAIL\n", action, hres); + ok(policy == 0xdeadbeef, "(%x) policy=%x\n", action, policy); + + policy = 0xdeadbeef; + hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, action, (BYTE*)&policy, + sizeof(DWORD), URLZONEREG_DEFAULT); + ok(hres == E_FAIL, "GetZoneActionPolicy failed: %08x, expected E_FAIL\n", hres); + ok(policy == 0xdeadbeef, "(%x) policy=%x\n", action, policy); + return; + } + + policy = 0xdeadbeef; + hres = IInternetZoneManager_GetZoneActionPolicy(zonemgr, 3, action, (BYTE*)&policy, + sizeof(DWORD), URLZONEREG_DEFAULT); + ok(hres == S_OK, "GetZoneActionPolicy failed: %08x\n", hres); + ok(policy == reg_policy, "(%x) policy=%x, expected %x\n", action, policy, reg_policy); + + if(policy != URLPOLICY_QUERY) { + policy = 0xdeadbeef; + hres = IInternetSecurityManager_ProcessUrlAction(secmgr, url9, action, (BYTE*)&policy, + sizeof(WCHAR), NULL, 0, 0, 0); + if(reg_policy == URLPOLICY_DISALLOW) + ok(hres == S_FALSE, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action, hres); + else + ok(hres == S_OK, "ProcessUrlAction(%x) failed: %08x\n", action, hres); + ok(policy == 0xdeadbeef, "(%x) policy=%x\n", action, policy); + } +} + +static void test_polices(void) +{ + IInternetZoneManager *zonemgr = NULL; + IInternetSecurityManager *secmgr = NULL; + HRESULT hres; + + hres = CoInternetCreateSecurityManager(NULL, &secmgr, 0); + ok(hres == S_OK, "CoInternetCreateSecurityManager failed: %08x\n", hres); + hres = CoInternetCreateZoneManager(NULL, &zonemgr, 0); + ok(hres == S_OK, "CoInternetCreateZoneManager failed: %08x\n", hres); + + test_url_action(secmgr, zonemgr, URLACTION_SCRIPT_RUN); + test_url_action(secmgr, zonemgr, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY); + test_url_action(secmgr, zonemgr, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS); + test_url_action(secmgr, zonemgr, 0xdeadbeef); + + IInternetSecurityManager_Release(secmgr); + IInternetZoneManager_Release(zonemgr); +} + static void test_ZoneManager(void) { IInternetZoneManager *zonemgr = NULL; @@ -1392,6 +1467,7 @@ START_TEST(misc) test_CoInternetQueryInfo(); test_FindMimeFromData(); test_SecurityManager(); + test_polices(); test_ZoneManager(); test_NameSpace(); test_MimeFilter();
participants (1)
-
Alexandre Julliard