[PATCH] Add two more tests for substitutions

Jeremy Allison jra at samba.org
Wed Mar 15 17:53:08 UTC 2017


On Wed, Mar 15, 2017 at 01:12:12PM +0100, Andreas Schneider via samba-technical wrote:
> Hi,
> 
> attached are two tests to tests substitutions for the share path name and also 
> the 'template homedir'.
> 
> 
> Review and push much appreciated!

Great work Andreas, thanks for these ! RB+ and pushed.

> Thanks,
> 
> 
> 	Andreas
> 
> -- 
> Andreas Schneider                   GPG-ID: CC014E3D
> Samba Team                             asn at samba.org
> www.samba.org

> From 4b98c3a9f8764f49a2e2320f923edbff3bce7bd4 Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <asn at samba.org>
> Date: Wed, 15 Mar 2017 12:37:08 +0100
> Subject: [PATCH 1/2] s3:tests: Add a subsitution test for %D %u %g
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
>  selftest/target/Samba3.pm                  | 19 ++++++++++++++++++-
>  source3/script/tests/test_substitutions.sh |  9 +++++++--
>  2 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
> index d754b5f9ac1..d56b35e97ba 100755
> --- a/selftest/target/Samba3.pm
> +++ b/selftest/target/Samba3.pm
> @@ -394,16 +394,33 @@ sub setup_admember($$$$)
>  	$substitution_path = "$share_dir/D_SAMBADOMAIN/U_alice/G_domain users";
>  	push(@dirs, $substitution_path);
>  
> +	# Using '/' as the winbind separator is a bad idea ...
> +	$substitution_path = "$share_dir/D_SAMBADOMAIN/u_SAMBADOMAIN";
> +	push(@dirs, $substitution_path);
> +
> +	$substitution_path = "$share_dir/D_SAMBADOMAIN/u_SAMBADOMAIN/alice";
> +	push(@dirs, $substitution_path);
> +
> +	$substitution_path = "$share_dir/D_SAMBADOMAIN/u_SAMBADOMAIN/alice/g_SAMBADOMAIN";
> +	push(@dirs, $substitution_path);
> +
> +	$substitution_path = "$share_dir/D_SAMBADOMAIN/u_SAMBADOMAIN/alice/g_SAMBADOMAIN/domain users";
> +	push(@dirs, $substitution_path);
> +
>  	my $member_options = "
>  	security = ads
>          workgroup = $dcvars->{DOMAIN}
>          realm = $dcvars->{REALM}
>          netbios aliases = foo bar
>  
> -[subDUG]
> +[sub_dug]
>  	path = $share_dir/D_%D/U_%U/G_%G
>  	writeable = yes
>  
> +[sub_dug2]
> +	path = $share_dir/D_%D/u_%u/g_%g
> +	writeable = yes
> +
>  ";
>  
>  	my $ret = $self->provision($prefix,
> diff --git a/source3/script/tests/test_substitutions.sh b/source3/script/tests/test_substitutions.sh
> index 0852ad969f0..1a46f11c85d 100755
> --- a/source3/script/tests/test_substitutions.sh
> +++ b/source3/script/tests/test_substitutions.sh
> @@ -24,9 +24,14 @@ smbclient="$samba_bindir/smbclient"
>  . $samba_srcdir/testprogs/blackbox/subunit.sh
>  . $samba_srcdir/testprogs/blackbox/common_test_fns.inc
>  
> -SMB_UNC="//$SERVER/subDUG"
> +SMB_UNC="//$SERVER/sub_dug"
>  
> -test_smbclient "Test login to share with substitution" \
> +test_smbclient "Test login to share with substitution (DUG)" \
> +	"ls" "$SMB_UNC" "-U$USERNAME%$PASSWORD" || failed=$(expr $failed + 1)
> +
> +SMB_UNC="//$SERVER/sub_dug2"
> +
> +test_smbclient "Test login to share with substitution (Dug)" \
>  	"ls" "$SMB_UNC" "-U$USERNAME%$PASSWORD" || failed=$(expr $failed + 1)
>  
>  exit $failed
> -- 
> 2.12.0
> 
> 
> From 86c9c428bf873d1c1da25ce4c4e5f673fb1d51b3 Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <asn at samba.org>
> Date: Wed, 15 Mar 2017 13:04:43 +0100
> Subject: [PATCH 2/2] s3:tests: Also test the substitution of 'template
>  homedir'
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
>  selftest/target/Samba3.pm                  |  1 +
>  source3/script/tests/test_substitutions.sh | 26 +++++++++++++++++++-------
>  source3/selftest/tests.py                  |  2 +-
>  3 files changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
> index d56b35e97ba..74997b43c8f 100755
> --- a/selftest/target/Samba3.pm
> +++ b/selftest/target/Samba3.pm
> @@ -412,6 +412,7 @@ sub setup_admember($$$$)
>          workgroup = $dcvars->{DOMAIN}
>          realm = $dcvars->{REALM}
>          netbios aliases = foo bar
> +	template homedir = /home/%D/%G/%U
>  
>  [sub_dug]
>  	path = $share_dir/D_%D/U_%U/G_%G
> diff --git a/source3/script/tests/test_substitutions.sh b/source3/script/tests/test_substitutions.sh
> index 1a46f11c85d..5620097c22a 100755
> --- a/source3/script/tests/test_substitutions.sh
> +++ b/source3/script/tests/test_substitutions.sh
> @@ -5,33 +5,45 @@
>  
>  if [ $# -lt 4 ]; then
>  cat <<EOF
> -Usage: test_substitutions.sh SERVER USERNAME PASSWORD PREFIX
> +Usage: test_substitutions.sh SERVER DOMAIN USERNAME PASSWORD PREFIX
>  EOF
>  exit 1;
>  fi
>  
>  SERVER=$1
> -USERNAME=$2
> -PASSWORD=$3
> -PREFIX=$4
> -shift 4
> +DOMAIN=$2
> +USERNAME=$3
> +PASSWORD=$4
> +PREFIX=$5
> +shift 5
>  failed=0
>  
>  samba_bindir="$BINDIR"
>  samba_srcdir="$SRCDIR"
>  smbclient="$samba_bindir/smbclient"
> +wbinfo="$samba_bindir/wbinfo"
>  
>  . $samba_srcdir/testprogs/blackbox/subunit.sh
>  . $samba_srcdir/testprogs/blackbox/common_test_fns.inc
>  
> +test_wbinfo_template_homedir()
> +{
> +	user="$1"
> +	shift
> +
> +	$wbinfo -i $user | grep "/home/$DOMAIN/Domain Users/alice"
> +}
> +
>  SMB_UNC="//$SERVER/sub_dug"
>  
> -test_smbclient "Test login to share with substitution (DUG)" \
> +test_smbclient "Test login to share with substitution (sub_dug)" \
>  	"ls" "$SMB_UNC" "-U$USERNAME%$PASSWORD" || failed=$(expr $failed + 1)
>  
>  SMB_UNC="//$SERVER/sub_dug2"
>  
> -test_smbclient "Test login to share with substitution (Dug)" \
> +test_smbclient "Test login to share with substitution (sub_dug2)" \
>  	"ls" "$SMB_UNC" "-U$USERNAME%$PASSWORD" || failed=$(expr $failed + 1)
>  
> +testit "wbinfo -i $DOMAIN+alice" test_wbinfo_template_homedir $DOMAIN/alice || failed=$(expr $failed + 1)
> +
>  exit $failed
> diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
> index 54f5b7baa03..436576229ac 100755
> --- a/source3/selftest/tests.py
> +++ b/source3/selftest/tests.py
> @@ -181,7 +181,7 @@ t = "--krb5auth=$DOMAIN/$DC_USERNAME%$DC_PASSWORD"
>  plantestsuite("samba3.wbinfo_simple.(%s:local).%s" % (env, t), "%s:local" % env, [os.path.join(srcdir(), "nsswitch/tests/test_wbinfo_simple.sh"), t])
>  t = "WBCLIENT-MULTI-PING"
>  plantestsuite("samba3.smbtorture_s3.%s" % t, env, [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//foo/bar', '""', '""', smbtorture3, ""])
> -plantestsuite("samba3.substitutions", env, [os.path.join(samba3srcdir, "script/tests/test_substitutions.sh"), "$SERVER", "alice", "Secret007", "$PREFIX"])
> +plantestsuite("samba3.substitutions", env, [os.path.join(samba3srcdir, "script/tests/test_substitutions.sh"), "$SERVER", "$DOMAIN", "alice", "Secret007", "$PREFIX"])
>  
>  plantestsuite("samba3.ntlm_auth.krb5 with old ccache(ktest:local)", "ktest:local", [os.path.join(samba3srcdir, "script/tests/test_ntlm_auth_krb5.sh"), valgrindify(python), samba3srcdir, ntlm_auth3, '$PREFIX/ktest/krb5_ccache-2', '$SERVER', configuration])
>  
> -- 
> 2.12.0
> 




More information about the samba-technical mailing list