shell32/tests: Basic tests for SHCreateSessionKey().
[wine.git] / dlls / wbemprox / tests / services.c
blob4c42a508fd657cb291ea25b8f287c27b6515b813
1 /*
2 * Copyright 2012 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 #define COBJMACROS
21 #include <stdio.h>
22 #include "windows.h"
23 #include "objidl.h"
24 #include "wbemcli.h"
25 #include "wine/test.h"
27 static void test_IClientSecurity(void)
29 static const WCHAR rootW[] = {'R','O','O','T','\\','C','I','M','V','2',0};
30 HRESULT hr;
31 IWbemLocator *locator;
32 IWbemServices *services;
33 IClientSecurity *security;
34 BSTR path = SysAllocString( rootW );
35 ULONG refs;
37 hr = CoCreateInstance( &CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (void **)&locator );
38 if (hr != S_OK)
40 win_skip("can't create instance of WbemLocator\n");
41 return;
43 ok( hr == S_OK, "failed to create IWbemLocator interface %08x\n", hr );
45 refs = IWbemLocator_Release( locator );
46 ok( refs == 0, "unexpected refcount %u\n", refs );
48 hr = CoCreateInstance( &CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (void **)&locator );
49 ok( hr == S_OK, "failed to create IWbemLocator interface %08x\n", hr );
51 hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
52 ok( hr == S_OK, "failed to get IWbemServices interface %08x\n", hr );
54 refs = IWbemServices_Release( services );
55 ok( refs == 0, "unexpected refcount %u\n", refs );
57 hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
58 ok( hr == S_OK, "failed to get IWbemServices interface %08x\n", hr );
60 hr = IWbemServices_QueryInterface( services, &IID_IClientSecurity, (void **)&security );
61 ok( hr == S_OK, "failed to query IClientSecurity interface %08x\n", hr );
62 ok( (void *)services != (void *)security, "expected pointers to be different\n" );
64 refs = IClientSecurity_Release( security );
65 ok( refs == 1, "unexpected refcount %u\n", refs );
67 refs = IWbemServices_Release( services );
68 ok( refs == 0, "unexpected refcount %u\n", refs );
70 hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
71 ok( hr == S_OK, "failed to get IWbemServices interface %08x\n", hr );
73 hr = IWbemServices_QueryInterface( services, &IID_IClientSecurity, (void **)&security );
74 ok( hr == S_OK, "failed to query IClientSecurity interface %08x\n", hr );
75 ok( (void *)services != (void *)security, "expected pointers to be different\n" );
77 refs = IWbemServices_Release( services );
78 todo_wine ok( refs == 1, "unexpected refcount %u\n", refs );
80 refs = IClientSecurity_Release( security );
81 todo_wine ok( refs == 0, "unexpected refcount %u\n", refs );
83 IWbemLocator_Release( locator );
84 SysFreeString( path );
87 static void test_IWbemLocator(void)
89 static const WCHAR path0W[] = {0};
90 static const WCHAR path1W[] = {'\\',0};
91 static const WCHAR path2W[] = {'\\','\\',0};
92 static const WCHAR path3W[] = {'\\','\\','.',0};
93 static const WCHAR path4W[] = {'\\','\\','.','\\',0};
94 static const WCHAR path5W[] = {'\\','R','O','O','T',0};
95 static const WCHAR path6W[] = {'\\','\\','R','O','O','T',0};
96 static const WCHAR path7W[] = {'\\','\\','.','R','O','O','T',0};
97 static const WCHAR path8W[] = {'\\','\\','.','\\','N','O','N','E',0};
98 static const WCHAR path9W[] = {'\\','\\','.','\\','R','O','O','T',0};
99 static const WCHAR path10W[] = {'\\','\\','\\','.','\\','R','O','O','T',0};
100 static const WCHAR path11W[] = {'\\','/','.','\\','R','O','O','T',0};
101 static const WCHAR path12W[] = {'/','/','.','\\','R','O','O','T',0};
102 static const WCHAR path13W[] = {'\\','\\','.','/','R','O','O','T',0};
103 static const WCHAR path14W[] = {'/','/','.','/','R','O','O','T',0};
104 static const WCHAR path15W[] = {'N','O','N','E',0};
105 static const WCHAR path16W[] = {'R','O','O','T',0};
106 static const WCHAR path17W[] = {'R','O','O','T','\\','N','O','N','E',0};
107 static const WCHAR path18W[] = {'R','O','O','T','\\','C','I','M','V','2',0};
108 static const WCHAR path19W[] = {'R','O','O','T','\\','\\','C','I','M','V','2',0};
109 static const WCHAR path20W[] = {'R','O','O','T','\\','C','I','M','V','2','\\',0};
110 static const WCHAR path21W[] = {'R','O','O','T','/','C','I','M','V','2',0};
111 static const WCHAR path22W[] = {'r','o','o','t','\\','d','e','f','a','u','l','t',0};
112 static const WCHAR path23W[] = {'r','o','o','t','\\','c','i','m','v','0',0};
113 static const WCHAR path24W[] = {'r','o','o','t','\\','c','i','m','v','1',0};
114 static const WCHAR path25W[] = {'\\','\\','l','o','c','a','l','h','o','s','t','\\','R','O','O','T',0};
115 static const WCHAR path26W[] = {'\\','\\','L','O','C','A','L','H','O','S','T','\\','R','O','O','T',0};
116 static const struct
118 const WCHAR *path;
119 HRESULT result;
120 BOOL todo;
121 HRESULT result_broken;
123 test[] =
125 { path0W, WBEM_E_INVALID_NAMESPACE },
126 { path1W, WBEM_E_INVALID_NAMESPACE },
127 { path2W, WBEM_E_INVALID_NAMESPACE },
128 { path3W, WBEM_E_INVALID_NAMESPACE },
129 { path4W, WBEM_E_INVALID_NAMESPACE, FALSE, WBEM_E_INVALID_PARAMETER },
130 { path5W, WBEM_E_INVALID_NAMESPACE },
131 { path6W, 0x800706ba, TRUE },
132 { path7W, 0x800706ba, TRUE },
133 { path8W, WBEM_E_INVALID_NAMESPACE },
134 { path9W, S_OK },
135 { path10W, WBEM_E_INVALID_PARAMETER },
136 { path11W, S_OK, FALSE, WBEM_E_INVALID_PARAMETER },
137 { path12W, S_OK },
138 { path13W, S_OK },
139 { path14W, S_OK },
140 { path15W, WBEM_E_INVALID_NAMESPACE },
141 { path16W, S_OK },
142 { path17W, WBEM_E_INVALID_NAMESPACE },
143 { path18W, S_OK },
144 { path19W, WBEM_E_INVALID_NAMESPACE, FALSE, WBEM_E_INVALID_PARAMETER },
145 { path20W, WBEM_E_INVALID_NAMESPACE, FALSE, WBEM_E_INVALID_PARAMETER },
146 { path21W, S_OK },
147 { path22W, S_OK },
148 { path23W, WBEM_E_INVALID_NAMESPACE },
149 { path24W, WBEM_E_INVALID_NAMESPACE },
150 { path25W, S_OK },
151 { path26W, S_OK }
153 IWbemLocator *locator;
154 IWbemServices *services;
155 unsigned int i;
156 HRESULT hr;
157 BSTR resource;
159 hr = CoCreateInstance( &CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (void **)&locator );
160 if (hr != S_OK)
162 win_skip("can't create instance of WbemLocator\n");
163 return;
165 ok( hr == S_OK, "failed to create IWbemLocator interface %08x\n", hr );
167 for (i = 0; i < sizeof(test) / sizeof(test[0]); i++)
169 resource = SysAllocString( test[i].path );
170 hr = IWbemLocator_ConnectServer( locator, resource, NULL, NULL, NULL, 0, NULL, NULL, &services );
171 if (test[i].todo) todo_wine
172 ok( hr == test[i].result || broken(hr == test[i].result_broken),
173 "%u: expected %08x got %08x\n", i, test[i].result, hr );
174 else
175 ok( hr == test[i].result || broken(hr == test[i].result_broken),
176 "%u: expected %08x got %08x\n", i, test[i].result, hr );
177 SysFreeString( resource );
178 if (hr == S_OK) IWbemServices_Release( services );
180 IWbemLocator_Release( locator );
183 START_TEST(services)
185 CoInitialize( NULL );
186 test_IClientSecurity();
187 test_IWbemLocator();
188 CoUninitialize();