CI: add a test creating a vetoed file
authorRalph Boehme <slow@samba.org>
Wed, 5 Apr 2023 09:32:09 +0000 (11:32 +0200)
committerJule Anger <janger@samba.org>
Tue, 11 Apr 2023 15:09:09 +0000 (15:09 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15143

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 2e8954d5be3336f1c4c2cf033209f632ad84e712)

selftest/knownfail.d/samba3.blackbox.test_veto_files.get_veto_file [new file with mode: 0644]
source3/script/tests/test_veto_files.sh

diff --git a/selftest/knownfail.d/samba3.blackbox.test_veto_files.get_veto_file b/selftest/knownfail.d/samba3.blackbox.test_veto_files.get_veto_file
new file mode 100644 (file)
index 0000000..ff8f37f
--- /dev/null
@@ -0,0 +1 @@
+^samba3.blackbox.test_veto_files.create_veto_file\(fileserver\)
index 9f0526bd54c0e74f5c67f11bec6f12c3989b3740..5ecfb53b8a41e52bf1fceab28c550b8865a88a11 100755 (executable)
@@ -84,6 +84,42 @@ EOF
        fi
 }
 
+smbclient_create_expect_error()
+{
+       filename="$1.$$"
+       expected_error="$2"
+       tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+       cat >"$tmpfile" <<EOF
+put $tmpfile $filename
+quit
+EOF
+
+       cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/veto_files -I$SERVER_IP < $tmpfile 2>&1'
+       eval echo "$cmd"
+       out=$(eval "$cmd")
+       ret=$?
+       rm -f "$tmpfile"
+       rm -f "$SHAREPATH/$filename"
+
+       if [ $ret != 0 ]; then
+               printf "%s\n" "$out"
+               printf "failed accessing veto_files share with error %s\n" "$ret"
+               return 1
+       fi
+
+       if [ "$expected_error" = "NT_STATUS_OK" ]; then
+               printf "%s" "$out" | grep -c "NT_STATUS_" && false
+       else
+               printf "%s" "$out" | grep "$expected_error"
+       fi
+       ret=$?
+       if [ $ret != 0 ]; then
+               printf "%s\n" "$out"
+               printf "failed - should get %s doing \"put %s\"\n" "$expected_error" "$filename"
+               return 1
+       fi
+}
+
 #
 # Using the share "[veto_files]" ensure we
 # cannot fetch a veto'd file or file in a veto'd directory.
@@ -133,6 +169,16 @@ test_get_veto_file()
        return 0
 }
 
+test_create_veto_file()
+{
+       # Test creating files
+       smbclient_create_expect_error "veto_name_file" "NT_STATUS_OBJECT_NAME_NOT_FOUND" || return 1
+       smbclient_create_expect_error "veto_name_dir/file_inside_dir" "NT_STATUS_OBJECT_PATH_NOT_FOUND" || return 1
+       smbclient_create_expect_error "dir1/veto_name_file" "NT_STATUS_OBJECT_NAME_NOT_FOUND" || return 1
+
+       return 0
+}
+
 do_cleanup
 
 # Using hash2, veto_name_file\"mangle == VHXE5P~M
@@ -194,6 +240,7 @@ touch "$SHAREPATH/dir1/dir2/dir3/veto_name_dir\"mangle/file_inside_dir"
 mkdir "$SHAREPATH/dir1/dir2/dir3/veto_name_dir\"mangle/testdir"
 touch "$SHAREPATH/dir1/dir2/dir3/veto_name_dir\"mangle/testdir/file_inside_dir"
 
+testit "create_veto_file" test_create_veto_file || failed=$((failed + 1))
 testit "get_veto_file" test_get_veto_file || failed=$(("$failed" + 1))
 
 do_cleanup