[PATCH] Extend testsuite - added small test

Michael Adam obnox at samba.org
Tue Feb 16 15:51:32 UTC 2016


Hi Robin,

Thanks a lot for continuing to work on the test cases!
This is highly appreciated.

A few comments:

Not sure if it's only me, but in newly added shell script
code, we seem to
- prefer $(...) over `...` .
- prefer ${VARNAME} over $VARNAME

On the conceptual side, it seems strange to me that the test case
would modify the client config into a temporary working
directory each time. That sounds rather like we would expect
a special environment for this.

I am not sure if there is a precedent for this in other test
cases, and I don't have an alternative quick approach ready,
but ... dunno ... it feels awkward and kind of arbitrary and
fragile to have this in the test case itself.

Any other opinions / advice on this?

Thanks - Michael


On 2016-02-15 at 14:36 +0100, Robin Hack wrote:
> Hi.
> 
> I added one small test to samba3.blackbox.smbclient_auth.plain
> testsuite.
> 
> Test covers segfault of smbclient binary when
> client NTLMv2 auth = yes
> client use spnego = no
> options are used.
> 
> Code review is welcome.
> 
> Have nice day
> Robin Hack

> From 99f9ba4a2418dcc9825a19c1dc5ce277dfdaab75 Mon Sep 17 00:00:00 2001
> From: Robin Hack <rhack at redhat.com>
> Date: Mon, 15 Feb 2016 13:42:45 +0100
> Subject: [PATCH] samba3.blackbox.smbclient_auth.plain: Extend testsuite.
> 
> Test covers commit
> 96a49d23a4caebefcea66cfb855fadbae12ccf7c
> 
> Test covers segfault of smbclient binary when
> client NTLMv2 auth = yes
> client use spnego = no
> options are used.
> 
> BUG: none
> RH BUG: http://bugzilla.redhat.com/show_bug.cgi?id=1271763
> 
> How to test:
> $ make -j test TESTS="samba3.blackbox.smbclient_auth.plain"
> RESULD: Should PASS
       ^
       T

