testprogs: Make test_smbclient_expect_failure() return 0 on success
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Tue, 11 Apr 2023 02:23:00 +0000 (14:23 +1200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 12 Apr 2023 13:52:32 +0000 (13:52 +0000)
This is the behaviour that most existing callers expect, but the
function actually returns a non-zero status code in that case.

Adjust all callers expecting the opposite behaviour to match.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
testprogs/blackbox/common_test_fns.inc
testprogs/blackbox/test_password_settings.sh
testprogs/blackbox/test_trust_ntlm.sh

index 5984a0c91a265aa9035c2fe4bd5d95d2858c2292..4f5a861754e96f6cfedc5b604ae6affef914726b 100755 (executable)
@@ -33,10 +33,11 @@ test_smbclient_expect_failure()
        status=$?
        if [ x$status = x0 ]; then
                printf '%s' "$output" | subunit_fail_test "$name"
+               return 1
        else
                subunit_pass_test "$name"
+               return 0
        fi
-       return $status
 }
 
 test_rpcclient_grep()
index 9e7ea29cf621e1d46026f57d09d9e695fbfe574f..b3b23f6843da8173027ea2a6731c739f2c16cd41 100755 (executable)
@@ -171,7 +171,7 @@ TEST_PASSWORD=$TEST_PASSWORD_NEW
 TEST_PASSWORD_NEW="testPaSS@04%"
 
 test_smbclient_expect_failure "Test login with user (NT_STATUS_PASSWORD_MUST_CHANGE)" \
-       "ls" "$SMB_UNC" --use-kerberos=disabled -U$TEST_PRINCIPAL%$TEST_PASSWORD && failed=$(expr $failed + 1)
+       "ls" "$SMB_UNC" --use-kerberos=disabled -U$TEST_PRINCIPAL%$TEST_PASSWORD || failed=$(expr $failed + 1)
 
 testit "change user password with 'samba-tool user password' (after must change flag set)" \
        $VALGRIND $PYTHON $samba_tool user password "${CONFIGURATION}" -W$DOMAIN -U$DOMAIN/$TEST_USERNAME%$TEST_PASSWORD -k no --newpassword=$TEST_PASSWORD_NEW || failed=$(expr $failed + 1)
index 5fde96b9da19e0810f796ef9e75bcb7b545ceef0..ae84aebd85bf80ceeccfaab9f1b5c30b50f89b6c 100755 (executable)
@@ -72,7 +72,7 @@ if [ x"$TYPE" = x"member" ]; then
        EXPFAIL="NT_STATUS_LOGON_FAILURE"
        # rpcclient doesn't handle -Uuser@domain yet
        #test_rpcclient_expect_failure_grep "Fail03 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS && failed=`expr $failed + 1`
-       test_smbclient_expect_failure "Fail03 smbclient with $CREDS" 'ls' "$unc" -U$CREDS && failed=$(expr $failed + 1)
+       test_smbclient_expect_failure "Fail03 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
        # winbindd doesn't handle user@domain yet
        #testit_expect_failure "Fail03 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
 else
@@ -90,7 +90,7 @@ if [ x"$TYPE" = x"member" ]; then
        EXPFAIL="NT_STATUS_LOGON_FAILURE"
        # rpcclient doesn't handle -Uuser@domain yet
        #test_rpcclient_expect_failure_grep "Fail04 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS && failed=`expr $failed + 1`
-       test_smbclient_expect_failure "Fail04 smbclient with $CREDS" 'ls' "$unc" -U$CREDS && failed=$(expr $failed + 1)
+       test_smbclient_expect_failure "Fail04 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
        # winbindd doesn't handle user@domain yet
        #testit_expect_failure "Fail04 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
 else
@@ -121,7 +121,7 @@ CREDS="$TRUST_DOMAIN\\$USERNAME%$PASSWORD"
 WBCREDS="$TRUST_DOMAIN/$USERNAME%$PASSWORD"
 EXPFAIL="$TRUST_ERROR"
 test_rpcclient_expect_failure_grep "Fail06 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS && failed=$(expr $failed + 1)
-test_smbclient_expect_failure "Fail06 smbclient with $CREDS" 'ls' "$unc" -U$CREDS && failed=$(expr $failed + 1)
+test_smbclient_expect_failure "Fail06 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
 testit_expect_failure "Fail06 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=$(expr $failed + 1)
 
 DNAME="$TRUST_DOMAIN"
@@ -161,7 +161,7 @@ if [ x"$TRUST_REALM" = x"$TRUST_DOMAIN" ]; then
        EXPFAIL="NT_STATUS_LOGON_FAILURE"
        # rpcclient doesn't handle -Uuser@domain yet
        #test_rpcclient_expect_failure_grep "Fail09 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS && failed=`expr $failed + 1`
-       test_smbclient_expect_failure "Fail09 smbclient with $CREDS" 'ls' "$unc" -U$CREDS && failed=$(expr $failed + 1)
+       test_smbclient_expect_failure "Fail09 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
        # winbindd doesn't handle user@domain yet
        #testit_expect_failure "Fail09 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
 else
@@ -180,7 +180,7 @@ if [ x"$TRUST_REALM" = x"$TRUST_DOMAIN" ]; then
        EXPFAIL="NT_STATUS_LOGON_FAILURE"
        # rpcclient doesn't handle -Uuser@domain yet
        #test_rpcclient_expect_failure_grep "Fail10 rpcclient getusername with $CREDS" getusername "$SERVER" "$EXPFAIL" -U$CREDS && failed=`expr $failed + 1`
-       test_smbclient_expect_failure "Fail10 smbclient with $CREDS" 'ls' "$unc" -U$CREDS && failed=$(expr $failed + 1)
+       test_smbclient_expect_failure "Fail10 smbclient with $CREDS" 'ls' "$unc" -U$CREDS || failed=$(expr $failed + 1)
        # winbindd doesn't handle user@domain yet
        #testit_expect_failure "Fail10 wbinfo -a with $WBCREDS" $VALGRIND $wbinfo -a $WBCREDS || failed=`expr $failed + 1`
 else