widl: Use for_each_iface in get_size_procformatstring.
[wine.git] / dlls / webservices / tests / channel.c
blob6a45671057d5c792012d7f8037fba67d45898db4
1 /*
2 * Copyright 2016 Hans Leidekker for CodeWeavers
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
19 #include <stdio.h>
20 #define COBJMACROS
21 #include "windows.h"
22 #include "webservices.h"
23 #include "initguid.h"
24 #include "netfw.h"
25 #include "wine/test.h"
27 static void test_WsCreateChannel(void)
29 HRESULT hr;
30 WS_CHANNEL *channel;
31 WS_CHANNEL_STATE state;
32 WS_CHANNEL_PROPERTY prop;
33 WS_ENCODING encoding;
34 WS_ENVELOPE_VERSION env_version;
35 WS_ADDRESSING_VERSION addr_version;
36 ULONG size;
38 hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, NULL, NULL );
39 ok( hr == E_INVALIDARG, "got %08x\n", hr );
41 channel = NULL;
42 hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
43 ok( hr == S_OK, "got %08x\n", hr );
44 ok( channel != NULL, "channel not set\n" );
46 size = 0xdeadbeef;
47 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_MAX_BUFFERED_MESSAGE_SIZE, &size, sizeof(size), NULL );
48 ok( hr == S_OK, "got %08x\n", hr );
49 ok( size == 65536, "got %u\n", size );
51 encoding = 0xdeadbeef;
52 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_ENCODING, &encoding, sizeof(encoding), NULL );
53 ok( hr == S_OK, "got %08x\n", hr );
54 ok( encoding == WS_ENCODING_XML_UTF8, "got %u\n", encoding );
56 env_version = 0xdeadbeef;
57 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_ENVELOPE_VERSION, &env_version, sizeof(env_version),
58 NULL );
59 ok( hr == S_OK, "got %08x\n", hr );
60 ok( env_version == WS_ENVELOPE_VERSION_SOAP_1_2, "got %u\n", env_version );
62 addr_version = 0xdeadbeef;
63 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_ADDRESSING_VERSION, &addr_version, sizeof(addr_version),
64 NULL );
65 ok( hr == S_OK, "got %08x\n", hr );
66 ok( addr_version == WS_ADDRESSING_VERSION_1_0, "got %u\n", addr_version );
68 /* read-only property */
69 state = 0xdeadbeef;
70 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_STATE, &state, sizeof(state), NULL );
71 ok( hr == S_OK, "got %08x\n", hr );
72 ok( state == WS_CHANNEL_STATE_CREATED, "got %u\n", state );
74 state = WS_CHANNEL_STATE_CREATED;
75 hr = WsSetChannelProperty( channel, WS_CHANNEL_PROPERTY_STATE, &state, sizeof(state), NULL );
76 ok( hr == E_INVALIDARG, "got %08x\n", hr );
78 encoding = WS_ENCODING_XML_UTF8;
79 hr = WsSetChannelProperty( channel, WS_CHANNEL_PROPERTY_ENCODING, &encoding, sizeof(encoding), NULL );
80 ok( hr == E_INVALIDARG, "got %08x\n", hr );
81 WsFreeChannel( channel );
83 encoding = WS_ENCODING_XML_UTF16LE;
84 prop.id = WS_CHANNEL_PROPERTY_ENCODING;
85 prop.value = &encoding;
86 prop.valueSize = sizeof(encoding);
87 hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, &prop, 1, NULL, &channel, NULL );
88 ok( hr == S_OK, "got %08x\n", hr );
89 encoding = 0xdeadbeef;
90 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_ENCODING, &encoding, sizeof(encoding), NULL );
91 ok( hr == S_OK, "got %08x\n", hr );
92 ok( encoding == WS_ENCODING_XML_UTF16LE, "got %u\n", encoding );
93 WsFreeChannel( channel );
95 hr = WsCreateChannel( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
96 ok( hr == S_OK, "got %08x\n", hr );
97 encoding = 0xdeadbeef;
98 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_ENCODING, &encoding, sizeof(encoding), NULL );
99 ok( hr == S_OK, "got %08x\n", hr );
100 ok( encoding == WS_ENCODING_XML_BINARY_SESSION_1, "got %u\n", encoding );
102 env_version = 0xdeadbeef;
103 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_ENVELOPE_VERSION, &env_version, sizeof(env_version),
104 NULL );
105 ok( hr == S_OK, "got %08x\n", hr );
106 ok( env_version == WS_ENVELOPE_VERSION_SOAP_1_2, "got %u\n", env_version );
108 addr_version = 0xdeadbeef;
109 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_ADDRESSING_VERSION, &addr_version, sizeof(addr_version),
110 NULL );
111 ok( hr == S_OK, "got %08x\n", hr );
112 ok( addr_version == WS_ADDRESSING_VERSION_1_0, "got %u\n", addr_version );
113 WsFreeChannel( channel );
116 static void test_WsOpenChannel(void)
118 WCHAR url[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t'};
119 HRESULT hr;
120 WS_CHANNEL *channel;
121 WS_ENDPOINT_ADDRESS addr;
123 hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
124 ok( hr == S_OK, "got %08x\n", hr );
126 hr = WsCloseChannel( channel, NULL, NULL );
127 ok( hr == S_OK, "got %08x\n", hr );
128 WsFreeChannel( channel );
130 hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
131 ok( hr == S_OK, "got %08x\n", hr );
133 hr = WsOpenChannel( channel, NULL, NULL, NULL );
134 ok( hr == E_INVALIDARG, "got %08x\n", hr );
136 memset( &addr, 0, sizeof(addr) );
137 addr.url.length = ARRAY_SIZE( url );
138 addr.url.chars = url;
139 hr = WsOpenChannel( NULL, &addr, NULL, NULL );
140 ok( hr == E_INVALIDARG, "got %08x\n", hr );
142 hr = WsOpenChannel( channel, &addr, NULL, NULL );
143 ok( hr == S_OK, "got %08x\n", hr );
145 hr = WsOpenChannel( channel, &addr, NULL, NULL );
146 ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
148 hr = WsCloseChannel( channel, NULL, NULL );
149 ok( hr == S_OK, "got %08x\n", hr );
151 hr = WsCloseChannel( channel, NULL, NULL );
152 ok( hr == S_OK, "got %08x\n", hr );
154 hr = WsCloseChannel( NULL, NULL, NULL );
155 ok( hr == E_INVALIDARG, "got %08x\n", hr );
157 WsFreeChannel( channel );
160 static void test_WsResetChannel(void)
162 WCHAR url[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t'};
163 HRESULT hr;
164 WS_CHANNEL *channel;
165 WS_CHANNEL_STATE state;
166 WS_CHANNEL_TYPE type;
167 WS_ENDPOINT_ADDRESS addr;
168 ULONG size, timeout;
170 hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
171 ok( hr == S_OK, "got %08x\n", hr );
173 hr = WsResetChannel( channel, NULL );
174 ok( hr == S_OK, "got %08x\n", hr );
176 timeout = 5000;
177 size = sizeof(timeout);
178 hr = WsSetChannelProperty( channel, WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT, &timeout, size, NULL );
179 ok( hr == S_OK, "got %08x\n", hr );
181 memset( &addr, 0, sizeof(addr) );
182 addr.url.length = ARRAY_SIZE( url );
183 addr.url.chars = url;
184 hr = WsOpenChannel( channel, &addr, NULL, NULL );
185 ok( hr == S_OK, "got %08x\n", hr );
187 hr = WsResetChannel( channel, NULL );
188 ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
190 hr = WsCloseChannel( channel, NULL, NULL );
191 ok( hr == S_OK, "got %08x\n", hr );
193 hr = WsResetChannel( channel, NULL );
194 ok( hr == S_OK, "got %08x\n", hr );
196 state = 0xdeadbeef;
197 size = sizeof(state);
198 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_STATE, &state, size, NULL );
199 ok( hr == S_OK, "got %08x\n", hr );
200 ok( state == WS_CHANNEL_STATE_CREATED, "got %u\n", state );
202 type = 0xdeadbeef;
203 size = sizeof(type);
204 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_CHANNEL_TYPE, &type, size, NULL );
205 ok( hr == S_OK, "got %08x\n", hr );
206 ok( type == WS_CHANNEL_TYPE_REQUEST, "got %u\n", type );
208 timeout = 0xdeadbeef;
209 size = sizeof(timeout);
210 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT, &timeout, size, NULL );
211 ok( hr == S_OK, "got %08x\n", hr );
212 ok( timeout == 5000, "got %u\n", timeout );
214 WsFreeChannel( channel );
217 static void test_WsCreateListener(void)
219 HRESULT hr;
220 WS_LISTENER *listener;
221 WS_CHANNEL_TYPE type;
222 WS_CHANNEL_BINDING binding;
223 WS_LISTENER_STATE state;
224 WS_IP_VERSION version;
225 ULONG size, backlog;
227 hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, NULL, NULL );
228 ok( hr == E_INVALIDARG, "got %08x\n", hr );
230 listener = NULL;
231 hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
232 ok( hr == S_OK, "got %08x\n", hr );
233 ok( listener != NULL, "listener not set\n" );
235 backlog = 1000;
236 size = sizeof(backlog);
237 hr = WsSetListenerProperty( listener, WS_LISTENER_PROPERTY_LISTEN_BACKLOG, &backlog, size, NULL );
238 todo_wine ok( hr == E_INVALIDARG, "got %08x\n", hr );
240 version = WS_IP_VERSION_4;
241 size = sizeof(version);
242 hr = WsSetListenerProperty( listener, WS_LISTENER_PROPERTY_IP_VERSION, &version, size, NULL );
243 todo_wine ok( hr == E_INVALIDARG, "got %08x\n", hr );
245 type = 0xdeadbeef;
246 hr = WsGetListenerProperty( listener, WS_LISTENER_PROPERTY_CHANNEL_TYPE, &type, sizeof(type), NULL );
247 ok( hr == S_OK, "got %08x\n", hr );
248 ok( type == WS_CHANNEL_TYPE_DUPLEX_SESSION, "got %u\n", type );
250 binding = 0xdeadbeef;
251 hr = WsGetListenerProperty( listener, WS_LISTENER_PROPERTY_CHANNEL_BINDING, &binding, sizeof(binding), NULL );
252 ok( hr == S_OK, "got %08x\n", hr );
253 ok( binding == WS_TCP_CHANNEL_BINDING, "got %u\n", binding );
255 version = 0;
256 size = sizeof(version);
257 hr = WsGetListenerProperty( listener, WS_LISTENER_PROPERTY_IP_VERSION, &version, size, NULL );
258 ok( hr == S_OK, "got %08x\n", hr );
259 todo_wine ok( version == WS_IP_VERSION_AUTO, "got %u\n", version );
261 state = 0xdeadbeef;
262 size = sizeof(state);
263 hr = WsGetListenerProperty( listener, WS_LISTENER_PROPERTY_STATE, &state, size, NULL );
264 ok( hr == S_OK, "got %08x\n", hr );
265 ok( state == WS_LISTENER_STATE_CREATED, "got %u\n", state );
267 state = WS_LISTENER_STATE_CREATED;
268 size = sizeof(state);
269 hr = WsSetListenerProperty( listener, WS_LISTENER_PROPERTY_STATE, &state, size, NULL );
270 ok( hr == E_INVALIDARG, "got %08x\n", hr );
272 WsFreeListener( listener );
275 static void test_WsOpenListener(void)
277 WCHAR str[] =
278 {'n','e','t','.','t','c','p',':','/','/','+',':','2','0','1','7','/','p','a','t','h'};
279 WCHAR str2[] =
280 {'n','e','t','.','t','c','p',':','/','/','l','o','c','a','l','h','o','s','t',':','2','0','1','7'};
281 WCHAR str3[] =
282 {'n','e','t','.','t','c','p',':','/','/','1','2','7','.','0','.','0','.','1',':','2','0','1','7'};
283 WS_STRING url;
284 WS_LISTENER *listener;
285 HRESULT hr;
287 hr = WsOpenListener( NULL, NULL, NULL, NULL );
288 ok( hr == E_INVALIDARG, "got %08x\n", hr );
290 hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
291 ok( hr == S_OK, "got %08x\n", hr );
293 hr = WsCloseListener( listener, NULL, NULL );
294 ok( hr == S_OK, "got %08x\n", hr );
296 WsFreeListener( listener );
298 hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
299 ok( hr == S_OK, "got %08x\n", hr );
301 hr = WsOpenListener( listener, NULL, NULL, NULL );
302 ok( hr == E_INVALIDARG, "got %08x\n", hr );
304 url.length = ARRAY_SIZE( str );
305 url.chars = str;
306 hr = WsOpenListener( NULL, &url, NULL, NULL );
307 ok( hr == E_INVALIDARG, "got %08x\n", hr );
309 hr = WsOpenListener( listener, &url, NULL, NULL );
310 ok( hr == S_OK, "got %08x\n", hr );
312 hr = WsOpenListener( listener, &url, NULL, NULL );
313 ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
315 hr = WsCloseListener( listener, NULL, NULL );
316 ok( hr == S_OK, "got %08x\n", hr );
318 WsFreeListener( listener );
320 hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
321 ok( hr == S_OK, "got %08x\n", hr );
323 url.length = ARRAY_SIZE( str2 );
324 url.chars = str2;
325 hr = WsOpenListener( listener, &url, NULL, NULL );
326 ok( hr == S_OK, "got %08x\n", hr );
328 hr = WsCloseListener( listener, NULL, NULL );
329 ok( hr == S_OK, "got %08x\n", hr );
331 WsFreeListener( listener );
333 hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
334 ok( hr == S_OK, "got %08x\n", hr );
336 url.length = ARRAY_SIZE( str3 );
337 url.chars = str3;
338 hr = WsOpenListener( listener, &url, NULL, NULL );
339 ok( hr == S_OK, "got %08x\n", hr );
341 hr = WsCloseListener( listener, NULL, NULL );
342 ok( hr == S_OK, "got %08x\n", hr );
344 hr = WsCloseListener( NULL, NULL, NULL );
345 ok( hr == E_INVALIDARG, "got %08x\n", hr );
347 WsFreeListener( listener );
350 static void test_WsCreateChannelForListener(void)
352 WS_LISTENER *listener;
353 WS_CHANNEL *channel;
354 WS_CHANNEL_TYPE type;
355 WS_CHANNEL_STATE state;
356 HRESULT hr;
358 hr = WsCreateChannelForListener( NULL, NULL, 0, NULL, NULL );
359 ok( hr == E_INVALIDARG, "got %08x\n", hr );
361 hr = WsCreateChannelForListener( NULL, NULL, 0, &channel, NULL );
362 ok( hr == E_INVALIDARG, "got %08x\n", hr );
364 hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
365 ok( hr == S_OK, "got %08x\n", hr );
367 channel = NULL;
368 hr = WsCreateChannelForListener( listener, NULL, 0, &channel, NULL );
369 ok( hr == S_OK, "got %08x\n", hr );
370 ok( channel != NULL, "channel not set\n" );
372 type = 0xdeadbeef;
373 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_CHANNEL_TYPE, &type, sizeof(type), NULL );
374 ok( hr == S_OK, "got %08x\n", hr );
375 ok( type == WS_CHANNEL_TYPE_DUPLEX_SESSION, "got %u\n", type );
377 state = 0xdeadbeef;
378 hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_STATE, &state, sizeof(state), NULL );
379 ok( hr == S_OK, "got %08x\n", hr );
380 ok( state == WS_CHANNEL_STATE_CREATED, "got %u\n", state );
382 WsFreeChannel( channel );
383 WsFreeListener( listener );
386 static void test_WsResetListener(void)
388 WCHAR str[] =
389 {'n','e','t','.','t','c','p',':','/','/','+',':','2','0','1','7','/','p','a','t','h'};
390 WS_STRING url = { ARRAY_SIZE( str ), str };
391 WS_LISTENER *listener;
392 WS_LISTENER_STATE state;
393 WS_LISTENER_PROPERTY prop;
394 ULONG size, timeout = 1000;
395 HRESULT hr;
397 hr = WsResetListener( NULL, NULL );
398 ok( hr == E_INVALIDARG, "got %08x\n", hr );
400 prop.id = WS_LISTENER_PROPERTY_CONNECT_TIMEOUT;
401 prop.value = &timeout;
402 prop.valueSize = sizeof(timeout);
403 hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, &prop, 1, NULL, &listener, NULL );
404 ok( hr == S_OK, "got %08x\n", hr );
406 hr = WsResetListener( listener, NULL );
407 ok( hr == S_OK, "got %08x\n", hr );
409 hr = WsOpenListener( listener, &url, NULL, NULL );
410 ok( hr == S_OK, "got %08x\n", hr );
412 hr = WsResetListener( listener, NULL );
413 ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
415 hr = WsCloseListener( listener, NULL, NULL );
416 ok( hr == S_OK, "got %08x\n", hr );
418 hr = WsResetListener( listener, NULL );
419 ok( hr == S_OK, "got %08x\n", hr );
421 state = 0xdeadbeef;
422 size = sizeof(state);
423 hr = WsGetListenerProperty( listener, WS_LISTENER_PROPERTY_STATE, &state, size, NULL );
424 ok( hr == S_OK, "got %08x\n", hr );
425 ok( state == WS_LISTENER_STATE_CREATED, "got %u\n", state );
427 timeout = 0xdeadbeef;
428 size = sizeof(timeout);
429 hr = WsGetListenerProperty( listener, WS_LISTENER_PROPERTY_CONNECT_TIMEOUT, &timeout, size, NULL );
430 ok( hr == S_OK, "got %08x\n", hr );
431 ok( timeout == 1000, "got %u\n", timeout );
433 WsFreeListener( listener );
436 static const WCHAR fmt_soap_udp[] =
437 {'s','o','a','p','.','u','d','p',':','/','/','l','o','c','a','l','h','o','s','t',':','%','u',0};
438 static const WCHAR fmt_net_tcp[] =
439 {'n','e','t','.','t','c','p',':','/','/','l','o','c','a','l','h','o','s','t',':','%','u',0};
441 struct listener_info
443 int port;
444 HANDLE wait;
445 WS_CHANNEL_BINDING binding;
446 WS_CHANNEL_TYPE type;
447 void (*server_func)( WS_CHANNEL * );
450 static void server_message_read_write( WS_CHANNEL *channel )
452 WS_MESSAGE *msg;
453 HRESULT hr;
455 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
456 ok( hr == S_OK, "got %08x\n", hr );
458 hr = WsReadMessageStart( NULL, NULL, NULL, NULL );
459 ok( hr == E_INVALIDARG, "got %08x\n", hr );
461 hr = WsReadMessageStart( channel, NULL, NULL, NULL );
462 ok( hr == E_INVALIDARG, "got %08x\n", hr );
464 hr = WsReadMessageStart( NULL, msg, NULL, NULL );
465 ok( hr == E_INVALIDARG, "got %08x\n", hr );
467 hr = WsReadMessageStart( channel, msg, NULL, NULL );
468 ok( hr == S_OK, "got %08x\n", hr );
470 hr = WsReadMessageEnd( NULL, NULL, NULL, NULL );
471 ok( hr == E_INVALIDARG, "got %08x\n", hr );
473 hr = WsReadMessageEnd( channel, NULL, NULL, NULL );
474 ok( hr == E_INVALIDARG, "got %08x\n", hr );
476 hr = WsReadMessageEnd( NULL, msg, NULL, NULL );
477 ok( hr == E_INVALIDARG, "got %08x\n", hr );
479 hr = WsReadMessageEnd( channel, msg, NULL, NULL );
480 ok( hr == S_OK, "got %08x\n", hr );
481 WsFreeMessage( msg );
484 static void client_message_read_write( const struct listener_info *info )
486 WS_ENDPOINT_ADDRESS addr;
487 WCHAR buf[64];
488 WS_CHANNEL *channel;
489 WS_MESSAGE *msg;
490 HRESULT hr;
491 DWORD err;
493 hr = WsCreateChannel( info->type, info->binding, NULL, 0, NULL, &channel, NULL );
494 ok( hr == S_OK, "got %08x\n", hr );
496 memset( &addr, 0, sizeof(addr) );
497 addr.url.length = wsprintfW( buf, fmt_soap_udp, info->port );
498 addr.url.chars = buf;
499 hr = WsOpenChannel( channel, &addr, NULL, NULL );
500 ok( hr == S_OK, "got %08x\n", hr );
502 hr = WsShutdownSessionChannel( channel, NULL, NULL );
503 ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
505 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
506 ok( hr == S_OK, "got %08x\n", hr );
508 hr = WsInitializeMessage( msg, WS_REQUEST_MESSAGE, NULL, NULL );
509 ok( hr == S_OK, "got %08x\n", hr );
511 hr = WsWriteMessageStart( NULL, NULL, NULL, NULL );
512 ok( hr == E_INVALIDARG, "got %08x\n", hr );
514 hr = WsWriteMessageStart( channel, NULL, NULL, NULL );
515 ok( hr == E_INVALIDARG, "got %08x\n", hr );
517 hr = WsWriteMessageStart( NULL, msg, NULL, NULL );
518 ok( hr == E_INVALIDARG, "got %08x\n", hr );
520 hr = WsWriteMessageStart( channel, msg, NULL, NULL );
521 ok( hr == S_OK, "got %08x\n", hr );
523 hr = WsWriteMessageEnd( NULL, NULL, NULL, NULL );
524 ok( hr == E_INVALIDARG, "got %08x\n", hr );
526 hr = WsWriteMessageEnd( channel, NULL, NULL, NULL );
527 ok( hr == E_INVALIDARG, "got %08x\n", hr );
529 hr = WsWriteMessageEnd( NULL, msg, NULL, NULL );
530 ok( hr == E_INVALIDARG, "got %08x\n", hr );
532 hr = WsWriteMessageEnd( channel, msg, NULL, NULL );
533 ok( hr == S_OK, "got %08x\n", hr );
535 err = WaitForSingleObject( info->wait, 3000 );
536 ok( err == WAIT_OBJECT_0, "wait failed %u\n", err );
538 hr = WsCloseChannel( channel, NULL, NULL );
539 ok( hr == S_OK, "got %08x\n", hr );
541 WsFreeMessage( msg );
542 WsFreeChannel( channel );
545 struct async_test
547 ULONG call_count;
548 HANDLE wait;
551 static void CALLBACK async_callback( HRESULT hr, WS_CALLBACK_MODEL model, void *state )
553 struct async_test *test = state;
555 ok( hr == S_OK, "got %08x\n", hr );
556 ok( model == WS_LONG_CALLBACK, "got %u\n", model );
557 test->call_count++;
558 SetEvent( test->wait );
561 static void server_duplex_session( WS_CHANNEL *channel )
563 WS_XML_STRING action = {6, (BYTE *)"action"}, localname = {9, (BYTE *)"localname"}, ns = {2, (BYTE *)"ns"};
564 WS_ELEMENT_DESCRIPTION desc_body;
565 const WS_MESSAGE_DESCRIPTION *desc[1];
566 WS_MESSAGE_DESCRIPTION desc_msg;
567 struct async_test test;
568 WS_ASYNC_CONTEXT ctx;
569 WS_MESSAGE *msg, *msg2;
570 INT32 val = 0;
571 HRESULT hr;
573 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
574 ok( hr == S_OK, "got %08x\n", hr );
576 desc_body.elementLocalName = &localname;
577 desc_body.elementNs = &ns;
578 desc_body.type = WS_INT32_TYPE;
579 desc_body.typeDescription = NULL;
580 desc_msg.action = &action;
581 desc_msg.bodyElementDescription = &desc_body;
582 desc[0] = &desc_msg;
584 test.call_count = 0;
585 test.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
586 ctx.callback = async_callback;
587 ctx.callbackState = &test;
589 hr = WsReceiveMessage( channel, msg, desc, 1, WS_RECEIVE_OPTIONAL_MESSAGE, WS_READ_REQUIRED_VALUE,
590 NULL, &val, sizeof(val), NULL, &ctx, NULL );
591 ok( hr == WS_S_ASYNC || hr == S_OK, "got %08x\n", hr );
592 if (hr == WS_S_ASYNC)
594 WaitForSingleObject( test.wait, INFINITE );
595 ok( test.call_count == 1, "got %u\n", test.call_count );
597 else ok( !test.call_count, "got %u\n", test.call_count );
599 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg2, NULL );
600 ok( hr == S_OK, "got %08x\n", hr );
602 test.call_count = 0;
603 hr = WsReceiveMessage( channel, msg2, desc, 1, WS_RECEIVE_OPTIONAL_MESSAGE, WS_READ_REQUIRED_VALUE,
604 NULL, &val, sizeof(val), NULL, &ctx, NULL );
605 ok( hr == WS_S_ASYNC || hr == S_OK, "got %08x\n", hr );
606 if (hr == WS_S_ASYNC)
608 WaitForSingleObject( test.wait, INFINITE );
609 ok( test.call_count == 1, "got %u\n", test.call_count );
611 else ok( !test.call_count, "got %u\n", test.call_count );
613 CloseHandle( test.wait );
614 WsFreeMessage( msg );
615 WsFreeMessage( msg2 );
618 static void client_duplex_session( const struct listener_info *info )
620 WS_XML_STRING action = {6, (BYTE *)"action"}, localname = {9, (BYTE *)"localname"}, ns = {2, (BYTE *)"ns"};
621 WS_ELEMENT_DESCRIPTION desc_body;
622 WS_MESSAGE_DESCRIPTION desc;
623 WS_ENDPOINT_ADDRESS addr;
624 WCHAR buf[64];
625 WS_CHANNEL *channel;
626 WS_MESSAGE *msg, *msg2;
627 INT32 val = -1;
628 HRESULT hr;
629 DWORD err;
631 hr = WsCreateChannel( info->type, info->binding, NULL, 0, NULL, &channel, NULL );
632 ok( hr == S_OK, "got %08x\n", hr );
634 hr = WsShutdownSessionChannel( channel, NULL, NULL );
635 ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
637 memset( &addr, 0, sizeof(addr) );
638 addr.url.length = wsprintfW( buf, fmt_net_tcp, info->port );
639 addr.url.chars = buf;
640 hr = WsOpenChannel( channel, &addr, NULL, NULL );
641 ok( hr == S_OK, "got %08x\n", hr );
643 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
644 ok( hr == S_OK, "got %08x\n", hr );
646 desc_body.elementLocalName = &localname;
647 desc_body.elementNs = &ns;
648 desc_body.type = WS_INT32_TYPE;
649 desc_body.typeDescription = NULL;
650 desc.action = &action;
651 desc.bodyElementDescription = &desc_body;
653 hr = WsSendMessage( channel, msg, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
654 ok( hr == S_OK, "got %08x\n", hr );
656 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg2, NULL );
657 ok( hr == S_OK, "got %08x\n", hr );
659 hr = WsSendMessage( channel, msg2, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
660 ok( hr == S_OK, "got %08x\n", hr );
662 err = WaitForSingleObject( info->wait, 3000 );
663 ok( err == WAIT_OBJECT_0, "wait failed %u\n", err );
665 hr = WsShutdownSessionChannel( channel, NULL, NULL );
666 ok( hr == S_OK, "got %08x\n", hr );
668 hr = WsShutdownSessionChannel( channel, NULL, NULL );
669 ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
671 hr = WsCloseChannel( channel, NULL, NULL );
672 ok( hr == S_OK, "got %08x\n", hr );
674 WsFreeMessage( msg );
675 WsFreeMessage( msg2 );
676 WsFreeChannel( channel );
679 static void server_accept_channel( WS_CHANNEL *channel )
681 WS_XML_STRING localname = {9, (BYTE *)"localname"}, ns = {2, (BYTE *)"ns"}, action = {6, (BYTE *)"action"};
682 WS_ELEMENT_DESCRIPTION body;
683 WS_MESSAGE_DESCRIPTION desc_resp;
684 const WS_MESSAGE_DESCRIPTION *desc[1];
685 WS_MESSAGE *msg;
686 INT32 val = 0;
687 HRESULT hr;
689 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
690 ok( hr == S_OK, "got %08x\n", hr );
692 body.elementLocalName = &localname;
693 body.elementNs = &ns;
694 body.type = WS_INT32_TYPE;
695 body.typeDescription = NULL;
697 desc_resp.action = &action;
698 desc_resp.bodyElementDescription = &body;
699 desc[0] = &desc_resp;
701 hr = WsReceiveMessage( channel, msg, desc, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE,
702 NULL, &val, sizeof(val), NULL, NULL, NULL );
703 ok( hr == S_OK, "got %08x\n", hr );
704 ok( val == -1, "got %d\n", val );
705 WsFreeMessage( msg );
708 static void client_accept_channel( const struct listener_info *info )
710 const WCHAR *fmt = (info->binding == WS_TCP_CHANNEL_BINDING) ? fmt_net_tcp : fmt_soap_udp;
711 WS_XML_STRING localname = {9, (BYTE *)"localname"}, ns = {2, (BYTE *)"ns"}, action = {6, (BYTE *)"action"};
712 WCHAR buf[64];
713 WS_LISTENER *listener;
714 WS_CHANNEL *channel;
715 WS_MESSAGE *msg;
716 WS_ENDPOINT_ADDRESS addr;
717 WS_ELEMENT_DESCRIPTION body;
718 WS_MESSAGE_DESCRIPTION desc;
719 INT32 val = -1;
720 HRESULT hr;
721 DWORD err;
723 hr = WsAcceptChannel( NULL, NULL, NULL, NULL );
724 ok( hr == E_INVALIDARG, "got %08x\n", hr );
726 hr = WsCreateListener( info->type, info->binding, NULL, 0, NULL, &listener, NULL );
727 ok( hr == S_OK, "got %08x\n", hr );
729 hr = WsAcceptChannel( listener, NULL, NULL, NULL );
730 ok( hr == E_INVALIDARG, "got %08x\n", hr );
732 hr = WsCreateChannelForListener( listener, NULL, 0, &channel, NULL );
733 ok( hr == S_OK, "got %08x\n", hr );
735 hr = WsAcceptChannel( listener, channel, NULL, NULL );
736 ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
737 WsFreeChannel( channel );
738 WsFreeListener( listener );
740 hr = WsCreateChannel( info->type, info->binding, NULL, 0, NULL, &channel, NULL );
741 ok( hr == S_OK, "got %08x\n", hr );
743 memset( &addr, 0, sizeof(addr) );
744 addr.url.length = wsprintfW( buf, fmt, info->port );
745 addr.url.chars = buf;
746 hr = WsOpenChannel( channel, &addr, NULL, NULL );
747 ok( hr == S_OK, "got %08x\n", hr );
749 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
750 ok( hr == S_OK, "got %08x\n", hr );
752 body.elementLocalName = &localname;
753 body.elementNs = &ns;
754 body.type = WS_INT32_TYPE;
755 body.typeDescription = NULL;
757 desc.action = &action;
758 desc.bodyElementDescription = &body;
760 hr = WsSendMessage( channel, msg, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
761 ok( hr == S_OK, "got %08x\n", hr );
763 err = WaitForSingleObject( info->wait, 3000 );
764 ok( err == WAIT_OBJECT_0, "wait failed %u\n", err );
766 hr = WsCloseChannel( channel, NULL, NULL );
767 ok( hr == S_OK, "got %08x\n", hr );
769 WsFreeMessage( msg );
770 WsFreeChannel( channel );
773 static void server_request_reply( WS_CHANNEL *channel )
775 WS_XML_STRING localname = {9, (BYTE *)"localname"}, ns = {2, (BYTE *)"ns"};
776 WS_XML_STRING req_action = {7, (BYTE *)"request"}, reply_action= {5, (BYTE *)"reply"};
777 WS_ELEMENT_DESCRIPTION body;
778 WS_MESSAGE_DESCRIPTION in_desc, out_desc;
779 const WS_MESSAGE_DESCRIPTION *desc[1];
780 WS_MESSAGE *msg;
781 INT32 val = 0;
782 HRESULT hr;
784 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
785 ok( hr == S_OK, "got %08x\n", hr );
787 body.elementLocalName = &localname;
788 body.elementNs = &ns;
789 body.type = WS_INT32_TYPE;
790 body.typeDescription = NULL;
792 in_desc.action = &req_action;
793 in_desc.bodyElementDescription = &body;
794 desc[0] = &in_desc;
796 hr = WsReceiveMessage( channel, msg, desc, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE,
797 NULL, &val, sizeof(val), NULL, NULL, NULL );
798 ok( hr == S_OK, "got %08x\n", hr );
799 ok( val == -1, "got %d\n", val );
800 WsFreeMessage( msg );
802 hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
803 ok( hr == S_OK, "got %08x\n", hr );
805 out_desc.action = &reply_action;
806 out_desc.bodyElementDescription = &body;
808 hr = WsSendMessage( channel, msg, &out_desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL );
809 ok( hr == S_OK, "got %08x\n", hr );
810 WsFreeMessage( msg );
813 static void client_request_reply( const struct listener_info *info )
815 WS_XML_STRING localname = {9, (BYTE *)"localname"}, ns = {2, (BYTE *)"ns"};
816 WS_XML_STRING req_action = {7, (BYTE *)"request"}, reply_action= {5, (BYTE *)"reply"};
817 WCHAR buf[64];
818 WS_CHANNEL *channel;
819 WS_MESSAGE *req, *reply;
820 WS_ENDPOINT_ADDRESS addr;
821 WS_ELEMENT_DESCRIPTION body;
822 WS_MESSAGE_DESCRIPTION req_desc, reply_desc;
823 INT32 val_in = -1, val_out = 0;
824 HRESULT hr;
826 hr = WsCreateChannel( info->type, info->binding, NULL, 0, NULL, &channel, NULL );
827 ok( hr == S_OK, "got %08x\n", hr );
829 memset( &addr, 0, sizeof(addr) );
830 addr.url.length = wsprintfW( buf, fmt_net_tcp, info->port );
831 addr.url.chars = buf;
832 hr = WsOpenChannel( channel, &addr, NULL, NULL );
833 ok( hr == S_OK, "got %08x\n", hr );
835 hr = WsCreateMessageForChannel( channel, NULL, 0, &req, NULL );
836 ok( hr == S_OK, "got %08x\n", hr );
838 hr = WsCreateMessageForChannel( channel, NULL, 0, &reply, NULL );
839 ok( hr == S_OK, "got %08x\n", hr );
841 hr = WsInitializeMessage( req, WS_BLANK_MESSAGE, NULL, NULL );
842 ok( hr == S_OK, "got %08x\n", hr );
844 body.elementLocalName = &localname;
845 body.elementNs = &ns;
846 body.type = WS_INT32_TYPE;
847 body.typeDescription = NULL;
849 req_desc.action = &req_action;
850 req_desc.bodyElementDescription = &body;
852 reply_desc.action = &reply_action;
853 reply_desc.bodyElementDescription = &body;
855 hr = WsRequestReply( channel, req, &req_desc, WS_WRITE_REQUIRED_VALUE, &val_in, sizeof(val_in), reply,
856 &reply_desc, WS_READ_REQUIRED_VALUE, NULL, &val_out, sizeof(val_out), NULL, NULL );
857 ok( val_out == -1, "got %d\n", val_out );
859 hr = WsCloseChannel( channel, NULL, NULL );
860 ok( hr == S_OK, "got %08x\n", hr );
862 WsFreeMessage( req );
863 WsFreeMessage( reply );
864 WsFreeChannel( channel );
867 static DWORD CALLBACK listener_proc( void *arg )
869 struct listener_info *info = arg;
870 const WCHAR *fmt = (info->binding == WS_TCP_CHANNEL_BINDING) ? fmt_net_tcp : fmt_soap_udp;
871 WS_LISTENER *listener;
872 WS_CHANNEL *channel;
873 WCHAR buf[64];
874 WS_STRING url;
875 HRESULT hr;
877 hr = WsCreateListener( info->type, info->binding, NULL, 0, NULL, &listener, NULL );
878 ok( hr == S_OK, "got %08x\n", hr );
880 url.length = wsprintfW( buf, fmt, info->port );
881 url.chars = buf;
882 hr = WsOpenListener( listener, &url, NULL, NULL );
883 ok( hr == S_OK, "got %08x\n", hr );
885 hr = WsCreateChannelForListener( listener, NULL, 0, &channel, NULL );
886 ok( hr == S_OK, "got %08x\n", hr );
888 SetEvent( info->wait );
890 hr = WsAcceptChannel( listener, channel, NULL, NULL );
891 ok( hr == S_OK, "got %08x\n", hr );
893 info->server_func( channel );
895 SetEvent( info->wait );
897 hr = WsCloseChannel( channel, NULL, NULL );
898 ok( hr == S_OK, "got %08x\n", hr );
899 WsFreeChannel( channel );
901 hr = WsCloseListener( listener, NULL, NULL );
902 ok( hr == S_OK, "got %08x\n", hr );
903 WsFreeListener( listener );
905 return 0;
908 static HANDLE start_listener( struct listener_info *info )
910 DWORD err;
911 HANDLE thread = CreateThread( NULL, 0, listener_proc, info, 0, NULL );
912 ok( thread != NULL, "failed to create listener thread %u\n", GetLastError() );
914 err = WaitForSingleObject( info->wait, 3000 );
915 ok( err == WAIT_OBJECT_0, "failed to start listener %u\n", err );
916 return thread;
919 enum firewall_op
921 APP_ADD,
922 APP_REMOVE
925 static BOOL is_process_elevated(void)
927 HANDLE token;
928 if (OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token ))
930 TOKEN_ELEVATION_TYPE type;
931 DWORD size;
932 BOOL ret;
934 ret = GetTokenInformation( token, TokenElevationType, &type, sizeof(type), &size );
935 CloseHandle( token );
936 return (ret && type == TokenElevationTypeFull);
938 return FALSE;
941 static BOOL is_firewall_enabled(void)
943 HRESULT hr, init;
944 INetFwMgr *mgr = NULL;
945 INetFwPolicy *policy = NULL;
946 INetFwProfile *profile = NULL;
947 VARIANT_BOOL enabled = VARIANT_FALSE;
949 init = CoInitializeEx( 0, COINIT_APARTMENTTHREADED );
951 hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr,
952 (void **)&mgr );
953 ok( hr == S_OK, "got %08x\n", hr );
954 if (hr != S_OK) goto done;
956 hr = INetFwMgr_get_LocalPolicy( mgr, &policy );
957 ok( hr == S_OK, "got %08x\n", hr );
958 if (hr != S_OK) goto done;
960 hr = INetFwPolicy_get_CurrentProfile( policy, &profile );
961 if (hr != S_OK) goto done;
963 hr = INetFwProfile_get_FirewallEnabled( profile, &enabled );
964 ok( hr == S_OK, "got %08x\n", hr );
966 done:
967 if (policy) INetFwPolicy_Release( policy );
968 if (profile) INetFwProfile_Release( profile );
969 if (mgr) INetFwMgr_Release( mgr );
970 if (SUCCEEDED( init )) CoUninitialize();
971 return (enabled == VARIANT_TRUE);
974 static HRESULT set_firewall( enum firewall_op op )
976 static const WCHAR testW[] = {'w','e','b','s','e','r','v','i','c','e','s','_','t','e','s','t',0};
977 HRESULT hr, init;
978 INetFwMgr *mgr = NULL;
979 INetFwPolicy *policy = NULL;
980 INetFwProfile *profile = NULL;
981 INetFwAuthorizedApplication *app = NULL;
982 INetFwAuthorizedApplications *apps = NULL;
983 BSTR name, image = SysAllocStringLen( NULL, MAX_PATH );
985 if (!GetModuleFileNameW( NULL, image, MAX_PATH ))
987 SysFreeString( image );
988 return E_FAIL;
990 init = CoInitializeEx( 0, COINIT_APARTMENTTHREADED );
992 hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr,
993 (void **)&mgr );
994 ok( hr == S_OK, "got %08x\n", hr );
995 if (hr != S_OK) goto done;
997 hr = INetFwMgr_get_LocalPolicy( mgr, &policy );
998 ok( hr == S_OK, "got %08x\n", hr );
999 if (hr != S_OK) goto done;
1001 hr = INetFwPolicy_get_CurrentProfile( policy, &profile );
1002 if (hr != S_OK) goto done;
1004 hr = INetFwProfile_get_AuthorizedApplications( profile, &apps );
1005 ok( hr == S_OK, "got %08x\n", hr );
1006 if (hr != S_OK) goto done;
1008 hr = CoCreateInstance( &CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER,
1009 &IID_INetFwAuthorizedApplication, (void **)&app );
1010 ok( hr == S_OK, "got %08x\n", hr );
1011 if (hr != S_OK) goto done;
1013 hr = INetFwAuthorizedApplication_put_ProcessImageFileName( app, image );
1014 if (hr != S_OK) goto done;
1016 name = SysAllocString( testW );
1017 hr = INetFwAuthorizedApplication_put_Name( app, name );
1018 SysFreeString( name );
1019 ok( hr == S_OK, "got %08x\n", hr );
1020 if (hr != S_OK) goto done;
1022 if (op == APP_ADD)
1023 hr = INetFwAuthorizedApplications_Add( apps, app );
1024 else if (op == APP_REMOVE)
1025 hr = INetFwAuthorizedApplications_Remove( apps, image );
1026 else
1027 hr = E_INVALIDARG;
1029 done:
1030 if (app) INetFwAuthorizedApplication_Release( app );
1031 if (apps) INetFwAuthorizedApplications_Release( apps );
1032 if (policy) INetFwPolicy_Release( policy );
1033 if (profile) INetFwProfile_Release( profile );
1034 if (mgr) INetFwMgr_Release( mgr );
1035 if (SUCCEEDED( init )) CoUninitialize();
1036 SysFreeString( image );
1037 return hr;
1040 START_TEST(channel)
1042 BOOL firewall_enabled = is_firewall_enabled();
1043 struct listener_info info;
1044 HANDLE thread;
1045 HRESULT hr;
1046 unsigned int i;
1047 static const struct test
1049 WS_CHANNEL_BINDING binding;
1050 WS_CHANNEL_TYPE type;
1051 void (*server_func)( WS_CHANNEL * );
1052 void (*client_func)( const struct listener_info * );
1054 tests[] =
1056 { WS_UDP_CHANNEL_BINDING, WS_CHANNEL_TYPE_DUPLEX, server_message_read_write, client_message_read_write },
1057 { WS_TCP_CHANNEL_BINDING, WS_CHANNEL_TYPE_DUPLEX_SESSION, server_duplex_session, client_duplex_session },
1058 { WS_UDP_CHANNEL_BINDING, WS_CHANNEL_TYPE_DUPLEX, server_accept_channel, client_accept_channel },
1059 { WS_TCP_CHANNEL_BINDING, WS_CHANNEL_TYPE_DUPLEX_SESSION, server_accept_channel, client_accept_channel },
1060 { WS_TCP_CHANNEL_BINDING, WS_CHANNEL_TYPE_DUPLEX_SESSION, server_request_reply, client_request_reply },
1063 if (firewall_enabled)
1065 if (!is_process_elevated())
1067 skip( "no privileges, skipping tests to avoid firewall dialog\n" );
1068 return;
1070 if ((hr = set_firewall( APP_ADD )) != S_OK)
1072 skip( "can't authorize app in firewall %08x\n", hr );
1073 return;
1077 test_WsCreateChannel();
1078 test_WsOpenChannel();
1079 test_WsResetChannel();
1080 test_WsCreateListener();
1081 test_WsOpenListener();
1082 test_WsCreateChannelForListener();
1083 test_WsResetListener();
1085 info.port = 7533;
1086 info.wait = CreateEventW( NULL, 0, 0, NULL );
1088 for (i = 0; i < ARRAY_SIZE(tests); i++)
1090 info.binding = tests[i].binding;
1091 info.type = tests[i].type;
1092 info.server_func = tests[i].server_func;
1094 thread = start_listener( &info );
1095 tests[i].client_func( &info );
1096 WaitForSingleObject( thread, 3000 );
1097 CloseHandle( thread );
1100 if (firewall_enabled) set_firewall( APP_REMOVE );