[PATCH] Add 'net rpc user' tests

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Add 'net rpc user' tests

Samba - samba-technical mailing list
Hi,

on Tuesday I thought that I found a bug in 'net rpc user password' but it
turned out it works just fine. However here is a test to confirm it.


This is also a really simple example how to write a blackbox test in our
environment.


Review and push much appreciated.


        Andreas

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add 'net rpc user' tests

Samba - samba-technical mailing list
On pe, 05 touko 2017, Andreas Schneider via samba-technical wrote:

> Hi,
>
> on Tuesday I thought that I found a bug in 'net rpc user password' but it
> turned out it works just fine. However here is a test to confirm it.
>
>
> This is also a really simple example how to write a blackbox test in our
> environment.
>
>
> Review and push much appreciated.
-ENOPATCH

--
/ Alexander Bokovoy

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add 'net rpc user' tests

Samba - samba-technical mailing list
On Friday, 5 May 2017 18:08:54 CEST Alexander Bokovoy wrote:

> On pe, 05 touko 2017, Andreas Schneider via samba-technical wrote:
> > Hi,
> >
> > on Tuesday I thought that I found a bug in 'net rpc user password' but it
> > turned out it works just fine. However here is a test to confirm it.
> >
> >
> > This is also a really simple example how to write a blackbox test in our
> > environment.
> >
> >
> > Review and push much appreciated.
>
> -ENOPATCH
Oops

