2 * Copyright 2016 Alistair Leslie-Hughes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
31 static void test_policy2_rules(INetFwPolicy2
*policy2
)
34 INetFwRules
*rules
, *rules2
;
35 INetFwServiceRestriction
*restriction
;
37 hr
= INetFwPolicy2_QueryInterface(policy2
, &IID_INetFwRules
, (void**)&rules
);
38 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
40 hr
= INetFwPolicy2_get_Rules(policy2
, &rules
);
41 ok(hr
== S_OK
, "got %08x\n", hr
);
43 hr
= INetFwPolicy2_get_Rules(policy2
, &rules2
);
44 ok(hr
== S_OK
, "got %08x\n", hr
);
45 ok(rules
== rules2
, "Different pointers\n");
47 hr
= INetFwPolicy2_get_ServiceRestriction(policy2
, &restriction
);
48 todo_wine
ok(hr
== S_OK
, "got %08x\n", hr
);
53 hr
= INetFwServiceRestriction_get_Rules(restriction
, &rules3
);
54 ok(hr
== S_OK
, "got %08x\n", hr
);
55 ok(rules
!= rules3
, "same pointers\n");
58 INetFwRules_Release(rules3
);
59 INetFwServiceRestriction_Release(restriction
);
62 INetFwRules_Release(rules
);
63 INetFwRules_Release(rules2
);
66 static void test_interfaces(void)
70 INetFwPolicy2
*policy2
;
73 hr
= CoCreateInstance(&CLSID_NetFwMgr
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
74 &IID_INetFwMgr
, (void**)&manager
);
75 ok(hr
== S_OK
, "NetFwMgr create failed: %08x\n", hr
);
77 hr
= INetFwMgr_QueryInterface(manager
, &IID_INetFwPolicy
, (void**)&policy
);
78 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
80 hr
= INetFwMgr_QueryInterface(manager
, &IID_INetFwPolicy2
, (void**)&policy2
);
81 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
83 hr
= INetFwMgr_get_LocalPolicy(manager
, &policy
);
84 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
86 hr
= INetFwPolicy_QueryInterface(policy
, &IID_INetFwPolicy2
, (void**)&policy2
);
87 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
89 INetFwPolicy_Release(policy
);
91 hr
= CoCreateInstance(&CLSID_NetFwPolicy2
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
92 &IID_INetFwPolicy2
, (void**)&policy2
);
95 test_policy2_rules(policy2
);
97 INetFwPolicy2_Release(policy2
);
100 win_skip("NetFwPolicy2 object is not supported: %08x\n", hr
);
102 INetFwMgr_Release(manager
);
105 static void test_NetFwAuthorizedApplication(void)
107 INetFwAuthorizedApplication
*app
;
108 static WCHAR empty
[] = {0};
109 UNIVERSAL_NAME_INFOW
*info
;
110 WCHAR netpath
[MAX_PATH
];
111 WCHAR image
[MAX_PATH
];
116 hr
= CoCreateInstance(&CLSID_NetFwAuthorizedApplication
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
117 &IID_INetFwAuthorizedApplication
, (void**)&app
);
118 ok(hr
== S_OK
, "got: %08x\n", hr
);
120 hr
= GetModuleFileNameW(NULL
, image
, ARRAY_SIZE(image
));
121 ok(hr
, "GetModuleFileName failed: %u\n", GetLastError());
123 hr
= INetFwAuthorizedApplication_get_ProcessImageFileName(app
, NULL
);
124 ok(hr
== E_POINTER
, "got: %08x\n", hr
);
126 hr
= INetFwAuthorizedApplication_get_ProcessImageFileName(app
, &bstr
);
127 ok(hr
== S_OK
|| hr
== HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
), "got: %08x\n", hr
);
128 ok(!bstr
, "got: %s\n", wine_dbgstr_w(bstr
));
130 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName(app
, NULL
);
131 ok(hr
== E_INVALIDARG
|| hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "got: %08x\n", hr
);
133 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName(app
, empty
);
134 ok(hr
== E_INVALIDARG
|| hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "got: %08x\n", hr
);
136 bstr
= SysAllocString(image
);
137 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName(app
, bstr
);
138 ok(hr
== S_OK
, "got: %08x\n", hr
);
141 info
= (UNIVERSAL_NAME_INFOW
*)&netpath
;
142 sz
= sizeof(netpath
);
143 hr
= WNetGetUniversalNameW(image
, UNIVERSAL_NAME_INFO_LEVEL
, &info
, &sz
);
146 info
->lpUniversalName
= netpath
+ sizeof(*info
)/sizeof(WCHAR
);
147 lstrcpyW(info
->lpUniversalName
, image
);
150 hr
= INetFwAuthorizedApplication_get_ProcessImageFileName(app
, &bstr
);
151 ok(hr
== S_OK
, "got: %08x\n", hr
);
152 ok(!lstrcmpW(bstr
,info
->lpUniversalName
), "expected %s, got %s\n",
153 wine_dbgstr_w(info
->lpUniversalName
), wine_dbgstr_w(bstr
));
156 INetFwAuthorizedApplication_Release(app
);
166 hr
= CoCreateInstance(&CLSID_NetFwMgr
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
167 &IID_INetFwMgr
, (void**)&manager
);
170 win_skip("NetFwMgr object is not supported: %08x\n", hr
);
175 INetFwMgr_Release(manager
);
178 test_NetFwAuthorizedApplication();