3 # Tests for the "net registry" and "net rpc registry" commands.
4 # rpc tests are chose by specifying "rpc" as commandline parameter.
8 NET
="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION"
10 if test "x${RPC}" = "xrpc" ; then
11 NETREG
="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc registry"
13 NETREG
="${NET} registry"
16 test x
"$TEST_FUNCTIONS_SH" != x
"INCLUDED" && {
18 .
$incdir/test_functions.sh
27 ${NETREG} enumerate
${KEY}
34 ${NETREG} getsd
${KEY}
37 test_enumerate_nonexisting
()
40 ${NETREG} enumerate
${KEY}
42 if test "x$?" = "x0" ; then
43 echo "ERROR: enumerate succeeded with key '${KEY}'"
50 test_enumerate_no_key
()
53 if test "x$?" = "x0" ; then
54 echo "ERROR: enumerate succeeded without any key spcified"
61 test_create_existing
()
64 EXPECTED
="createkey opened existing ${KEY}"
66 OUTPUT
=`${NETREG} createkey ${KEY}`
67 if test "x$?" = "x0" ; then
68 if test "$OUTPUT" = "$EXPECTED" ; then
71 echo "got '$OUTPUT', expected '$EXPECTED'"
75 printf "%s\n" "$OUTPUT"
83 BASEKEY
=`dirname $KEY`
84 SUBKEY
=`basename $KEY`
86 OUTPUT
=`${NETREG} createkey ${KEY}`
87 if test "x$?" != "x0" ; then
88 echo "ERROR: createkey ${KEY} failed"
90 printf "%s\n" "$OUTPUT"
95 # check enumerate of basekey lists new key:
96 OUTPUT
=`${NETREG} enumerate ${BASEKEY}`
97 if test "x$?" != "x0" ; then
98 echo "ERROR: failed to enumerate key '${BASEKEY}'"
100 printf "%s\n" "$OUTPUT"
105 EXPECTED
="Keyname = ${SUBKEY}"
106 printf "%s\n" "$OUTPUT" |
grep '^Keyname' |
grep ${SUBKEY}
107 if test "x$?" != "x0" ; then
108 echo "ERROR: did not find expexted '$EXPECTED' in output"
110 printf "%s\n" "$OUTPUT"
114 # check enumerate of new key works:
115 ${NETREG} enumerate
${KEY}
121 BASEKEY
=`dirname ${KEY}`
122 SUBKEY
=`basename ${KEY}`
124 OUTPUT
=`test_createkey "${KEY}"`
125 if test "x$?" != "x0" ; then
126 printf "%s\n" "${OUTPUT}"
131 OUTPUT
=`${NETREG} deletekey ${KEY}`
132 if test "x$?" != "x0" ; then
133 printf "%s\n" "${OUTPUT}"
138 # check enumerate of basekey does not show key anymore:
139 OUTPUT
=`${NETREG} enumerate ${BASEKEY}`
140 if test "x$?" != "x0" ; then
141 printf "%s\n" "$OUTPUT"
146 UNEXPECTED
="Keyname = ${SUBKEY}"
147 printf "%s\n" "$OUTPUT" |
grep '^Keyname' |
grep ${SUBKEY}
148 if test "x$?" = "x0" ; then
149 echo "ERROR: found '$UNEXPECTED' after delete in output"
151 printf "%s\n" "$OUTPUT"
155 # check enumerate of key itself does not work anymore:
156 ${NETREG} enumerate
${KEY}
157 if test "x$?" = "x0" ; then
158 echo "ERROR: 'enumerate ${KEY}' works after 'deletekey ${KEY}'"
165 test_deletekey_nonexisting
()
169 OUTPUT
=`test_deletekey "${KEY}"`
170 if test "x$?" != "x0" ; then
171 printf "%s\n" "${OUTPUT}"
176 ${NETREG} deletekey
"${KEY}"
177 if test "x$?" = "x0" ; then
178 echo "ERROR: delete after delete succeeded for key '${KEY}'"
183 test_createkey_with_subkey
()
186 KEY2
=`dirname ${KEY}`
187 SUBKEYNAME2
=`basename ${KEY}`
188 BASENAME
=`dirname ${KEY2}`
189 SUBKEYNAME1
=`basename ${KEY2}`
191 OUTPUT
=`${NETREG} createkey ${KEY}`
192 if test "x$?" != "x0" ; then
193 echo "ERROR: createkey ${KEY} failed"
194 printf "%s\n" "${OUTPUT}"
199 # check we can enumerate to level key
200 OUTPUT
=`${NETREG} enumerate ${KEY}`
201 if test "x$?" != "x0" ; then
202 echo "ERROR: failed to enumerate '${KEY}' after creation"
203 printf "%s\n" "${OUTPUT}"
209 ${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2}
212 test_deletekey_with_subkey
()
215 KEY2
=`dirname ${KEY}`
217 OUTPUT
=`${NETREG} createkey ${KEY}`
218 if test "x$?" != "x0" ; then
219 printf "%s\n" "${OUTPUT}"
224 OUTPUT
=`${NETREG} deletekey ${KEY2}`
226 if test "x$?" = "x0" ; then
227 echo "ERROR: delete of key with subkey succeeded"
229 printf "%s\n" "$OUTPUT"
234 ${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2}
244 OUTPUT
=`test_createkey ${KEY}`
245 if test "x$?" != "x0" ; then
246 printf "%s\n" "${OUTPUT}"
251 OUTPUT
=`${NETREG} setvalue ${KEY} "${VALNAME}" ${VALTYPE} ${VALVALUE}`
252 if test "x$?" != "x0" ; then
253 echo "ERROR: failed to set value testval in key ${KEY}"
254 printf "%s\n" "${OUTPUT}"
259 OUTPUT
=`${NETREG} getvalueraw ${KEY} "${VALNAME}"`
260 if test "x$?" != "x0" ; then
261 echo "ERROR: failure calling getvalueraw for key ${KEY}"
263 printf "%s\n" "${OUTPUT}"
268 if test "x${OUTPUT}" != "x${VALVALUE}" ; then
269 echo "ERROR: failure retrieving value ${VALNAME} for key ${KEY}"
270 printf "expected: %s\ngot: %s\n" "${VALVALUE}" "${OUTPUT}"
282 ${NETREG} deletevalue ${KEY} "${VALNAME}"
285 test_deletevalue_nonexisting()
290 ${NETREG} deletevalue ${KEY} "${VALNAME}"
291 if test "x$?" = "x0" ; then
292 echo "ERROR: succeeded deleting value ${VALNAME}"
299 test_setvalue_twice
()
308 OUTPUT
=`test_setvalue ${KEY} _"${VALNAME}" ${VALTYPE1} ${VALVALUE1}`
309 if test "x$?" != "x0" ; then
310 echo "ERROR: first setvalue call failed"
311 printf "%s\n" "$OUTPUT"
316 ${NETREG} setvalue ${KEY} "${VALNAME}" ${VALTYPE2} ${VALVALUE2}
319 give_administrative_rights
()
321 bin
/net
-s $SERVERCONFFILE sam createbuiltingroup Administrators
322 if test "x$?" != "x0" ; then
323 echo "ERROR: creating builtin group Administrators"
328 bin
/net
-s $SERVERCONFFILE sam addmem BUILTIN
\\Administrators
$USERNAME
329 if test "x$?" != "x0" ; then
330 echo "ERROR: adding user $USERNAME to BUILTIN\\Administrators"
337 take_administrative_rights
()
339 bin
/net
-s $SERVERCONFFILE sam delmem BUILTIN
\\Administrators
$USERNAME
340 if test "x$?" != "x0" ; then
341 echo "ERROR: removing user $USERNAME from BUILTIN\\Administrators"
348 if test "x${RPC}" = "xrpc" ; then
349 testit
"giving user ${USERNAME} administrative rights" \
350 give_administrative_rights
351 if [ "x$?" != "x0" ] ; then
352 failed
=`expr $failed + 1`
357 testit
"enumerate HKLM" \
358 test_enumerate HKLM || \
359 failed
=`expr $failed + 1`
361 testit
"enumerate nonexisting hive" \
362 test_enumerate_nonexisting XYZ || \
363 failed
=`expr $failed + 1`
365 testit
"enumerate without key" \
366 test_enumerate_no_key || \
367 failed
=`expr $failed + 1`
369 # skip getsd test for registry currently: it fails
370 if test "x${RPC}" != "xrpc" ; then
371 testit
"getsd HKLM" \
373 failed
=`expr $failed + 1`
376 testit
"create existing HKLM" \
377 test_create_existing || \
378 failed
=`expr $failed + 1`
380 testit
"create key" \
381 test_createkey HKLM
/testkey || \
382 failed
=`expr $failed + 1`
384 testit
"delete key" \
385 test_deletekey HKLM
/testkey || \
386 failed
=`expr $failed + 1`
388 testit
"delete^2 key" \
389 test_deletekey_nonexisting HKLM
/testkey || \
390 failed
=`expr $failed + 1`
392 testit
"enumerate nonexisting key" \
393 test_enumerate_nonexisting HKLM
/testkey || \
394 failed
=`expr $failed + 1`
396 testit
"create key with subkey" \
397 test_createkey_with_subkey HKLM
/testkey
/subkey || \
398 failed
=`expr $failed + 1`
400 testit
"delete key with subkey" \
401 test_deletekey_with_subkey HKLM
/testkey
/subkey || \
402 failed
=`expr $failed + 1`
405 test_setvalue HKLM
/testkey _testval sz moin || \
406 failed
=`expr $failed + 1`
408 testit
"delete value" \
409 test_deletevalue HKLM
/testkey _testval || \
410 failed
=`expr $failed + 1`
412 testit
"delete nonexisting value" \
413 test_deletevalue_nonexisting HKLM
/testkey _testval || \
414 failed
=`expr $failed + 1`
416 testit
"set value to different type" \
417 test_setvalue_twice HKLM
/testkey testval sz moin dword
42 || \
418 failed
=`expr $failed + 1`
420 testit
"set default value" \
421 test_setvalue HKLM
/testkey _
"" sz
42 || \
422 failed
=`expr $failed + 1`
424 testit
"delete default value" \
425 test_deletevalue HKLM
/testkey _
"" || \
426 failed
=`expr $failed + 1`
428 testit
"delete nonexisting default value" \
429 test_deletevalue_nonexisting HKLM
/testkey _
"" || \
430 failed
=`expr $failed + 1`
432 testit
"delete key with value" \
433 test_deletekey HKLM
/testkey || \
434 failed
=`expr $failed + 1`
436 if test "x${RPC}" = "xrpc" ; then
437 testit
"taking administrative rights from user ${USERNAME}" \
438 take_administrative_rights || \
439 failed
=`expr $failed + 1`