1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
25 #include <vector>
26 #include <set>
27 #include <cstdlib>
28 #include <iostream>
29 #include <ut/ut.h>
30 #include <protocol/protocol.h>
31 #include <unittest/utils.h>
32 #include <sock/sock.h>
33 #include <base/io.h>
34
35 using namespace std;
36
37 /* Local data */
38 static Sock s = INVALID_SOCK;
39 static const char* s_currentNamespace = "";
40 static bool s_DisconnectAfterEachTest = false;
41
42 static void setUp()
43 mike 1.1 {
44 if (INVALID_SOCK == s)
45 {
46 s = SockConnectLocal(ut::getUnittestPortNumberWSMANHTTP());
47 }
48 }
49
50 static void cleanup()
51 {
52 if (s_DisconnectAfterEachTest)
53 {
54 if (INVALID_SOCK != s) Sock_Close(s);
55
56 s = INVALID_SOCK;
57 }
58 }
59
60 static string _CreateRequestXML(
61 const char* cn,
62 const char* ns,
63 const char* enumerationMode = 0,
64 mike 1.1 const char* maxEnvelopeSize = 0,
65 bool specifyNamespace = true)
66 {
67 string res =
68 "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\""
69 " xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\""
70 " xmlns:n=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\""
71 " xmlns:w=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\">"
72 "<s:Header>"
73 "<a:To>http://linux-22kv:22000/wsman</a:To>"
74 "<w:ResourceURI s:mustUnderstand=\"true\">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/";
75
76 res += cn;
77 res += "</w:ResourceURI>"
78 "<a:ReplyTo>"
79 "<a:Address s:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>"
80 "</a:ReplyTo>"
81 "<a:Action s:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action>"
82 "<w:MaxEnvelopeSize s:mustUnderstand=\"true\">";
83
84 if (maxEnvelopeSize)
85 mike 1.1 {
86 res += maxEnvelopeSize;
87 }
88 else
89 {
90 res += "10240";
91 }
92
93 res += "</w:MaxEnvelopeSize>"
94 "<a:MessageID>uuid:FEF3DF41-FFEC-4ABE-ADFC-A8305DAB71C9</a:MessageID>"
95 "<w:Locale xml:lang=\"en-US\" s:mustUnderstand=\"false\" /><w:SelectorSet>";
96
97 if (specifyNamespace)
98 {
99 res +=
100 "<w:Selector Name=\"__cimnamespace\">";
101 res += s_currentNamespace;
102 res += ns;
103 res += "</w:Selector>";
104 }
105 else
106 mike 1.1 {
107 res +=
108 "<w:Selector Name=\"something\">value</w:Selector>";
109 }
110
111 res +=
112 "</w:SelectorSet>"
113 "<w:OperationTimeout>PT60.000S</w:OperationTimeout>"
114 "</s:Header>"
115 "<s:Body>"
116 "<n:Enumerate>"
117 "<w:OptimizeEnumeration/>"
118 "<w:MaxElements>10</w:MaxElements>";
119 if (enumerationMode)
120 res += enumerationMode;
121
122 res +=
123 "</n:Enumerate></s:Body></s:Envelope>"
124 ;
125
126 return res;
127 mike 1.1 }
128
129 static string _CreateInvokeRequestXML(
130 const char* cn,
131 const char* ns,
132 const char* method,
133 const char* params,
134 const char* keys,
135 bool specifyNamespace = true)
136 {
137 string res =
138 "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\""
139 " xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\""
140 " xmlns:w=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\""
141 " xmlns:p=\"http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd\">"
142 "<s:Header><a:To>http://localhost:7778/wsman</a:To><w:ResourceURI s:mustUnderstand=\"true\">"
143 "http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/";
144
145 res += cn;
146 res += "</w:ResourceURI><a:ReplyTo><a:Address s:mustUnderstand=\"true\">"
147 "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"
148 mike 1.1 "<a:Action s:mustUnderstand=\"true\">http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/";
149
150 res += cn;
151 res += "/";
152 res += method;
153 res +=
154 "</a:Action><w:MaxEnvelopeSize s:mustUnderstand=\"true\">32768</w:MaxEnvelopeSize><a:MessageID>"
155 "uuid:E8928068-D73B-4206-9E95-894088B96288</a:MessageID><w:Locale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
156 "<p:DataLocale xml:lang=\"en-US\" s:mustUnderstand=\"false\" /><w:SelectorSet>";
157
158
159 if (specifyNamespace)
160 {
161 res +=
162 "<w:Selector Name=\"__cimnamespace\">";
163 res += s_currentNamespace;
164 res += ns;
165 res += "</w:Selector>";
166 }
167 else
168 {
169 mike 1.1 res +=
170 "<w:Selector Name=\"something\">value</w:Selector>";
171 }
172
173 if (keys)
174 res += keys;
175
176 res += "</w:SelectorSet><w:OperationTimeout>PT60.000S</w:OperationTimeout></s:Header><s:Body>"
177 "<p:SpellNumber_INPUT xmlns:p=\"http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/X_smallNumber\">";
178
179 res += params;
180 res +=
181 "</p:SpellNumber_INPUT></s:Body></s:Envelope>";
182
183 return res;
184 }
185
186 static string _CreateGetRequestXML(
187 const char* cn,
188 const char* ns,
189 const char* keys,
190 mike 1.1 bool specifyNamespace = true)
191 {
192 string res =
193 "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\""
194 " xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\""
195 " xmlns:w=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\""
196 " xmlns:p=\"http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd\">"
197 "<s:Header><a:To>http://localhost:7778/wsman</a:To>"
198 "<w:ResourceURI s:mustUnderstand=\"true\">"
199 "http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/";
200
201 res += cn;
202 res += "</w:ResourceURI>"
203 "<a:ReplyTo><a:Address s:mustUnderstand=\"true\">"
204 "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"
205 "<a:Action s:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/09/transfer/Get"
206 "</a:Action>"
207 "<w:MaxEnvelopeSize s:mustUnderstand=\"true\">32768</w:MaxEnvelopeSize>"
208 "<a:MessageID>uuid:E8928068-D73B-4206-9E95-894088B96288</a:MessageID><w:Locale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
209 "<p:DataLocale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
210 "<w:SelectorSet>";
211 mike 1.1
212 if (specifyNamespace)
213 {
214 res +=
215 "<w:Selector Name=\"__cimnamespace\">";
216 res += s_currentNamespace;
217 res += ns;
218 res += "</w:Selector>";
219 }
220 else
221 {
222 res +=
223 "<w:Selector Name=\"something\">value</w:Selector>";
224 }
225
226 if (keys)
227 res += keys;
228
229 res += "</w:SelectorSet><w:OperationTimeout>PT60.000S</w:OperationTimeout></s:Header><s:Body>"
230 "</s:Body></s:Envelope>";
231
232 mike 1.1 return res;
233 }
234
235 static string _CreateDeleteRequestXML(
236 const char* cn,
237 const char* ns,
238 const char* keys,
239 bool specifyNamespace = true)
240 {
241 string res =
242 "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\""
243 " xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\""
244 " xmlns:w=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\""
245 " xmlns:p=\"http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd\">"
246 "<s:Header><a:To>http://localhost:7778/wsman</a:To>"
247 "<w:ResourceURI s:mustUnderstand=\"true\">"
248 "http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/";
249
250 res += cn;
251 res += "</w:ResourceURI>"
252 "<a:ReplyTo><a:Address s:mustUnderstand=\"true\">"
253 mike 1.1 "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"
254 "<a:Action s:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete"
255 "</a:Action>"
256 "<w:MaxEnvelopeSize s:mustUnderstand=\"true\">32768</w:MaxEnvelopeSize>"
257 "<a:MessageID>uuid:E8928068-D73B-4206-9E95-894088B96288</a:MessageID><w:Locale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
258 "<p:DataLocale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
259 "<w:SelectorSet>";
260
261 if (specifyNamespace)
262 {
263 res +=
264 "<w:Selector Name=\"__cimnamespace\">";
265 res += s_currentNamespace;
266 res += ns;
267 res += "</w:Selector>";
268 }
269 else
270 {
271 res +=
272 "<w:Selector Name=\"something\">value</w:Selector>";
273 }
274 mike 1.1
275 if (keys)
276 res += keys;
277
278 res += "</w:SelectorSet><w:OperationTimeout>PT60.000S</w:OperationTimeout></s:Header><s:Body>"
279 "</s:Body></s:Envelope>";
280
281 return res;
282 }
283
284 static string _CreateCreateRequestXML(
285 const char* cn,
286 const char* ns,
287 const char* props,
288 bool specifyNamespace = true)
289 {
290 string res =
291 "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\""
292 " xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\""
293 " xmlns:w=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\""
294 " xmlns:p=\"http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd\">"
295 mike 1.1 "<s:Header><a:To>http://localhost:7778/wsman</a:To>"
296 "<w:ResourceURI s:mustUnderstand=\"true\">"
297 "http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/";
298
299 res += cn;
300 res += "</w:ResourceURI>"
301 "<a:ReplyTo><a:Address s:mustUnderstand=\"true\">"
302 "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"
303 "<a:Action s:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/09/transfer/Create"
304 "</a:Action>"
305 "<w:MaxEnvelopeSize s:mustUnderstand=\"true\">32768</w:MaxEnvelopeSize>"
306 "<a:MessageID>uuid:E8928068-D73B-4206-9E95-894088B96288</a:MessageID><w:Locale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
307 "<p:DataLocale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
308 "<w:SelectorSet>";
309
310 if (specifyNamespace)
311 {
312 res +=
313 "<w:Selector Name=\"__cimnamespace\">";
314 res += s_currentNamespace;
315 res += ns;
316 mike 1.1 res += "</w:Selector>";
317 }
318 else
319 {
320 res +=
321 "<w:Selector Name=\"something\">value</w:Selector>";
322 }
323
324
325 res += "</w:SelectorSet><w:OperationTimeout>PT60.000S</w:OperationTimeout></s:Header><s:Body>";
326
327 res += props;
328
329 res +=
330 "</s:Body></s:Envelope>";
331
332 return res;
333 }
334
335 static string _CreateModifyRequestXML(
336 const char* cn,
337 mike 1.1 const char* ns,
338 const char* keys,
339 const char* props,
340 bool specifyNamespace = true)
341 {
342 string res =
343 "<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\""
344 " xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\""
345 " xmlns:w=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\""
346 " xmlns:p=\"http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd\">"
347 "<s:Header><a:To>http://localhost:7778/wsman</a:To>"
348 "<w:ResourceURI s:mustUnderstand=\"true\">"
349 "http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/";
350
351 res += cn;
352 res += "</w:ResourceURI>"
353 "<a:ReplyTo><a:Address s:mustUnderstand=\"true\">"
354 "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"
355 "<a:Action s:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/09/transfer/Put"
356 "</a:Action>"
357 "<w:MaxEnvelopeSize s:mustUnderstand=\"true\">32768</w:MaxEnvelopeSize>"
358 mike 1.1 "<a:MessageID>uuid:E8928068-D73B-4206-9E95-894088B96288</a:MessageID><w:Locale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
359 "<p:DataLocale xml:lang=\"en-US\" s:mustUnderstand=\"false\" />"
360 "<w:SelectorSet>";
361
362 if (specifyNamespace)
363 {
364 res +=
365 "<w:Selector Name=\"__cimnamespace\">";
366 res += s_currentNamespace;
367 res += ns;
368 res += "</w:Selector>";
369 }
370 else
371 {
372 res +=
373 "<w:Selector Name=\"something\">value</w:Selector>";
374 }
375
376 if (keys)
377 res += keys;
378
379 mike 1.1 res += "</w:SelectorSet><w:OperationTimeout>PT60.000S</w:OperationTimeout></s:Header><s:Body>";
380
381 res += props;
382
383 res +=
384 "</s:Body></s:Envelope>";
385
386 return res;
387 }
388
389 static void TestWSMANemptyRequest()
390 {
391 string r_b, r_h;
392
393 SockSendRecvHTTP(s, false, "", r_h, r_b );
394 // send invalid xml; expecting http 500 back
395 UT_ASSERT(r_h.find("500") != string::npos);
396 }
397
398 static void TestWSMANInvalidXML()
399 {
400 mike 1.1 string r_b, r_h;
401
402 SockSendRecvHTTP(s, false, "invalid xml", r_h, r_b );
403 // send invalid xml; expecting http 500 back
404 UT_ASSERT(r_h.find("500") != string::npos);
405 }
406
407 static void TestWSMAN_NotSupportedEncoding()
408 {
409 string r_b, r_h;
410
411 // use utf16 encoding header
412 SockSendRecvHTTP(s, true, _CreateRequestXML("X_number", "test/cpp").c_str(), r_h, r_b );
413 // send not-supported encoding; expecting http 500 back
414 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
415 UT_ASSERT(r_h.find("500") != string::npos);
416 }
417
418 static void TestWSMAN_Fault_invalidNamespace()
419 {
420 string r_b, r_h;
421 mike 1.1 SockSendRecvHTTP(s, false, _CreateRequestXML("X_number", "invlaid/namespace").c_str(), r_h, r_b );
422
423 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
424
425 // send invalid request; expecting http 500 back
426 UT_ASSERT(r_h.find("500") != string::npos);
427 UT_ASSERT(!r_b.empty());
428 UT_ASSERT(r_b.find("wsa:DestinationUnreachable") != string::npos);
429 UT_ASSERT(r_b.find("CIM ERROR:INVALID_NAMESPACE") != string::npos);
430 }
431
432 static void TestWSMAN_Fault_instanceBiggerThaEnvelope()
433 {
434 string r_b, r_h;
435 SockSendRecvHTTP(s, false, _CreateRequestXML("X_SingletonWithAllTypes", "test/cpp", 0, "8200").c_str(), r_h, r_b );
436
437 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
438
439 // send envelope size is not enough to hold one instance; expecting http 500 back
440 UT_ASSERT(r_h.find("500") != string::npos);
441 UT_ASSERT(!r_b.empty());
442 mike 1.1 UT_ASSERT(r_b.find("wsman:EncodingLimit") != string::npos);
443 UT_ASSERT(r_b.find("insufficient envelope size") != string::npos);
444 }
445
446 static void TestWSMAN_Fault_invalidClass()
447 {
448 string r_b, r_h;
449 SockSendRecvHTTP(s, false, _CreateRequestXML("InvalidClassname", "test/cpp").c_str(), r_h, r_b );
450
451 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
452
453 // send invalid request; expecting http 500 back
454 UT_ASSERT(r_h.find("500") != string::npos);
455 UT_ASSERT(!r_b.empty());
456 UT_ASSERT(r_b.find("wsa:DestinationUnreachable") != string::npos);
457 UT_ASSERT(r_b.find("CIM ERROR:INVALID_CLASS") != string::npos);
458 }
459
460 static void TestWSMAN_Enumerate_XProfile()
461 {
462 string r_b, r_h;
463 mike 1.1 SockSendRecvHTTP(s, false, _CreateRequestXML("X_Profile", "interop").c_str(), r_h, r_b );
464
465 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
466
467 UT_ASSERT(r_h.find("200") != string::npos);
468 UT_ASSERT(!r_b.empty());
469 UT_ASSERT(r_b.find("World") != string::npos);
470 UT_ASSERT(r_b.find("Huge Numbers") != string::npos);
471 }
472
473 static void TestWSMAN_Enumerate_XProfile_EPR_Only()
474 {
475 string r_b, r_h;
476 SockSendRecvHTTP(s, false, _CreateRequestXML("X_Profile", "interop", "<w:EnumerationMode>EnumerateEPR</w:EnumerationMode>").c_str(), r_h, r_b );
477
478 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
479
480 UT_ASSERT(r_h.find("200") != string::npos);
481 UT_ASSERT(!r_b.empty());
482
483 /* expect EPR back */
484 mike 1.1 UT_ASSERT(r_b.find("<wsa:EndpointReference>") != string::npos);
485 UT_ASSERT(r_b.find("Name=\"InstanceID\">world<") != string::npos);
486 UT_ASSERT(r_b.find("Name=\"InstanceID\">number<") != string::npos);
487
488 /* regular properties shuld not be specified */
489 UT_ASSERT(r_b.find("World") == string::npos);
490 UT_ASSERT(r_b.find("Huge Numbers") == string::npos);
491 }
492
493 static void TestWSMAN_Enumerate_XProfile_EPRAndObject()
494 {
495 string r_b, r_h;
496 SockSendRecvHTTP(s, false, _CreateRequestXML("X_Profile", "interop", "<w:EnumerationMode>EnumerateObjectAndEPR</w:EnumerationMode>").c_str(), r_h, r_b );
497
498 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
499
500 UT_ASSERT(r_h.find("200") != string::npos);
501 UT_ASSERT(!r_b.empty());
502
503 /* expect EPR back */
504 UT_ASSERT(r_b.find("<wsa:EndpointReference>") != string::npos);
505 mike 1.1 UT_ASSERT(r_b.find("Name=\"InstanceID\">world<") != string::npos);
506 UT_ASSERT(r_b.find("Name=\"InstanceID\">number<") != string::npos);
507
508 /* and regular properties */
509 UT_ASSERT(r_b.find("World") != string::npos);
510 UT_ASSERT(r_b.find("Huge Numbers") != string::npos);
511 }
512
513 static void TestWSMAN_Enumerate_X_SingletonWithAllTypes()
514 {
515 string r_b, r_h;
516 SockSendRecvHTTP(s, false, _CreateRequestXML("X_SingletonWithAllTypes", "test/cpp", 0, "64000").c_str(), r_h, r_b );
517
518 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
519
520 UT_ASSERT(r_h.find("200") != string::npos);
521 UT_ASSERT(!r_b.empty());
522
523 // check data
524 // (see X_SingletonWithAllTypes_Class_Provider.cpp to see how it was created)
525 UT_ASSERT(r_b.find("id>1<") != string::npos);
526 mike 1.1 UT_ASSERT(r_b.find("b>TRUE<") != string::npos);
527 UT_ASSERT(r_b.find("u8>172<") != string::npos);
528 UT_ASSERT(r_b.find("u16>1745<") != string::npos);
529
530 // inst.c16_value(1044);
531 // in utf8 it's -48, -108 or 0xd0, 0x94
532 #if 0
533 UT_ASSERT(r_b.find("c16>\xd0\x94<") != string::npos);
534 #else
535 UT_ASSERT(r_b.find("c16>1044<") != string::npos);
536 #endif
537
538 UT_ASSERT(r_b.find("s8>-123<") != string::npos);
539 UT_ASSERT(r_b.find("u16>1745<") != string::npos);
540 UT_ASSERT(r_b.find("s16>-1746<") != string::npos);
541 UT_ASSERT(r_b.find("u32>17567<") != string::npos);
542 UT_ASSERT(r_b.find("s32>-17568<") != string::npos);
543
544 UT_ASSERT(r_b.find("u64>18446744073709551613<") != string::npos);
545 UT_ASSERT(r_b.find("s64>-9223372036854775805<") != string::npos);
546 UT_ASSERT(r_b.find("s>string value<") != string::npos);
547 mike 1.1
548 /* due to truncation feature of float numbers,
549 skip comparison of last digit */
550 UT_ASSERT(r_b.find("r32>32.3") != string::npos);
551 UT_ASSERT(r_b.find("r64>64.646") != string::npos);
552 UT_ASSERT(r_b.find("dt>2010-07-14T11:35:11.900675-00:07<") != string::npos);
553
554 // person
555 UT_ASSERT(r_b.find("person>") != string::npos);
556 UT_ASSERT(r_b.find("MSFT_Person>") != string::npos);
557 UT_ASSERT(r_b.find("Last>Smith<") != string::npos);
558 UT_ASSERT(r_b.find("First>John<") != string::npos);
559 UT_ASSERT(r_b.find("Key>7<") != string::npos);
560
561 // object
562 UT_ASSERT(r_b.find("objectSingle>") != string::npos);
563 UT_ASSERT(r_b.find("X_TestObject>") != string::npos);
564 UT_ASSERT(r_b.find("id>9000<") != string::npos);
565 //UT_ASSERT(r_b.find("operation>?<") != string::npos);
566 UT_ASSERT(r_b.find("right_operand xsi:nil=\"true\"/>") != string::npos);
567
568 mike 1.1 // test array values
569 UT_ASSERT(r_b.find("bA>TRUE<") != string::npos);
570 UT_ASSERT(r_b.find("bA>FALSE<") != string::npos);
571 UT_ASSERT(r_b.find("u8A>0<") != string::npos);
572 UT_ASSERT(r_b.find("u8A>255<") != string::npos);
573 UT_ASSERT(r_b.find("u8A>128<") != string::npos);
574 UT_ASSERT(r_b.find("s8A>0<") != string::npos);
575 UT_ASSERT(r_b.find("s8A>127<") != string::npos);
576 UT_ASSERT(r_b.find("s8A>-128<") != string::npos);
577 UT_ASSERT(r_b.find("u16A>0<") != string::npos);
578 UT_ASSERT(r_b.find("u16A>64000<") != string::npos);
579 UT_ASSERT(r_b.find("s16A>0<") != string::npos);
580 UT_ASSERT(r_b.find("s16A>-1216<") != string::npos);
581 UT_ASSERT(r_b.find("s16A>258<") != string::npos);
582
583 }
584
585 static void TestWSMAN_Enumerate_X_HugeNumberConformsToProfile()
586 {
587 // Enumerate Assoc class and verify references are returned properly
588 string r_b, r_h;
589 mike 1.1 SockSendRecvHTTP(s, false, _CreateRequestXML("X_HugeNumberConformsToProfile", "test/cpp").c_str(), r_h, r_b );
590
591 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
592
593 UT_ASSERT(r_h.find("200") != string::npos);
594 UT_ASSERT(!r_b.empty());
595
596 // check data
597 UT_ASSERT(r_b.find(":Profile>") != string::npos);
598 UT_ASSERT(r_b.find("Name=\"InstanceID\">number<") != string::npos);
599
600 UT_ASSERT(r_b.find("<wsman:Selector Name=\"Number\">1000000</wsman:Selector>") != string::npos);
601 }
602
603 static void TestWSMAN_Enumerate_MissingNamespace()
604 {
605 string r_b, r_h;
606 /* namespace param is missing - expecting error back */
607 SockSendRecvHTTP(s, false, _CreateRequestXML("X_Profile", "interop", 0, 0, false).c_str(), r_h, r_b );
608
609 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
610 mike 1.1
611 UT_ASSERT(r_h.find("500") != string::npos);
612 UT_ASSERT(r_b.find(">wsman:InternalError<") != string::npos);
613 UT_ASSERT(r_b.find(">mandatory parameters") != string::npos);
614 }
615
616 static void TestWSMAN_Enumerate_X_HugeNumber_Deep()
617 {
618 // Enumerate X_HugeNumber - expecting back 3 instances
619 string r_b, r_h;
620 SockSendRecvHTTP(s, false,
621 _CreateRequestXML("X_HugeNumber", "test/cpp",
622 "<b:PolymorphismMode xmlns:b=\"http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd\">IncludeSubClassProperties</b:PolymorphismMode>"
623 ).c_str(), r_h, r_b );
624
625 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
626
627 UT_ASSERT(r_h.find("200") != string::npos);
628 UT_ASSERT(!r_b.empty());
629
630 // check data: expecting three items and property 'Property0'
631 mike 1.1 // all should present
632 UT_ASSERT(r_b.find("Number>1000000<") != string::npos);
633 UT_ASSERT(r_b.find("Number>1000000000<") != string::npos);
634 UT_ASSERT(r_b.find("Number>1000001<") != string::npos);
635 UT_ASSERT(r_b.find("Property0>9<") != string::npos);
636 UT_ASSERT(r_b.find("<p:X_Number1000001") != string::npos);
637 }
638
639 static void TestWSMAN_Enumerate_X_HugeNumber_BasicProps()
640 {
641 // Enumerate X_HugeNumber - expecting back 3 instances
642 string r_b, r_h;
643 SockSendRecvHTTP(s, false,
644 _CreateRequestXML("X_HugeNumber", "test/cpp",
645 "<b:PolymorphismMode xmlns:b=\"http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd\">ExcludeSubClassProperties</b:PolymorphismMode>"
646 ).c_str(), r_h, r_b );
647
648 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
649
650 UT_ASSERT(r_h.find("200") != string::npos);
651 UT_ASSERT(!r_b.empty());
652 mike 1.1
653 // check data: expecting three items and property 'Property0'
654 // 3 instances are expected, but no sub-class properties/sub-class name
655 UT_ASSERT(r_b.find("Number>1000000<") != string::npos);
656 UT_ASSERT(r_b.find("Number>1000000000<") != string::npos);
657 UT_ASSERT(r_b.find("Number>1000001<") != string::npos);
658
659 UT_ASSERT(r_b.find("Property0>9<") == string::npos);
660 UT_ASSERT(r_b.find("<p:X_Number1000001") == string::npos);
661 }
662
663 static void TestWSMAN_Enumerate_X_HugeNumber_Shallow()
664 {
665 // Enumerate X_HugeNumber - expecting back 3 instances
666 string r_b, r_h;
667 SockSendRecvHTTP(s, false,
668 _CreateRequestXML("X_HugeNumber", "test/cpp",
669 "<b:PolymorphismMode xmlns:b=\"http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd\">None</b:PolymorphismMode>"
670 ).c_str(), r_h, r_b );
671
672 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
673 mike 1.1
674 UT_ASSERT(r_h.find("200") != string::npos);
675 UT_ASSERT(!r_b.empty());
676
677 // check data: expecting three items and property 'Property0'
678 // only 2 instances are expected - exact class match
679 UT_ASSERT(r_b.find("Number>1000000<") != string::npos);
680 UT_ASSERT(r_b.find("Number>1000000000<") != string::npos);
681
682 UT_ASSERT(r_b.find("Number>1000001<") == string::npos);
683 UT_ASSERT(r_b.find("Property0>9<") == string::npos);
684 UT_ASSERT(r_b.find("<p:X_Number1000001") == string::npos);
685 }
686
687 static void TestWSMAN_Invoke_SmallNumber_SpellNumber()
688 {
689 string r_b, r_h;
690 SockSendRecvHTTP(s, false,
691 _CreateInvokeRequestXML("X_Smallnumber", "test/cpp", "spellNumber", "<p:num>77</p:num>", "").c_str(), r_h, r_b );
692
693 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
694 mike 1.1
695 UT_ASSERT(r_h.find("200") != string::npos);
696 UT_ASSERT(!r_b.empty());
697
698 // check data
699 UT_ASSERT(r_b.find("MIReturn>seventy seven<") != string::npos);
700 }
701
702 static void TestWSMAN_Invoke_MissingNamespace()
703 {
704 string r_b, r_h;
705 SockSendRecvHTTP(s, false,
706 _CreateInvokeRequestXML("X_Smallnumber", "test/cpp", "spellNumber", "<p:num>77</p:num>", "", false).c_str(), r_h, r_b );
707
708 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
709
710 UT_ASSERT(r_h.find("500") != string::npos);
711 UT_ASSERT(!r_b.empty());
712
713 // check data
714 UT_ASSERT(r_b.find(">wsman:InternalError<") != string::npos);
715 mike 1.1 UT_ASSERT(r_b.find("CIM ERROR:INVALID_PARAMETER") != string::npos);
716 }
717
718 static void TestWSMAN_Invoke_SmallNumber_SpellNumber_OOP()
719 {
720 string r_b, r_h;
721 SockSendRecvHTTP(s, false,
722 _CreateInvokeRequestXML("X_Smallnumber", "oop/requestor/test/cpp", "spellNumber", "<p:num>77</p:num>", "").c_str(), r_h, r_b );
723
724 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
725
726 UT_ASSERT(r_h.find("200") != string::npos);
727 UT_ASSERT(!r_b.empty());
728
729 // check data
730 UT_ASSERT(r_b.find("MIReturn>seventy seven<") != string::npos);
731 }
732
733 static void TestWSMAN_Invoke_TestEmbeddedObjectReturnKey20100609()
734 {
735 string r_b, r_h;
736 mike 1.1 SockSendRecvHTTP(s, false,
737 _CreateInvokeRequestXML("TestEmbeddedOperations", "test/cpp", "TestEmbeddedObjectReturnKey20100609", "", "<w:Selector Name=\"key\">1</w:Selector>").c_str(), r_h, r_b );
738
739 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
740 if (r_h.find("200") == string::npos)
741 cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
742
743 // send invalid request; expecting http 500 back
744 UT_ASSERT(r_h.find("200") != string::npos);
745 UT_ASSERT(!r_b.empty());
746
747 // check data
748 UT_ASSERT(r_b.find("ObjectID>20100609<") != string::npos);
749 UT_ASSERT(r_b.find("X_TestEmbeddedObjectNotReferenced") != string::npos);
750 }
751
752 static void TestWSMAN_Invoke_TestEmbeddedObjectReturnKey20100609_OOP()
753 {
754 string r_b, r_h;
755 SockSendRecvHTTP(s, false,
756 _CreateInvokeRequestXML("TestEmbeddedOperations", "oop/requestor/test/cpp", "TestEmbeddedObjectReturnKey20100609", "", "<w:Selector Name=\"key\">1</w:Selector>").c_str(), r_h, r_b );
757 mike 1.1
758 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
759
760 // send invalid request; expecting http 500 back
761 UT_ASSERT(r_h.find("200") != string::npos);
762 UT_ASSERT(!r_b.empty());
763
764 // check data
765 UT_ASSERT(r_b.find("ObjectID>20100609<") != string::npos);
766 UT_ASSERT(r_b.find("X_TestEmbeddedObjectNotReferenced") != string::npos);
767 }
768
769 static void TestWSMAN_Invoke_TestEmbedded()
770 {
771 const char* c_embeddedInstance =
772 "<p:objectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
773 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
774 <q:MSFT_Base>\
775 <q:Key>101</q:Key>\
776 </q:MSFT_Base>\
777 </p:objectsArray>";
778 mike 1.1
779 string r_b, r_h;
780 SockSendRecvHTTP(s, false,
781 _CreateInvokeRequestXML("TestEmbeddedOperations", "test/cpp", "TestEmbedded", c_embeddedInstance, "<w:Selector Name=\"key\">1</w:Selector>").c_str(), r_h, r_b );
782
783 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
784 UT_ASSERT(r_h.find("200") != string::npos);
785 UT_ASSERT(!r_b.empty());
786
787 // check data
788 UT_ASSERT(r_b.find("Key>101<") != string::npos);
789 UT_ASSERT(r_b.find("Species>test<") != string::npos);
790 UT_ASSERT(r_b.find("MSFT_Animal") != string::npos);
791 }
792
793 static void TestWSMAN_Invoke_TestEmbeddedWithArray()
794 {
795 const char* c_embeddedInstance =
796 "\
797 <p:objectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
798 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
799 mike 1.1 <q:MSFT_Base>\
800 <q:Key>101</q:Key>\
801 </q:MSFT_Base>\
802 </p:objectsArray>\
803 <p:objectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
804 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
805 <q:MSFT_Base>\
806 <q:Key>102</q:Key>\
807 </q:MSFT_Base>\
808 </p:objectsArray>\
809 <p:objectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
810 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
811 <q:MSFT_Base>\
812 <q:Key>103</q:Key>\
813 </q:MSFT_Base>\
814 </p:objectsArray>\
815 ";
816
817 string r_b, r_h;
818 SockSendRecvHTTP(s, false,
819 _CreateInvokeRequestXML("TestEmbeddedOperations", "test/cpp", "TestEmbedded", c_embeddedInstance, "<w:Selector Name=\"key\">1</w:Selector>").c_str(), r_h, r_b );
820 mike 1.1
821 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
822 UT_ASSERT(r_h.find("200") != string::npos);
823 UT_ASSERT(!r_b.empty());
824
825 // check data
826 UT_ASSERT(r_b.find("Key>101<") != string::npos);
827 UT_ASSERT(r_b.find("Key>102<") != string::npos);
828 UT_ASSERT(r_b.find("Key>103<") != string::npos);
829 UT_ASSERT(r_b.find("Species>test<") != string::npos);
830 UT_ASSERT(r_b.find("MSFT_Animal") != string::npos);
831 }
832
833 static void TestWSMAN_Invoke_TestEmbeddedWithMultipleArrays()
834 {
835 const char* c_embeddedInstance =
836 "\
837 <p:objectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
838 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
839 <q:MSFT_Base>\
840 <q:Key>101</q:Key>\
841 mike 1.1 </q:MSFT_Base>\
842 </p:objectsArray>\
843 <p:objectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
844 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
845 <q:MSFT_Base>\
846 <q:Key>102</q:Key>\
847 </q:MSFT_Base>\
848 </p:objectsArray>\
849 <p:objectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
850 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
851 <q:MSFT_Base>\
852 <q:Key>103</q:Key>\
853 </q:MSFT_Base>\
854 </p:objectsArray>\
855 \
856 <p:testObjectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
857 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
858 <q:X_TestObject>\
859 <q:id>9000109</q:id>\
860 </q:X_TestObject>\
861 </p:testObjectsArray>\
862 mike 1.1 <p:testObjectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
863 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
864 <q:X_TestObject>\
865 <q:str>some string</q:str>\
866 <q:id>9000209</q:id>\
867 </q:X_TestObject>\
868 </p:testObjectsArray>\
869 <p:testObjectsArray xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
870 xmlns:q=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\">\
871 <q:X_TestObject>\
872 <q:id>9000309</q:id>\
873 <q:str>+</q:str>\
874 <q:result>1719</q:result>\
875 </q:X_TestObject>\
876 </p:testObjectsArray>\
877 ";
878
879 string r_b, r_h;
880 SockSendRecvHTTP(s, false,
881 _CreateInvokeRequestXML("TestEmbeddedOperations", "test/cpp", "TestEmbedded", c_embeddedInstance, "<w:Selector Name=\"key\">1</w:Selector>").c_str(), r_h, r_b );
882
883 mike 1.1 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
884 UT_ASSERT(r_h.find("200") != string::npos);
885 UT_ASSERT(!r_b.empty());
886
887 // check data
888 UT_ASSERT(r_b.find("Key>101<") != string::npos);
889 UT_ASSERT(r_b.find("Key>102<") != string::npos);
890 UT_ASSERT(r_b.find("Key>103<") != string::npos);
891 UT_ASSERT(r_b.find("Species>test<") != string::npos);
892 UT_ASSERT(r_b.find("MSFT_Animal") != string::npos);
893
894 UT_ASSERT(r_b.find("MIReturn") != string::npos);
895 UT_ASSERT(r_b.find("X_TestObject") != string::npos);
896 UT_ASSERT(r_b.find("id>27000627<") != string::npos);
897 UT_ASSERT(r_b.find("id>9000309<") != string::npos);
898 UT_ASSERT(r_b.find("result>1719<") != string::npos);
899 UT_ASSERT(r_b.find("str>some string<") != string::npos);
900
901 }
902
903 static void TestWSMAN_Invoke_TestAllTypesWithSingleItemArray()
904 mike 1.1 {
905 const char* c_Params =
906 "\
907 <p:b>false</p:b>\
908 <p:u8>90</p:u8>\
909 <p:u8A>13</p:u8A>\
910 <p:u8A>14</p:u8A>\
911 <p:s16A>-9</p:s16A>\
912 ";
913
914 string r_b, r_h;
915 SockSendRecvHTTP(s, false,
916 _CreateInvokeRequestXML("MSFT_Person", "test/cpp", "TestAllTypes", c_Params, "<w:Selector Name=\"key\">777</w:Selector>").c_str(), r_h, r_b );
917
918 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
919 UT_ASSERT(r_h.find("200") != string::npos);
920 UT_ASSERT(!r_b.empty());
921
922 // check data
923 UT_ASSERT(r_b.find("u8A>2<") != string::npos);
924 UT_ASSERT(r_b.find("u8A>27<") != string::npos);
925 mike 1.1 UT_ASSERT(r_b.find("u8>91<") != string::npos);
926 UT_ASSERT(r_b.find("b>TRUE<") != string::npos);
927 UT_ASSERT(r_b.find("s16A>1<") != string::npos);
928 UT_ASSERT(r_b.find("s16A>-9<") != string::npos);
929 }
930
931 /* verify array buffer re-allocation (16 items boundary)*/
932 static void TestWSMAN_Invoke_TestAllTypesWith17ItemsArray()
933 {
934 const char* c_Params =
935 "\
936 <p:u64A>1</p:u64A>\
937 <p:u64A>2</p:u64A>\
938 <p:u64A>3</p:u64A>\
939 <p:u64A>4</p:u64A>\
940 <p:u64A>5</p:u64A>\
941 <p:u64A>6</p:u64A>\
942 <p:u64A>7</p:u64A>\
943 <p:u64A>8</p:u64A>\
944 <p:u64A>9</p:u64A>\
945 <p:u64A>10</p:u64A>\
946 mike 1.1 <p:u64A>11</p:u64A>\
947 <p:u64A>12</p:u64A>\
948 <p:u64A>13</p:u64A>\
949 <p:u64A>14</p:u64A>\
950 <p:u64A>15</p:u64A>\
951 <p:u64A>16</p:u64A>\
952 <p:u64A>17</p:u64A>\
953 ";
954
955 string r_b, r_h;
956 SockSendRecvHTTP(s, false,
957 _CreateInvokeRequestXML("MSFT_Person", "test/cpp", "TestAllTypes", c_Params, "<w:Selector Name=\"key\">777</w:Selector>").c_str(), r_h, r_b );
958
959 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
960 UT_ASSERT(r_h.find("200") != string::npos);
961 UT_ASSERT(!r_b.empty());
962
963 // check data - number of elements and sum
964 UT_ASSERT(r_b.find("u64A>17<") != string::npos);
965 UT_ASSERT(r_b.find("u64A>153<") != string::npos);
966 }
967 mike 1.1
968 /* verify array two buffer re-allocations (16 items boundary)*/
969 static void TestWSMAN_Invoke_TestAllTypesWith33ItemsArray()
970 {
971 const char* c_Params =
972 "\
973 <p:u64A>1</p:u64A>\
974 <p:u64A>2</p:u64A>\
975 <p:u64A>3</p:u64A>\
976 <p:u64A>4</p:u64A>\
977 <p:u64A>5</p:u64A>\
978 <p:u64A>6</p:u64A>\
979 <p:u64A>7</p:u64A>\
980 <p:u64A>8</p:u64A>\
981 <p:u64A>9</p:u64A>\
982 <p:u64A>10</p:u64A>\
983 <p:u64A>11</p:u64A>\
984 <p:u64A>12</p:u64A>\
985 <p:u64A>13</p:u64A>\
986 <p:u64A>14</p:u64A>\
987 <p:u64A>15</p:u64A>\
988 mike 1.1 <p:u64A>16</p:u64A>\
989 <p:u64A>17</p:u64A>\
990 <p:u64A>18</p:u64A>\
991 <p:u64A>19</p:u64A>\
992 <p:u64A>20</p:u64A>\
993 <p:u64A>21</p:u64A>\
994 <p:u64A>22</p:u64A>\
995 <p:u64A>23</p:u64A>\
996 <p:u64A>24</p:u64A>\
997 <p:u64A>25</p:u64A>\
998 <p:u64A>26</p:u64A>\
999 <p:u64A>27</p:u64A>\
1000 <p:u64A>28</p:u64A>\
1001 <p:u64A>29</p:u64A>\
1002 <p:u64A>30</p:u64A>\
1003 <p:u64A>31</p:u64A>\
1004 <p:u64A>32</p:u64A>\
1005 <p:u64A>33</p:u64A>\
1006 ";
1007
1008 string r_b, r_h;
1009 mike 1.1 SockSendRecvHTTP(s, false,
1010 _CreateInvokeRequestXML("MSFT_Person", "test/cpp", "TestAllTypes", c_Params, "<w:Selector Name=\"key\">777</w:Selector>").c_str(), r_h, r_b );
1011
1012 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1013 UT_ASSERT(r_h.find("200") != string::npos);
1014 UT_ASSERT(!r_b.empty());
1015
1016 // check data - number of elements and sum
1017 UT_ASSERT(r_b.find("u64A>33<") != string::npos);
1018 UT_ASSERT(r_b.find("u64A>561<") != string::npos);
1019 }
1020
1021 /* verify u64 type operations */
1022 static void TestWSMAN_Invoke_TestAllTypesU64Max()
1023 {
1024 /*u64 max is 18446744073709551615; expect it as sum of two items */
1025 const char* c_Params =
1026 "\
1027 <p:u64A>18446744073709551610</p:u64A>\
1028 <p:u64A>5</p:u64A>\
1029 ";
1030 mike 1.1
1031 string r_b, r_h;
1032 SockSendRecvHTTP(s, false,
1033 _CreateInvokeRequestXML("MSFT_Person", "test/cpp", "TestAllTypes", c_Params, "<w:Selector Name=\"key\">777</w:Selector>").c_str(), r_h, r_b );
1034
1035 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1036 UT_ASSERT(r_h.find("200") != string::npos);
1037 UT_ASSERT(!r_b.empty());
1038
1039 // check data - number of elements and sum
1040 UT_ASSERT(r_b.find("u64A>2<") != string::npos);
1041 UT_ASSERT(r_b.find("u64A>18446744073709551615<") != string::npos);
1042 }
1043
1044 static void TestWSMAN_Invoke_TestAllTypesStringArray()
1045 {
1046 /* unit-test expects exactly two strings and retunr 3 strings: substrings form first two plus '*'*/
1047 const char* c_Params =
1048 "\
1049 <p:sA>123456</p:sA>\
1050 <p:sA>abcdef</p:sA>\
1051 mike 1.1 ";
1052
1053 string r_b, r_h;
1054 SockSendRecvHTTP(s, false,
1055 _CreateInvokeRequestXML("MSFT_Person", "test/cpp", "TestAllTypes", c_Params, "<w:Selector Name=\"key\">777</w:Selector>").c_str(), r_h, r_b );
1056
1057 // cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1058 UT_ASSERT(r_h.find("200") != string::npos);
1059 UT_ASSERT(!r_b.empty());
1060
1061 // check data - number of elements and sum
1062 UT_ASSERT(r_b.find("sA>456<") != string::npos);
1063 UT_ASSERT(r_b.find("sA>def<") != string::npos);
1064 UT_ASSERT(r_b.find("sA>*<") != string::npos);
1065 }
1066
1067 static void TestWSMAN_Invoke_TestAllTypesReference()
1068 {
1069 /* unit-test expects a reference parameter and returns reference to the same class with key++ */
1070 const char* c_Params =
1071 "\
1072 mike 1.1 <p:rf>\
1073 <a:Address xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\
1074 http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous\
1075 </a:Address>\
1076 <a:ReferenceParameters xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:w=\"http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\">\
1077 <w:ResourceURI>\
1078 http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/MSFT_Base\
1079 </w:ResourceURI>\
1080 <w:SelectorSet>\
1081 <w:Selector Name=\"Key\">89</w:Selector>\
1082 </w:SelectorSet>\
1083 </a:ReferenceParameters>\
1084 </p:rf>\
1085 ";
1086
1087 string r_b, r_h;
1088 SockSendRecvHTTP(s, false,
1089 _CreateInvokeRequestXML("MSFT_Person", "test/cpp", "TestAllTypes", c_Params, "<w:Selector Name=\"key\">777</w:Selector>").c_str(), r_h, r_b );
1090
1091 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1092 UT_ASSERT(r_h.find("200") != string::npos);
1093 mike 1.1 UT_ASSERT(!r_b.empty());
1094
1095 // check data - number of elements and sum
1096 UT_ASSERT(r_b.find("Selector Name=\"Key\">90<") != string::npos);
1097 }
1098
1099 static void TestWSMAN_Get_SmallNumber_17()
1100 {
1101 string r_b, r_h;
1102
1103 SockSendRecvHTTP(s, false,
1104 _CreateGetRequestXML("X_smallNumber", "test/cpp", "<w:Selector Name=\"Number\">17</w:Selector>").c_str(), r_h, r_b );
1105
1106 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1107
1108 UT_ASSERT(r_h.find("200") != string::npos);
1109 UT_ASSERT(!r_b.empty());
1110
1111 // check data - number of elements and sum
1112 UT_ASSERT(r_b.find("<wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse</") != string::npos);
1113 UT_ASSERT(r_b.find("Number>17<") != string::npos);
1114 mike 1.1 UT_ASSERT(r_b.find("SpelledNumber>seventeen<") != string::npos);
1115 }
1116
1117 static void TestWSMAN_Get_SmallNumber_NotFound()
1118 {
1119 string r_b, r_h;
1120
1121 SockSendRecvHTTP(s, false,
1122 _CreateGetRequestXML("X_smallNumber", "test/cpp", "<w:Selector Name=\"Number\">17000</w:Selector>").c_str(), r_h, r_b );
1123
1124 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1125
1126 UT_ASSERT(r_h.find("500") != string::npos);
1127 UT_ASSERT(!r_b.empty());
1128
1129 // check data - number of elements and sum
1130 UT_ASSERT(r_b.find("CIM ERROR:NOT_FOUND") != string::npos);
1131 UT_ASSERT(r_b.find("Value>wsa:DestinationUnreachable<") != string::npos);
1132 }
1133
1134 static void TestWSMAN_Get_MissingNamespace()
1135 mike 1.1 {
1136 string r_b, r_h;
1137
1138 SockSendRecvHTTP(s, false,
1139 _CreateGetRequestXML("X_smallNumber", "test/cpp", "<w:Selector Name=\"Number\">17</w:Selector>", false).c_str(), r_h, r_b );
1140
1141 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1142
1143 UT_ASSERT(r_h.find("500") != string::npos);
1144 UT_ASSERT(!r_b.empty());
1145
1146 // check data - number of elements and sum
1147 UT_ASSERT(r_b.find(">CIM ERROR:INVALID_PARAMETER") != string::npos);
1148 UT_ASSERT(r_b.find("Value>wsman:InternalError<") != string::npos);
1149 }
1150
1151 static void TestWSMAN_Delete_SmallNumber_7()
1152 {
1153 string r_b, r_h;
1154
1155 SockSendRecvHTTP(s, false,
1156 mike 1.1 _CreateDeleteRequestXML("X_smallNumber", "test/cpp", "<w:Selector Name=\"Number\">7</w:Selector>").c_str(), r_h, r_b );
1157
1158 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1159
1160 UT_ASSERT(r_h.find("200") != string::npos);
1161 UT_ASSERT(!r_b.empty());
1162
1163 // check data - number of elements and sum
1164 UT_ASSERT(r_b.find("<wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/transfer/DeleteResponse</") != string::npos);
1165 }
1166
1167 static void TestWSMAN_Delete_SmallNumber_17_NotFound()
1168 {
1169 string r_b, r_h;
1170
1171 SockSendRecvHTTP(s, false,
1172 _CreateDeleteRequestXML("X_smallNumber", "test/cpp", "<w:Selector Name=\"Number\">17</w:Selector>").c_str(), r_h, r_b );
1173
1174 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1175
1176 UT_ASSERT(r_h.find("500") != string::npos);
1177 mike 1.1 UT_ASSERT(!r_b.empty());
1178
1179 // check data - number of elements and sum
1180 UT_ASSERT(r_b.find("CIM ERROR:NOT_FOUND") != string::npos);
1181 UT_ASSERT(r_b.find("Value>wsa:DestinationUnreachable<") != string::npos);
1182 }
1183
1184 static void TestWSMAN_Delete_MissingNamespace()
1185 {
1186 string r_b, r_h;
1187
1188 SockSendRecvHTTP(s, false,
1189 _CreateDeleteRequestXML("X_smallNumber", "test/cpp", "<w:Selector Name=\"Number\">7</w:Selector>", false).c_str(), r_h, r_b );
1190
1191 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1192
1193 UT_ASSERT(r_h.find("500") != string::npos);
1194 UT_ASSERT(!r_b.empty());
1195
1196 // check data - number of elements and sum
1197 UT_ASSERT(r_b.find(">CIM ERROR:INVALID_PARAMETER") != string::npos);
1198 mike 1.1 UT_ASSERT(r_b.find("Value>wsman:InternalError<") != string::npos);
1199 }
1200
1201 static void TestWSMAN_Create_SmallNumber_ok()
1202 {
1203 string r_b, r_h;
1204 const char* props =
1205 "<p:X_smallNumber xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/X_smallNumber\">"
1206 " <p:Description>text</p:Description>"
1207 " </p:X_smallNumber>";
1208
1209 SockSendRecvHTTP(s, false,
1210 _CreateCreateRequestXML("X_smallNumber", "test/cpp", props).c_str(), r_h, r_b );
1211
1212 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1213
1214 UT_ASSERT(r_h.find("200") != string::npos);
1215 UT_ASSERT(!r_b.empty());
1216
1217 // check data - number of elements and sum
1218 UT_ASSERT(r_b.find("<wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/transfer/CreateResponse</") != string::npos);
1219 mike 1.1 UT_ASSERT(r_b.find("Name=\"Number\">10000<") != string::npos);
1220 UT_ASSERT(r_b.find("wxf:ResourceCreated>") != string::npos);
1221 }
1222
1223 static void TestWSMAN_Create_SmallNumber_failed_invalid_prop()
1224 {
1225 /* invalid property set */
1226 string r_b, r_h;
1227 const char* props =
1228 "<p:X_smallNumber xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/X_smallNumber\">"
1229 " <p:Description>text</p:Description>"
1230 " <p:InvalidProp>text</p:InvalidProp>"
1231 " </p:X_smallNumber>";
1232
1233 SockSendRecvHTTP(s, false,
1234 _CreateCreateRequestXML("X_smallNumber", "test/cpp", props).c_str(), r_h, r_b );
1235
1236 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1237
1238 UT_ASSERT(r_h.find("500") != string::npos);
1239 UT_ASSERT(!r_b.empty());
1240 mike 1.1
1241 // check data - number of elements and sum
1242 UT_ASSERT(r_b.find("CIM ERROR:FAILED") != string::npos);
1243 }
1244
1245 static void TestWSMAN_Create_SmallNumber_failed_no_description()
1246 {
1247 string r_b, r_h;
1248 const char* props =
1249 "<p:X_smallNumber xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/X_smallNumber\">"
1250 " <p:Number>7</p:Number>"
1251 " </p:X_smallNumber>";
1252
1253 SockSendRecvHTTP(s, false,
1254 _CreateCreateRequestXML("X_smallNumber", "test/cpp", props).c_str(), r_h, r_b );
1255
1256 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1257
1258 UT_ASSERT(r_h.find("500") != string::npos);
1259 UT_ASSERT(!r_b.empty());
1260
1261 mike 1.1 /* when description is not specified, provider returns 'not-found' */
1262 // check data -
1263 UT_ASSERT(r_b.find("CIM ERROR:NOT_FOUND") != string::npos);
1264 }
1265
1266 static void TestWSMAN_Create_SmallNumber_MissingNamespace()
1267 {
1268 string r_b, r_h;
1269 const char* props =
1270 "<p:X_smallNumber xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/X_smallNumber\">"
1271 " <p:Description>text</p:Description>"
1272 " </p:X_smallNumber>";
1273
1274 SockSendRecvHTTP(s, false,
1275 _CreateCreateRequestXML("X_smallNumber", "test/cpp", props, false).c_str(), r_h, r_b );
1276
1277 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1278
1279 UT_ASSERT(r_h.find("500") != string::npos);
1280 UT_ASSERT(!r_b.empty());
1281
1282 mike 1.1 // check data - number of elements and sum
1283 UT_ASSERT(r_b.find(">CIM ERROR:INVALID_PARAMETER") != string::npos);
1284 UT_ASSERT(r_b.find("Value>wsman:InternalError<") != string::npos);
1285 }
1286
1287 static void TestWSMAN_Modify_SmallNumber_ok()
1288 {
1289 string r_b, r_h;
1290 const char* props =
1291 "<p:X_smallNumber xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/X_smallNumber\">"
1292 " <p:Description>text</p:Description>"
1293 " </p:X_smallNumber>";
1294 const char* keys = "<w:Selector Name=\"Number\">7</w:Selector>";
1295
1296 SockSendRecvHTTP(s, false,
1297 _CreateModifyRequestXML("X_smallNumber", "test/cpp", keys, props).c_str(), r_h, r_b );
1298
1299 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1300
1301 UT_ASSERT(r_h.find("200") != string::npos);
1302 UT_ASSERT(!r_b.empty());
1303 mike 1.1
1304 // check data - number of elements and sum
1305 UT_ASSERT(r_b.find("<wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/transfer/PutResponse</") != string::npos);
1306 UT_ASSERT(r_b.find("Number>10000<") != string::npos);
1307 UT_ASSERT(r_b.find("Description>text<") != string::npos);
1308 }
1309
1310 static void TestWSMAN_Modify_SmallNumber_failed_invalid_prop()
1311 {
1312 /* invalid property set */
1313 string r_b, r_h;
1314 const char* props =
1315 "<p:X_smallNumber xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/X_smallNumber\">"
1316 " <p:Description>text</p:Description>"
1317 " <p:InvalidProp>text</p:InvalidProp>"
1318 " </p:X_smallNumber>";
1319 const char* keys = "<w:Selector Name=\"Number\">7</w:Selector>";
1320
1321 SockSendRecvHTTP(s, false,
1322 _CreateModifyRequestXML("X_smallNumber", "test/cpp", keys, props).c_str(), r_h, r_b );
1323
1324 mike 1.1 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1325
1326 UT_ASSERT(r_h.find("500") != string::npos);
1327 UT_ASSERT(!r_b.empty());
1328
1329 // check data - number of elements and sum
1330 UT_ASSERT(r_b.find("CIM ERROR:FAILED") != string::npos);
1331 }
1332
1333 static void TestWSMAN_Modify_SmallNumber_failed_no_description()
1334 {
1335 string r_b, r_h;
1336 const char* props =
1337 "<p:X_smallNumber xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/X_smallNumber\">"
1338 " <p:SpelledNumber>Seven</p:SpelledNumber>"
1339 " </p:X_smallNumber>";
1340 const char* keys = "<w:Selector Name=\"Number\">7</w:Selector>";
1341
1342 SockSendRecvHTTP(s, false,
1343 _CreateModifyRequestXML("X_smallNumber", "test/cpp", keys, props).c_str(), r_h, r_b );
1344
1345 mike 1.1 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1346
1347 UT_ASSERT(r_h.find("500") != string::npos);
1348 UT_ASSERT(!r_b.empty());
1349
1350 /* when description is not specified, provider returns 'not-found' */
1351 // check data -
1352 UT_ASSERT(r_b.find("CIM ERROR:NOT_FOUND") != string::npos);
1353 }
1354
1355 static void TestWSMAN_Modify_SmallNumber_MissingNamespace()
1356 {
1357 string r_b, r_h;
1358 const char* props =
1359 "<p:X_smallNumber xmlns:p=\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/X_smallNumber\">"
1360 " <p:Description>text</p:Description>"
1361 " </p:X_smallNumber>";
1362 const char* keys = "<w:Selector Name=\"Number\">7</w:Selector>";
1363
1364 SockSendRecvHTTP(s, false,
1365 _CreateModifyRequestXML("X_smallNumber", "test/cpp", keys, props, false).c_str(), r_h, r_b );
1366 mike 1.1
1367 //cout << "resp header: " << r_h << endl << endl << "body: " << r_b << endl;
1368
1369 UT_ASSERT(r_h.find("500") != string::npos);
1370 UT_ASSERT(!r_b.empty());
1371
1372 // check data - number of elements and sum
1373 UT_ASSERT(r_b.find(">CIM ERROR:INVALID_PARAMETER") != string::npos);
1374 UT_ASSERT(r_b.find("Value>wsman:InternalError<") != string::npos);
1375 }
1376
1377 void WSMAN_Tests_With_Server()
1378 {
1379 const char* namespaces[] = {
1380 "", "oop/requestor/"
1381 };
1382
1383 for (int KeepALive = 0; KeepALive < 2; KeepALive++)
1384 {
1385 s_DisconnectAfterEachTest = (KeepALive !=0 );
1386
1387 mike 1.1 for (unsigned int i = 0; i < MI_COUNT(namespaces); i++)
1388 {
1389 s_currentNamespace = namespaces[i];
1390
1391 // general errors
1392 UT_TEST(TestWSMANemptyRequest);
1393 UT_TEST(TestWSMANInvalidXML);
1394 UT_TEST(TestWSMAN_NotSupportedEncoding);
1395
1396 // wsman faults
1397 UT_TEST(TestWSMAN_Fault_invalidNamespace);
1398 UT_TEST(TestWSMAN_Fault_invalidClass);
1399 UT_TEST(TestWSMAN_Fault_instanceBiggerThaEnvelope);
1400
1401 // enumeration
1402 UT_TEST(TestWSMAN_Enumerate_XProfile);
1403 UT_TEST(TestWSMAN_Enumerate_XProfile_EPR_Only);
1404 UT_TEST(TestWSMAN_Enumerate_XProfile_EPRAndObject);
1405 UT_TEST(TestWSMAN_Enumerate_X_SingletonWithAllTypes);
1406 UT_TEST(TestWSMAN_Enumerate_X_HugeNumberConformsToProfile);
1407 UT_TEST(TestWSMAN_Enumerate_MissingNamespace);
1408 mike 1.1 // enumeration: deep/shallow/basic-props
1409 UT_TEST(TestWSMAN_Enumerate_X_HugeNumber_Deep);
1410 UT_TEST(TestWSMAN_Enumerate_X_HugeNumber_Shallow);
1411 UT_TEST(TestWSMAN_Enumerate_X_HugeNumber_BasicProps);
1412
1413 // invoke
1414 UT_TEST(TestWSMAN_Invoke_SmallNumber_SpellNumber);
1415 UT_TEST(TestWSMAN_Invoke_SmallNumber_SpellNumber);
1416 UT_TEST(TestWSMAN_Invoke_TestEmbeddedObjectReturnKey20100609);
1417 UT_TEST(TestWSMAN_Invoke_TestEmbedded);
1418 UT_TEST(TestWSMAN_Invoke_TestEmbeddedWithArray);
1419 UT_TEST(TestWSMAN_Invoke_TestEmbeddedWithMultipleArrays);
1420 UT_TEST(TestWSMAN_Invoke_TestAllTypesWithSingleItemArray);
1421 UT_TEST(TestWSMAN_Invoke_TestAllTypesWith17ItemsArray);
1422 UT_TEST(TestWSMAN_Invoke_TestAllTypesWith33ItemsArray);
1423 UT_TEST(TestWSMAN_Invoke_TestAllTypesU64Max);
1424 UT_TEST(TestWSMAN_Invoke_TestAllTypesStringArray);
1425 UT_TEST(TestWSMAN_Invoke_TestAllTypesReference);
1426 UT_TEST(TestWSMAN_Invoke_MissingNamespace);
1427
1428 // get
1429 mike 1.1 UT_TEST(TestWSMAN_Get_SmallNumber_17);
1430 UT_TEST(TestWSMAN_Get_SmallNumber_NotFound);
1431 UT_TEST(TestWSMAN_Get_MissingNamespace);
1432
1433 // delete
1434 UT_TEST(TestWSMAN_Delete_SmallNumber_7);
1435 UT_TEST(TestWSMAN_Delete_SmallNumber_17_NotFound);
1436 UT_TEST(TestWSMAN_Delete_MissingNamespace);
1437
1438 // create
1439 UT_TEST(TestWSMAN_Create_SmallNumber_ok);
1440 UT_TEST(TestWSMAN_Create_SmallNumber_failed_invalid_prop);
1441 UT_TEST(TestWSMAN_Create_SmallNumber_failed_no_description);
1442 UT_TEST(TestWSMAN_Create_SmallNumber_MissingNamespace);
1443
1444 // Put/Set/Modify
1445 UT_TEST(TestWSMAN_Modify_SmallNumber_ok);
1446 UT_TEST(TestWSMAN_Modify_SmallNumber_failed_invalid_prop);
1447 UT_TEST(TestWSMAN_Modify_SmallNumber_failed_no_description);
1448 UT_TEST(TestWSMAN_Modify_SmallNumber_MissingNamespace);
1449
1450 mike 1.1 }
1451 }
1452
1453 s_currentNamespace = "";
1454
1455 // test out-of-process invocation static/non-static
1456 UT_TEST(TestWSMAN_Invoke_SmallNumber_SpellNumber_OOP);
1457 UT_TEST(TestWSMAN_Invoke_TestEmbeddedObjectReturnKey20100609_OOP);
1458 UT_TEST(TestWSMAN_Enumerate_XProfile);
1459
1460
1461 if (INVALID_SOCK != s)
1462 Sock_Close(s);
1463
1464 s = INVALID_SOCK;
1465 }
1466
|