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"
17 . $incdir/test_functions.sh
25 ${NETREG} enumerate ${KEY}
32 ${NETREG} getsd ${KEY}
35 test_enumerate_nonexisting()
38 ${NETREG} enumerate ${KEY}
40 if test "x$?" = "x0" ; then
41 echo "ERROR: enumerate succeeded with key '${KEY}'"
48 test_enumerate_no_key()
51 if test "x$?" = "x0" ; then
52 echo "ERROR: enumerate succeeded without any key spcified"
59 test_create_existing()
62 EXPECTED="createkey opened existing ${KEY}"
64 OUTPUT=`${NETREG} createkey ${KEY}`
65 if test "x$?" = "x0" ; then
66 if test "$OUTPUT" = "$EXPECTED" ; then
69 echo "got '$OUTPUT', expected '$EXPECTED'"
73 printf "%s\n" "$OUTPUT"
81 BASEKEY=`dirname $KEY`
82 SUBKEY=`basename $KEY`
84 OUTPUT=`${NETREG} createkey ${KEY}`
85 if test "x$?" != "x0" ; then
86 echo "ERROR: createkey ${KEY} failed"
88 printf "%s\n" "$OUTPUT"
93 # check enumerate of basekey lists new key:
94 OUTPUT=`${NETREG} enumerate ${BASEKEY}`
95 if test "x$?" != "x0" ; then
96 echo "ERROR: failed to enumerate key '${BASEKEY}'"
98 printf "%s\n" "$OUTPUT"
103 EXPECTED="Keyname = ${SUBKEY}"
104 printf "%s\n" "$OUTPUT" | grep '^Keyname' | grep ${SUBKEY}
105 if test "x$?" != "x0" ; then
106 echo "ERROR: did not find expexted '$EXPECTED' in output"
108 printf "%s\n" "$OUTPUT"
112 # check enumerate of new key works:
113 ${NETREG} enumerate ${KEY}
119 BASEKEY=`dirname ${KEY}`
120 SUBKEY=`basename ${KEY}`
122 OUTPUT=`test_createkey "${KEY}"`
123 if test "x$?" != "x0" ; then
124 printf "%s\n" "${OUTPUT}"
129 OUTPUT=`${NETREG} deletekey ${KEY}`
130 if test "x$?" != "x0" ; then
131 printf "%s\n" "${OUTPUT}"
136 # check enumerate of basekey does not show key anymore:
137 OUTPUT=`${NETREG} enumerate ${BASEKEY}`
138 if test "x$?" != "x0" ; then
139 printf "%s\n" "$OUTPUT"
144 UNEXPECTED="Keyname = ${SUBKEY}"
145 printf "%s\n" "$OUTPUT" | 'grep ^Keyname' | grep ${SUBKEY}
146 if test "x$?" = "x0" ; then
147 echo "ERROR: found '$UNEXPECTED' after delete in output"
149 printf "%s\n" "$OUTPUT"
153 # check enumerate of key itself does not work anymore:
154 ${NETREG} enumerate ${KEY}
155 if test "x$?" = "x0" ; then
156 echo "ERROR: 'enumerate ${KEY}' works after 'deletekey ${KEY}'"
163 test_deletekey_nonexisting()
167 OUTPUT=`test_deletekey "${KEY}"`
168 if test "x$?" != "x0" ; then
169 printf "%s\n" "${OUTPUT}"
174 ${NETREG} deletekey "${KEY}"
175 if test "x$?" = "x0" ; then
176 echo "ERROR: delete after delete succeeded for key '${KEY}'"
181 test_createkey_with_subkey()
184 KEY2=`dirname ${KEY}`
185 SUBKEYNAME2=`basename ${KEY}`
186 BASENAME=`dirname ${KEY2}`
187 SUBKEYNAME1=`basename ${KEY2}`
189 OUTPUT=`${NETREG} createkey ${KEY}`
190 if test "x$?" != "x0" ; then
191 echo "ERROR: createkey ${KEY} failed"
192 printf "%s\n" "${OUTPUT}"
197 # check we can enumerate to level key
198 OUTPUT=`${NETREG} enumerate ${KEY}`
199 if test "x$?" != "x0" ; then
200 echo "ERROR: failed to enumerate '${KEY}' after creation"
201 printf "%s\n" "${OUTPUT}"
207 ${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2}
210 test_deletekey_with_subkey()
213 KEY2=`dirname ${KEY}`
215 OUTPUT=`${NETREG} createkey ${KEY}`
216 if test "x$?" != "x0" ; then
217 printf "%s\n" "${OUTPUT}"
222 OUTPUT=`${NETREG} deletekey ${KEY2}`
224 if test "x$?" = "x0" ; then
225 echo "ERROR: delete of key with subkey succeeded"
227 printf "%s\n" "$OUTPUT"
232 ${NETREG} deletekey ${KEY} && ${NETREG} deletekey ${KEY2}
242 OUTPUT=`test_createkey ${KEY}`
243 if test "x$?" != "x0" ; then
244 printf "%s\n" "${OUTPUT}"
249 OUTPUT=`${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE} ${VALVALUE}`
250 if test "x$?" != "x0" ; then
251 echo "ERROR: failed to set value testval in key ${KEY}"
252 printf "%s\n" "${OUTPUT}"
257 OUTPUT=`${NETREG} enumerate ${KEY}`
258 if test "x$?" != "x0" ; then
259 echo "ERROR: failure calling enumerate for key ${KEY}"
261 printf "%s\n" "${OUTPUT}"
266 printf "%s\n" "$OUTPUT" | {
269 SEARCH1=`echo $LINE | grep '^Valuename' | grep ${VALNAME}`
270 if test "x$?" = "x0" ; then
273 SEARCH2=`echo $LINE | grep '^Value ' | grep ${VALVALUE}`
274 if test "x$?" = "x0" ; then
281 if test "x$FOUND" != "x1" ; then
282 echo "ERROR: did not find value '${VALNAME}' with enumerate"
283 echo "enumerate output:"
284 printf "%s\n" "$OUTPUT"
296 ${NETREG} deletevalue ${KEY} ${VALNAME}
299 test_deletevalue_nonexisting()
304 ${NETREG} deletevalue ${KEY} ${VALNAME}
305 if test "x$?" = "x0" ; then
306 echo "ERROR: succeeded deleting value ${VALNAME}"
313 test_setvalue_twice()
322 OUTPUT=`test_setvalue ${KEY} ${VALNAME} ${VALTYPE1} ${VALVALUE1}`
323 if test "x$?" != "x0" ; then
324 echo "ERROR: first setvalue call failed"
325 printf "%s\n" "$OUTPUT"
330 ${NETREG} setvalue ${KEY} ${VALNAME} ${VALTYPE2} ${VALVALUE2}
333 give_administrative_rights()
335 bin/net -s $SERVERCONFFILE sam createbuiltingroup Administrators
336 if test "x$?" != "x0" ; then
337 echo "ERROR: creating builtin group Administrators"
342 bin/net -s $SERVERCONFFILE sam addmem BUILTIN\\Administrators $USERNAME
343 if test "x$?" != "x0" ; then
344 echo "ERROR: adding user $USERNAME to BUILTIN\\Administrators"
351 take_administrative_rights()
353 bin/net -s $SERVERCONFFILE sam delmem BUILTIN\\Administrators $USERNAME
354 if test "x$?" != "x0" ; then
355 echo "ERROR: removing user $USERNAME from BUILTIN\\Administrators"
362 if test "x${RPC}" = "xrpc" ; then
363 testit "giving user ${USERNAME} administrative rights" \
364 give_administrative_rights
365 if [ "x$?" != "x0" ] ; then
366 failed=`expr $failed + 1`
371 testit "enumerate HKLM" \
372 test_enumerate HKLM || \
373 failed=`expr $failed + 1`
375 testit "enumerate nonexisting hive" \
376 test_enumerate_nonexisting XYZ || \
377 failed=`expr $failed + 1`
379 testit "enumerate without key" \
380 test_enumerate_no_key || \
381 failed=`expr $failed + 1`
383 # skip getsd test for registry currently: it fails
384 if test "x${RPC}" != "xrpc" ; then
385 testit "getsd HKLM" \
387 failed=`expr $failed + 1`
390 testit "create existing HKLM" \
391 test_create_existing || \
392 failed=`expr $failed + 1`
394 testit "create key" \
395 test_createkey HKLM/testkey || \
396 failed=`expr $failed + 1`
398 testit "delete key" \
399 test_deletekey HKLM/testkey || \
400 failed=`expr $failed + 1`
402 testit "delete^2 key" \
403 test_deletekey_nonexisting HKLM/testkey || \
404 failed=`expr $failed + 1`
406 testit "enumerate nonexisting key" \
407 test_enumerate_nonexisting HKLM/testkey || \
408 failed=`expr $failed + 1`
410 testit "create key with subkey" \
411 test_createkey_with_subkey HKLM/testkey/subkey || \
412 failed=`expr $failed + 1`
414 testit "delete key with subkey" \
415 test_deletekey_with_subkey HKLM/testkey/subkey || \
416 failed=`expr $failed + 1`
419 test_setvalue HKLM/testkey testval sz moin || \
420 failed=`expr $failed + 1`
422 testit "delete value" \
423 test_deletevalue HKLM/testkey testval || \
424 failed=`expr $failed + 1`
426 testit "delete nonexisting value" \
427 test_deletevalue_nonexisting HKLM/testkey testval || \
428 failed=`expr $failed + 1`
430 testit "set value to different type" \
431 test_setvalue_twice HKLM/testkey testval sz moin dword 42 || \
432 failed=`expr $failed + 1`
434 testit "delete key with value" \
435 test_deletekey HKLM/testkey || \
436 failed=`expr $failed + 1`
438 if test "x${RPC}" = "xrpc" ; then
439 testit "taking administrative rights from user ${USERNAME}" \
440 take_administrative_rights || \
441 failed=`expr $failed + 1`