0001-testprogs-Add-net-rpc-user-test-against-AD-DC.patch.txt (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add 'net rpc user' tests

Samba - samba-technical mailing list
On pe, 05 touko 2017, Andreas Schneider wrote:

> On Friday, 5 May 2017 18:08:54 CEST Alexander Bokovoy wrote:
> > On pe, 05 touko 2017, Andreas Schneider via samba-technical wrote:
> > > Hi,
> > >
> > > on Tuesday I thought that I found a bug in 'net rpc user password' but it
> > > turned out it works just fine. However here is a test to confirm it.
> > >
> > >
> > > This is also a really simple example how to write a blackbox test in our
> > > environment.
> > >
> > >
> > > Review and push much appreciated.
> >
> > -ENOPATCH
>
> Oops

> From ce5482172848b6a7d5130bed4e15ea70460bc9d4 Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <[hidden email]>
> Date: Tue, 2 May 2017 12:31:48 +0200
> Subject: [PATCH] testprogs: Add 'net rpc user' test against AD DC
>
> Signed-off-by: Andreas Schneider <[hidden email]>
> diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
> index 47d71d2..c173bea 100755
> --- a/source4/selftest/tests.py
> +++ b/source4/selftest/tests.py
> @@ -385,6 +385,7 @@ for env in ["ad_member", "s4member", "ad_dc_ntvfs", "chgdcpass"]:
>      plantestsuite("samba4.blackbox.smbclient(%s:local)" % env, "%s:local" % env, [os.path.join(samba4srcdir, "utils/tests/test_smbclient.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$DOMAIN', smbclient4])
>  
>  plantestsuite("samba4.blackbox.samba_tool(ad_dc_ntvfs:local)", "ad_dc_ntvfs:local", [os.path.join(samba4srcdir, "utils/tests/test_samba_tool.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$DOMAIN', smbclient4])
> +plantestsuite("samba4.blackbox.net_rpc_user(ad_dc)", "ad_dc", [os.path.join(bbdir, "test_net_rpc_user.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN'])
>  
>  if have_heimdal_support:
>      for env in ["ad_dc_ntvfs", "ad_dc"]:
> diff --git a/testprogs/blackbox/test_net_rpc_user.sh b/testprogs/blackbox/test_net_rpc_user.sh
> new file mode 100755
> index 0000000..91e7661
> --- /dev/null
> +++ b/testprogs/blackbox/test_net_rpc_user.sh
> @@ -0,0 +1,56 @@
> +#!/bin/sh
> +# Blackbox tests for 'net rpc'
> +#
> +# Copyright (c) 2017      Andreas Schneider <[hidden email]>
> +
> +if [ $# -lt 4 ]; then
> +cat << EOF
> +Usage: net_rpc.sh SERVER ADMIN_ACCOUNT ADMIN_PASSWORD
You pass and accept four arguments but 'Usage:' string only mentions
three.

--
/ Alexander Bokovoy

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add 'net rpc user' tests

Samba - samba-technical mailing list
On Monday, 8 May 2017 13:17:16 CEST Alexander Bokovoy via samba-technical
wrote:

> > +#!/bin/sh
> > +# Blackbox tests for 'net rpc'
> > +#
> > +# Copyright (c) 2017      Andreas Schneider <[hidden email]>
> > +
> > +if [ $# -lt 4 ]; then
> > +cat << EOF
> > +Usage: net_rpc.sh SERVER ADMIN_ACCOUNT ADMIN_PASSWORD
>
> You pass and accept four arguments but 'Usage:' string only mentions
> three.
Fixed, see attached patch.


Thanks for the review.


        Andreas

test_net_rpc_user.patch.txt (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add 'net rpc user' tests

Samba - samba-technical mailing list
On Tue, May 09, 2017 at 08:59:14AM +0200, Andreas Schneider via samba-technical wrote:

> On Monday, 8 May 2017 13:17:16 CEST Alexander Bokovoy via samba-technical
> wrote:
> > > +#!/bin/sh
> > > +# Blackbox tests for 'net rpc'
> > > +#
> > > +# Copyright (c) 2017      Andreas Schneider <[hidden email]>
> > > +
> > > +if [ $# -lt 4 ]; then
> > > +cat << EOF
> > > +Usage: net_rpc.sh SERVER ADMIN_ACCOUNT ADMIN_PASSWORD
> >
> > You pass and accept four arguments but 'Usage:' string only mentions
> > three.
>
> Fixed, see attached patch.
>
>
> Thanks for the review.

LGTM. Pushed !


> From 5a5985304ed892589e76364b1f524caf8d1af67e Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <[hidden email]>
> Date: Tue, 2 May 2017 12:31:48 +0200
> Subject: [PATCH] testprogs: Add 'net rpc user' test against AD DC
>
> Signed-off-by: Andreas Schneider <[hidden email]>
> ---
>  source4/selftest/tests.py               |  1 +
>  testprogs/blackbox/test_net_rpc_user.sh | 56 +++++++++++++++++++++++++++++++++
>  2 files changed, 57 insertions(+)
>  create mode 100755 testprogs/blackbox/test_net_rpc_user.sh
>
> diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
> index 47d71d2..c173bea 100755
> --- a/source4/selftest/tests.py
> +++ b/source4/selftest/tests.py
> @@ -385,6 +385,7 @@ for env in ["ad_member", "s4member", "ad_dc_ntvfs", "chgdcpass"]:
>      plantestsuite("samba4.blackbox.smbclient(%s:local)" % env, "%s:local" % env, [os.path.join(samba4srcdir, "utils/tests/test_smbclient.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$DOMAIN', smbclient4])
>  
>  plantestsuite("samba4.blackbox.samba_tool(ad_dc_ntvfs:local)", "ad_dc_ntvfs:local", [os.path.join(samba4srcdir, "utils/tests/test_samba_tool.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$DOMAIN', smbclient4])
> +plantestsuite("samba4.blackbox.net_rpc_user(ad_dc)", "ad_dc", [os.path.join(bbdir, "test_net_rpc_user.sh"), '$SERVER', '$USERNAME', '$PASSWORD', '$DOMAIN'])
>  
>  if have_heimdal_support:
>      for env in ["ad_dc_ntvfs", "ad_dc"]:
> diff --git a/testprogs/blackbox/test_net_rpc_user.sh b/testprogs/blackbox/test_net_rpc_user.sh
> new file mode 100755
> index 0000000..64ab01b
> --- /dev/null
> +++ b/testprogs/blackbox/test_net_rpc_user.sh
> @@ -0,0 +1,56 @@
> +#!/bin/sh
> +# Blackbox tests for 'net rpc'
> +#
> +# Copyright (c) 2017      Andreas Schneider <[hidden email]>
> +
> +if [ $# -lt 4 ]; then
> +cat << EOF
> +Usage: net_rpc.sh SERVER ADMIN_ACCOUNT ADMIN_PASSWORD ADMIN_DOMAIN
> +EOF
> +exit 1
> +fi
> +
> +SERVER=$1
> +ADMIN_ACCOUNT=$2
> +ADMIN_PASSWORD=$3
> +ADMIN_DOMAIN=$4
> +shift 4
> +
> +failed=0
> +samba_bindir="$BINDIR"
> +
> +samba_tool="$samba_bindir/samba-tool"
> +net_tool="$samba_bindir/net"
> +
> +TEST_USERNAME="$(mktemp -u samson-XXXXXX)"
> +TEST_PASSWORD="Passw0rd~01"
> +
> +newuser="$samba_tool user create"
> +
> +. `dirname $0`/subunit.sh
> +. `dirname $0`/common_test_fns.inc
> +
> +###########################################################
> +### Setup
> +###########################################################
> +
> +testit "net rpc user add" \
> + $VALGRIND $net_tool rpc user add $TEST_USERNAME $TEST_PASSWORD -U$ADMIN_ACCOUNT%$ADMIN_PASSWORD -S $SERVER || failed=$(expr $failed + 1)
> +
> +###########################################################
> +### Tests
> +###########################################################
> +
> +TEST_PASSWORD_NEW="Passw0rd~02"
> +
> +testit "net rpc user password" \
> + $VALGRIND $net_tool rpc user password $TEST_USERNAME $TEST_PASSWORD_NEW -U$ADMIN_ACCOUNT%$ADMIN_PASSWORD -S $SERVER || failed=$(expr $failed + 1)
> +
> +###########################################################
> +### Teardown
> +###########################################################
> +
> +testit "net rpc user delete" \
> + $VALGRIND $net_tool rpc user delete $TEST_USERNAME -U$ADMIN_ACCOUNT%$ADMIN_PASSWORD -S $SERVER || failed=$(expr $failed + 1)
> +
> +exit $failed
> --
> 2.9.3
>


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add 'net rpc user' tests

Samba - samba-technical mailing list
Am 11.05.17 um 02:03 schrieb Jeremy Allison via samba-technical:

> On Tue, May 09, 2017 at 08:59:14AM +0200, Andreas Schneider via samba-technical wrote:
>> On Monday, 8 May 2017 13:17:16 CEST Alexander Bokovoy via samba-technical
>> wrote:
>>>> +#!/bin/sh
>>>> +# Blackbox tests for 'net rpc'
>>>> +#
>>>> +# Copyright (c) 2017      Andreas Schneider <[hidden email]>
>>>> +
>>>> +if [ $# -lt 4 ]; then
>>>> +cat << EOF
>>>> +Usage: net_rpc.sh SERVER ADMIN_ACCOUNT ADMIN_PASSWORD
>>>
>>> You pass and accept four arguments but 'Usage:' string only mentions
>>> three.
>>
>> Fixed, see attached patch.
>>
>>
>> Thanks for the review.
>
> LGTM. Pushed !
>

Should a test not also check some assertions on the desired effects?
Just checking the return code seems a bit minimal to me. We could
replace the code of the net tool with the famous "Hello, World" code and
the test would still pass.

Cheers,
Christian




Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Add 'net rpc user' tests

Samba - samba-technical mailing list
On Fri, May 12, 2017 at 02:02:55PM +0200, Christian Ambach wrote:

> Am 11.05.17 um 02:03 schrieb Jeremy Allison via samba-technical:
> > On Tue, May 09, 2017 at 08:59:14AM +0200, Andreas Schneider via samba-technical wrote:
> >> On Monday, 8 May 2017 13:17:16 CEST Alexander Bokovoy via samba-technical
> >> wrote:
> >>>> +#!/bin/sh
> >>>> +# Blackbox tests for 'net rpc'
> >>>> +#
> >>>> +# Copyright (c) 2017      Andreas Schneider <[hidden email]>
> >>>> +
> >>>> +if [ $# -lt 4 ]; then
> >>>> +cat << EOF
> >>>> +Usage: net_rpc.sh SERVER ADMIN_ACCOUNT ADMIN_PASSWORD
> >>>
> >>> You pass and accept four arguments but 'Usage:' string only mentions
> >>> three.
> >>
> >> Fixed, see attached patch.
> >>
> >>
> >> Thanks for the review.
> >
> > LGTM. Pushed !
> >
>
> Should a test not also check some assertions on the desired effects?
> Just checking the return code seems a bit minimal to me. We could
> replace the code of the net tool with the famous "Hello, World" code and
> the test would still pass.

Yeah, but it's a start and a framework we can now build on :-).