libsmb: Simplify an if-condition
[Samba.git] / testprogs / blackbox / test_weak_crypto.sh
blobe938bb0b0ab5685ff5f52b2388667a4cc1d7a900
1 #!/bin/sh
4 # Blackbox tests for weak crypto
5 # Copyright (c) 2020 Andreas Schneider <asn@samba.org>
8 if [ $# -lt 6 ]; then
9 cat <<EOF
10 Usage: $0 SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
11 EOF
12 exit 1
15 SERVER=$1
16 USERNAME=$2
17 PASSWORD=$3
18 REALM=$4
19 DOMAIN=$5
20 PREFIX=$6
21 shift 6
23 failed=0
24 . $(dirname $0)/subunit.sh
26 samba_bindir="$BINDIR"
27 samba_testparm="$BINDIR/testparm"
28 samba_rpcclient="$samba_bindir/rpcclient"
30 opt="--option=gensec:gse_krb5=no -U${USERNAME}%${PASSWORD}"
32 unset GNUTLS_FORCE_FIPS_MODE
34 # Checks that testparm reports: Weak crypto is allowed
35 testit_grep "testparm" "Weak crypto is allowed" $samba_testparm --suppress-prompt $SMB_CONF_PATH 2>&1 || failed=$(expr $failed + 1)
37 # We should be allowed to use NTLM for connecting
38 testit "rpclient.ntlm" $samba_rpcclient ncacn_np:$SERVER $opt -c "getusername" || failed=$(expr $failed + 1)
40 GNUTLS_FORCE_FIPS_MODE=1
41 export GNUTLS_FORCE_FIPS_MODE
43 # Checks that testparm reports: Weak crypto is disallowed
44 testit_grep "testparm" "Weak crypto is disallowed" $samba_testparm --suppress-prompt $SMB_CONF_PATH 2>&1 || failed=$(expr $failed + 1)
46 # We should not be allowed to use NTLM for connecting
47 testit_expect_failure "rpclient.ntlm" $samba_rpcclient ncacn_np:$SERVER $opt -c "getusername" || failed=$(expr $failed + 1)
49 unset GNUTLS_FORCE_FIPS_MODE
51 exit $failed