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"
32 static void test_policy2_rules(INetFwPolicy2
*policy2
)
35 INetFwRules
*rules
, *rules2
;
36 INetFwServiceRestriction
*restriction
;
38 hr
= INetFwPolicy2_QueryInterface(policy2
, &IID_INetFwRules
, (void**)&rules
);
39 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
41 hr
= INetFwPolicy2_get_Rules(policy2
, &rules
);
42 ok(hr
== S_OK
, "got %08x\n", hr
);
44 hr
= INetFwPolicy2_get_Rules(policy2
, &rules2
);
45 ok(hr
== S_OK
, "got %08x\n", hr
);
46 ok(rules
== rules2
, "Different pointers\n");
48 hr
= INetFwPolicy2_get_ServiceRestriction(policy2
, &restriction
);
49 todo_wine
ok(hr
== S_OK
, "got %08x\n", hr
);
54 hr
= INetFwServiceRestriction_get_Rules(restriction
, &rules3
);
55 ok(hr
== S_OK
, "got %08x\n", hr
);
56 ok(rules
!= rules3
, "same pointers\n");
59 INetFwRules_Release(rules3
);
60 INetFwServiceRestriction_Release(restriction
);
63 hr
= INetFwRules_get__NewEnum(rules
, NULL
);
64 ok(hr
== E_POINTER
, "got %08x\n", hr
);
66 INetFwRules_Release(rules
);
67 INetFwRules_Release(rules2
);
70 static void test_interfaces(void)
74 INetFwPolicy2
*policy2
;
77 hr
= CoCreateInstance(&CLSID_NetFwMgr
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
78 &IID_INetFwMgr
, (void**)&manager
);
79 ok(hr
== S_OK
, "NetFwMgr create failed: %08x\n", hr
);
81 hr
= INetFwMgr_QueryInterface(manager
, &IID_INetFwPolicy
, (void**)&policy
);
82 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
84 hr
= INetFwMgr_QueryInterface(manager
, &IID_INetFwPolicy2
, (void**)&policy2
);
85 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
87 hr
= INetFwMgr_get_LocalPolicy(manager
, &policy
);
88 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
90 hr
= INetFwPolicy_QueryInterface(policy
, &IID_INetFwPolicy2
, (void**)&policy2
);
91 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
93 INetFwPolicy_Release(policy
);
95 hr
= CoCreateInstance(&CLSID_NetFwPolicy2
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
96 &IID_INetFwPolicy2
, (void**)&policy2
);
99 test_policy2_rules(policy2
);
101 INetFwPolicy2_Release(policy2
);
104 win_skip("NetFwPolicy2 object is not supported: %08x\n", hr
);
106 INetFwMgr_Release(manager
);
109 static void test_NetFwAuthorizedApplication(void)
111 INetFwAuthorizedApplication
*app
;
112 static WCHAR empty
[] = L
"";
113 UNIVERSAL_NAME_INFOW
*info
;
114 WCHAR fullpath
[MAX_PATH
];
115 WCHAR netpath
[MAX_PATH
];
116 WCHAR image
[MAX_PATH
];
121 hr
= CoCreateInstance(&CLSID_NetFwAuthorizedApplication
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
122 &IID_INetFwAuthorizedApplication
, (void**)&app
);
123 ok(hr
== S_OK
, "got: %08x\n", hr
);
125 hr
= GetModuleFileNameW(NULL
, image
, ARRAY_SIZE(image
));
126 ok(hr
, "GetModuleFileName failed: %u\n", GetLastError());
128 hr
= INetFwAuthorizedApplication_get_ProcessImageFileName(app
, NULL
);
129 ok(hr
== E_POINTER
, "got: %08x\n", hr
);
131 hr
= INetFwAuthorizedApplication_get_ProcessImageFileName(app
, &bstr
);
132 ok(hr
== S_OK
|| hr
== HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
), "got: %08x\n", hr
);
133 ok(!bstr
, "got: %s\n", wine_dbgstr_w(bstr
));
135 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName(app
, NULL
);
136 ok(hr
== E_INVALIDARG
|| hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "got: %08x\n", hr
);
138 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName(app
, empty
);
139 ok(hr
== E_INVALIDARG
|| hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "got: %08x\n", hr
);
141 bstr
= SysAllocString(image
);
142 hr
= INetFwAuthorizedApplication_put_ProcessImageFileName(app
, bstr
);
143 ok(hr
== S_OK
, "got: %08x\n", hr
);
146 GetFullPathNameW(image
, ARRAY_SIZE(fullpath
), fullpath
, NULL
);
147 GetLongPathNameW(fullpath
, fullpath
, ARRAY_SIZE(fullpath
));
149 info
= (UNIVERSAL_NAME_INFOW
*)&netpath
;
150 sz
= sizeof(netpath
);
151 hr
= WNetGetUniversalNameW(image
, UNIVERSAL_NAME_INFO_LEVEL
, info
, &sz
);
154 info
->lpUniversalName
= netpath
+ sizeof(*info
)/sizeof(WCHAR
);
155 lstrcpyW(info
->lpUniversalName
, fullpath
);
158 hr
= INetFwAuthorizedApplication_get_ProcessImageFileName(app
, &bstr
);
159 ok(hr
== S_OK
, "got: %08x\n", hr
);
160 ok(!lstrcmpW(bstr
,info
->lpUniversalName
), "expected %s, got %s\n",
161 wine_dbgstr_w(info
->lpUniversalName
), wine_dbgstr_w(bstr
));
164 INetFwAuthorizedApplication_Release(app
);
167 static void test_IUPnPNAT(void)
170 IStaticPortMappingCollection
*static_ports
;
171 IDynamicPortMappingCollection
*dync_ports
;
172 INATEventManager
*manager
;
173 IProvideClassInfo
*provider
;
176 hr
= CoCreateInstance(&CLSID_UPnPNAT
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
, &IID_IUPnPNAT
, (void**)&nat
);
177 ok(hr
== S_OK
, "got: %08x\n", hr
);
179 hr
= IUPnPNAT_QueryInterface(nat
, &IID_IProvideClassInfo
, (void**)&provider
);
180 ok(hr
== E_NOINTERFACE
, "got: %08x\n", hr
);
182 hr
= IUPnPNAT_get_StaticPortMappingCollection(nat
, &static_ports
);
183 ok(hr
== S_OK
, "got: %08x\n", hr
);
184 if(hr
== S_OK
&& static_ports
)
185 IStaticPortMappingCollection_Release(static_ports
);
187 hr
= IUPnPNAT_get_DynamicPortMappingCollection(nat
, &dync_ports
);
188 ok(hr
== S_OK
|| hr
== E_NOTIMPL
/* Windows 8.1 */, "got: %08x\n", hr
);
189 if(hr
== S_OK
&& dync_ports
)
190 IDynamicPortMappingCollection_Release(dync_ports
);
192 hr
= IUPnPNAT_get_NATEventManager(nat
, &manager
);
193 todo_wine
ok(hr
== S_OK
, "got: %08x\n", hr
);
194 if(hr
== S_OK
&& manager
)
195 INATEventManager_Release(manager
);
197 IUPnPNAT_Release(nat
);
207 hr
= CoCreateInstance(&CLSID_NetFwMgr
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
208 &IID_INetFwMgr
, (void**)&manager
);
211 win_skip("NetFwMgr object is not supported: %08x\n", hr
);
216 INetFwMgr_Release(manager
);
219 test_NetFwAuthorizedApplication();