> $ git revert 96a49d23a4caebefcea66cfb855fadbae12ccf7c
> $ make -j test TESTS="samba3.blackbox.smbclient_auth.plain"
> RESULT: Should FAIL
> (and you can see segfault in dmesg)
> 
> Signed-off-by: Robin Hack <rhack at redhat.com>
> ---
>  source3/script/tests/test_smbclient_auth.sh | 25 ++++++++++++++++++++++++-
>  source3/selftest/tests.py                   | 10 +++++-----
>  2 files changed, 29 insertions(+), 6 deletions(-)
> 
> diff --git a/source3/script/tests/test_smbclient_auth.sh b/source3/script/tests/test_smbclient_auth.sh
> index 057414c..bcf6501 100755
> --- a/source3/script/tests/test_smbclient_auth.sh
> +++ b/source3/script/tests/test_smbclient_auth.sh
> @@ -15,7 +15,8 @@ USERNAME="$3"
>  PASSWORD="$4"
>  SMBCLIENT="$5"
>  SMBCLIENT="$VALGRIND ${SMBCLIENT}"
> -shift 5
> +BASEDIR="$6"
> +shift 6
>  ADDARGS="$*"
>  
>  incdir=`dirname $0`/../../../testprogs/blackbox
> @@ -31,3 +32,25 @@ testit "smbclient //$SERVER/forceuser_unixonly" $SMBCLIENT //$SERVER/forceuser_u
>  testit "smbclient //$SERVER/forceuser_wkngroup" $SMBCLIENT //$SERVER/forceuser_wkngroup $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 -c quit $ADDARGS
>  testit "smbclient //$SERVER/forcegroup" $SMBCLIENT //$SERVER/forcegroup $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 -c quit $ADDARGS
>  testit "smbclient //$SERVER/forcegroup as anon" $SMBCLIENT //$SERVER/forcegroup $CONFIGURATION -U% -I $SERVER_IP -p 139 -c quit $ADDARGS
> +
> +HOSTNAME=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | sha1sum | cut -b 1-10
> +RUNDIR=`pwd`
> +cd $BASEDIR
> +WORKDIR=`mktemp -d -p .`
> +WORKDIR=`basename $WORKDIR`
> +cp -a client/* $WORKDIR/
> +sed -ri "s@(dir|directory) = (.*)/client/@\1 = \2/$WORKDIR/@" $WORKDIR/client.conf
> +sed -ri "s/netbios name = .*/netbios name = $HOSTNAME/" $WORKDIR/client.conf
> +
> +# Add two config lines after [global] statement to config file
> +# Example:
> +# [global]
> +# client NTLMv2 auth = yes
> +# client use spnego = no
> +awk 'BEGIN { header_found = 0; }; /\[global\]/ { header_found = 1; }; (header_found == 1) { print $0; print "\tclient NTLMv2 auth = yes\n\tclient use spnego = no"; }; { if (header_found != 1) { print $0; }; header_found = 0; }' $WORKDIR/client.conf > $WORKDIR/client.conf.awked
> +mv $WORKDIR/client.conf.awked $WORKDIR/client.conf
> +
> +rm -f $WORKDIR/private/secrets.tdb
> +cd $RUNDIR
> +
> +testit "smbclient //$SERVER/tmp should not segfault" $SMBCLIENT -s $BASEDIR/$WORKDIR/client.conf //$SERVER/tmp $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 -c quit $ADDARGS
> diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
> index b2bae75..601dcf4 100755
> --- a/source3/selftest/tests.py
> +++ b/source3/selftest/tests.py
> @@ -127,14 +127,14 @@ plantestsuite("samba.vfstest.catia", "nt4_dc:local", [os.path.join(samba3srcdir,
>  
>  for options in ["--option=clientusespnego=no", " --option=clientntlmv2auth=no --option=clientlanmanauth=yes --max-protocol=LANMAN2", ""]:
>      env = "nt4_dc"
> -    plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) %s" % (env, options), env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', smbclient3, configuration, options])
> +    plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) %s" % (env, options), env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', smbclient3, '$PREFIX_ABS', configuration, options])
>  
>  for env in ["nt4_dc", "nt4_member", "ad_member", "ad_dc_ntvfs", "s4member"]:
>      plantestsuite("samba3.blackbox.smbclient_machine_auth.plain (%s:local)" % env, "%s:local" % env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_machine_auth.sh"), '$SERVER', smbclient3, configuration])
>  
>  for env in ["nt4_dc", "nt4_member", "ad_member"]:
> -    plantestsuite("samba3.blackbox.smbclient_auth.plain (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', smbclient3, configuration])
> -    plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) member creds" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$SERVER/$USERNAME', '$PASSWORD', smbclient3, configuration])
> +    plantestsuite("samba3.blackbox.smbclient_auth.plain (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', smbclient3, '$PREFIX_ABS', configuration])
> +    plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) member creds" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$SERVER/$USERNAME', '$PASSWORD', smbclient3, '$PREFIX_ABS', configuration])
>  
>  for env in ["nt4_member", "ad_member"]:
>      plantestsuite("samba3.blackbox.net_cred_change.(%s:local)" % env, "%s:local" % env, [os.path.join(samba3srcdir, "script/tests/test_net_cred_change.sh"), configuration])
> @@ -152,10 +152,10 @@ plantestsuite("samba3.ntlm_auth.krb5(ktest:local)", "ktest:local", [os.path.join
>  
>  
>  for env in ["maptoguest", "simpleserver"]:
> -    plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) local creds" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', smbclient3, configuration + " --option=clientntlmv2auth=no --option=clientlanmanauth=yes"])
> +    plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) local creds" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', smbclient3, '$PREFIX_ABS', configuration + " --option=clientntlmv2auth=no --option=clientlanmanauth=yes"])
>  
>  env = "maptoguest"
> -plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) bad username" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', 'notmy$USERNAME', '$PASSWORD', smbclient3, configuration + " --option=clientntlmv2auth=no --option=clientlanmanauth=yes"])
> +plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) bad username" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', 'notmy$USERNAME', '$PASSWORD', smbclient3, '$PREFIX_ABS', configuration + " --option=clientntlmv2auth=no --option=clientlanmanauth=yes"])
>  
>  # plain
>  for env in ["nt4_dc"]:
> -- 
> 1.9.3
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160216/5f76f932/signature.sig>


More information about the samba-technical mailing list