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
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};
31 IWbemLocator
*locator
;
32 IWbemServices
*services
;
33 IClientSecurity
*security
;
34 BSTR path
= SysAllocString( rootW
);
37 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
, (void **)&locator
);
40 win_skip("can't create instance of WbemLocator\n");
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};
119 HRESULT result_broken
;
123 { path0W
, WBEM_E_INVALID_NAMESPACE
},
124 { path1W
, WBEM_E_INVALID_NAMESPACE
},
125 { path2W
, WBEM_E_INVALID_NAMESPACE
},
126 { path3W
, WBEM_E_INVALID_NAMESPACE
},
127 { path4W
, WBEM_E_INVALID_NAMESPACE
, 0, WBEM_E_INVALID_PARAMETER
},
128 { path5W
, WBEM_E_INVALID_NAMESPACE
},
129 { path6W
, 0x800706ba, 1 },
130 { path7W
, 0x800706ba, 1 },
131 { path8W
, WBEM_E_INVALID_NAMESPACE
},
133 { path10W
, WBEM_E_INVALID_PARAMETER
},
138 { path15W
, WBEM_E_INVALID_NAMESPACE
},
140 { path17W
, WBEM_E_INVALID_NAMESPACE
},
142 { path19W
, WBEM_E_INVALID_NAMESPACE
},
143 { path20W
, WBEM_E_INVALID_NAMESPACE
},
146 { path23W
, WBEM_E_INVALID_NAMESPACE
},
147 { path24W
, WBEM_E_INVALID_NAMESPACE
}
149 IWbemLocator
*locator
;
150 IWbemServices
*services
;
155 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
, (void **)&locator
);
158 win_skip("can't create instance of WbemLocator\n");
161 ok( hr
== S_OK
, "failed to create IWbemLocator interface %08x\n", hr
);
163 for (i
= 0; i
< sizeof(test
) / sizeof(test
[0]); i
++)
165 resource
= SysAllocString( test
[i
].path
);
166 hr
= IWbemLocator_ConnectServer( locator
, resource
, NULL
, NULL
, NULL
, 0, NULL
, NULL
, &services
);
167 if (test
[i
].todo
) todo_wine
168 ok( hr
== test
[i
].result
|| broken(hr
== test
[i
].result_broken
),
169 "%u: expected %08x got %08x\n", i
, test
[i
].result
, hr
);
171 ok( hr
== test
[i
].result
|| broken(hr
== test
[i
].result_broken
),
172 "%u: expected %08x got %08x\n", i
, test
[i
].result
, hr
);
173 SysFreeString( resource
);
174 if (hr
== S_OK
) IWbemServices_Release( services
);
176 IWbemLocator_Release( locator
);
181 CoInitialize( NULL
);
182 test_IClientSecurity();