1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

testprogs: Use random usernames for export keytab tests

This avoids that subsequent tests because users already exist and cleanup didn't
work.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2023-02-08 08:30:38 +01:00 committed by Andrew Bartlett
parent 93c7bbf4d2
commit 5595765d4e
2 changed files with 11 additions and 10 deletions

View File

@ -59,10 +59,11 @@ test_keytab()
return 0 return 0
} }
TEST_USER="$(mktemp -u keytabtestuserXXXXXX)"
USERPASS=testPaSS@01% USERPASS=testPaSS@01%
unc="//$SERVER/tmp" unc="//$SERVER/tmp"
testit "create user locally" $VALGRIND $PYTHON $newuser nettestuser $USERPASS "$@" || failed=$(expr $failed + 1) testit "create user locally" $VALGRIND $PYTHON $newuser ${TEST_USER} $USERPASS "$@" || failed=$(expr $failed + 1)
testit "dump keytab from domain" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab "$@" || failed=$(expr $failed + 1) testit "dump keytab from domain" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab "$@" || failed=$(expr $failed + 1)
test_keytab "read keytab from domain" "$PREFIX/tmpkeytab" "$SERVER\\\$" 3 test_keytab "read keytab from domain" "$PREFIX/tmpkeytab" "$SERVER\\\$" 3
@ -76,11 +77,11 @@ testit "dump keytab from domain for cifs principal (2nd time)" $VALGRIND $PYTHON
$samba_tool domain exportkeytab $PREFIX/tmpkeytab-server --principal=cifs/$SERVER_FQDN "$@" || failed=$(expr $failed + 1) $samba_tool domain exportkeytab $PREFIX/tmpkeytab-server --principal=cifs/$SERVER_FQDN "$@" || failed=$(expr $failed + 1)
test_keytab "read keytab from domain for cifs principal (2nd time)" "$PREFIX/tmpkeytab-server" "cifs/$SERVER_FQDN" 3 test_keytab "read keytab from domain for cifs principal (2nd time)" "$PREFIX/tmpkeytab-server" "cifs/$SERVER_FQDN" 3
testit "dump keytab from domain for user principal" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-2 --principal=nettestuser "$@" || failed=$(expr $failed + 1) testit "dump keytab from domain for user principal" $VALGRIND $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-2 --principal=${TEST_USER} "$@" || failed=$(expr $failed + 1)
test_keytab "dump keytab from domain for user principal" "$PREFIX/tmpkeytab-2" "nettestuser@$REALM" 3 test_keytab "dump keytab from domain for user principal" "$PREFIX/tmpkeytab-2" "${TEST_USER}@$REALM" 3
testit "dump keytab from domain for user principal (2nd time)" $VALGRIND $PYTHON testit "dump keytab from domain for user principal (2nd time)" $VALGRIND $PYTHON
$samba_tool domain exportkeytab $PREFIX/tmpkeytab-2 --principal=nettestuser@$REALM "$@" || failed=$(expr $failed + 1) $samba_tool domain exportkeytab $PREFIX/tmpkeytab-2 --principal=${TEST_USER}@$REALM "$@" || failed=$(expr $failed + 1)
test_keytab "dump keytab from domain for user principal (2nd time)" "$PREFIX/tmpkeytab-2" "nettestuser@$REALM" 3 test_keytab "dump keytab from domain for user principal (2nd time)" "$PREFIX/tmpkeytab-2" "${TEST_USER}@$REALM" 3
testit "dump keytab from domain for user principal with SPN as UPN" $VALGRIND testit "dump keytab from domain for user principal with SPN as UPN" $VALGRIND
$PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-3 --principal=http/testupnspn.$DNSDOMAIN "$@" || failed=$(expr $failed + 1) $PYTHON $samba_tool domain exportkeytab $PREFIX/tmpkeytab-3 --principal=http/testupnspn.$DNSDOMAIN "$@" || failed=$(expr $failed + 1)
@ -90,11 +91,11 @@ KRB5CCNAME="$PREFIX/tmpuserccache"
samba4kinit="$samba4kinit_binary -c $KRB5CCNAME" samba4kinit="$samba4kinit_binary -c $KRB5CCNAME"
export KRB5CCNAME export KRB5CCNAME
testit "kinit with keytab as user" $VALGRIND $samba4kinit --keytab=$PREFIX/tmpkeytab --request-pac nettestuser@$REALM || failed=$(expr $failed + 1) testit "kinit with keytab as user" $VALGRIND $samba4kinit --keytab=$PREFIX/tmpkeytab --request-pac ${TEST_USER}@$REALM || failed=$(expr $failed + 1)
test_smbclient "Test login with user kerberos ccache" 'ls' "$unc" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1) test_smbclient "Test login with user kerberos ccache" 'ls' "$unc" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
testit "kinit with keytab as user (2)" $VALGRIND $samba4kinit --keytab=$PREFIX/tmpkeytab-2 --request-pac nettestuser@$REALM || failed=$(expr $failed + 1) testit "kinit with keytab as user (2)" $VALGRIND $samba4kinit --keytab=$PREFIX/tmpkeytab-2 --request-pac ${TEST_USER}@$REALM || failed=$(expr $failed + 1)
test_smbclient "Test login with user kerberos ccache as user (2)" 'ls' "$unc" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1) test_smbclient "Test login with user kerberos ccache as user (2)" 'ls' "$unc" --use-krb5-ccache=$KRB5CCNAME || failed=$(expr $failed + 1)
@ -113,7 +114,7 @@ KRB5CCNAME="$PREFIX/tmpadminccache"
samba4kinit="$samba4kinit_binary -c $KRB5CCNAME" samba4kinit="$samba4kinit_binary -c $KRB5CCNAME"
export KRB5CCNAME export KRB5CCNAME
testit "del user" $VALGRIND $PYTHON $samba_tool user delete nettestuser -k yes "$@" || failed=$(expr $failed + 1) testit "del user" $VALGRIND $PYTHON $samba_tool user delete ${TEST_USER} -k yes "$@" || failed=$(expr $failed + 1)
rm -f $PREFIX/tmpadminccache $PREFIX/tmpuserccache $PREFIX/tmpkeytab $PREFIX/tmpkeytab-2 $PREFIX/tmpkeytab-2 $PREFIX/tmpkeytab-server $PREFIX/tmpspnupnccache rm -f $PREFIX/tmpadminccache $PREFIX/tmpuserccache $PREFIX/tmpkeytab $PREFIX/tmpkeytab-2 $PREFIX/tmpkeytab-2 $PREFIX/tmpkeytab-server $PREFIX/tmpspnupnccache
exit $failed exit $failed

View File

@ -76,7 +76,7 @@ test_keytab()
return 0 return 0
} }
TEST_USER=nettestuser TEST_USER="$(mktemp -u keytabtestuserXXXXXX)"
TEST_PASSWORD=testPaSS@01% TEST_PASSWORD=testPaSS@01%
EXPECTED_NKEYS=3 EXPECTED_NKEYS=3
@ -129,7 +129,7 @@ echo "$samba_kinit -k -t $PREFIX/tmpkeytab-server cifs/$SERVER_FQDN"
testit "kinit with SPN from keytab" $VALGRIND $samba_kinit -k -t $PREFIX/tmpkeytab-server cifs/$SERVER_FQDN || failed=$(expr $failed + 1) testit "kinit with SPN from keytab" $VALGRIND $samba_kinit -k -t $PREFIX/tmpkeytab-server cifs/$SERVER_FQDN || failed=$(expr $failed + 1)
# cleanup # cleanup
testit "delete user $TEST_USER" $VALGRIND $PYTHON $samba_tool user delete nettestuser --use-krb5-ccache="${KRB5CCNAME}" "$@" || failed=$(expr $failed + 1) testit "delete user $TEST_USER" $VALGRIND $PYTHON $samba_tool user delete "${TEST_USER}" --use-krb5-ccache="${KRB5CCNAME}" "$@" || failed=$(expr $failed + 1)
$samba_kdestroy $samba_kdestroy
rm -f $PREFIX/tmpadminccache $PREFIX/tmpuserccache $PREFIX/tmpkeytab $PREFIX/tmpkeytab-2 $PREFIX/tmpkeytab-server rm -f $PREFIX/tmpadminccache $PREFIX/tmpuserccache $PREFIX/tmpkeytab $PREFIX/tmpkeytab-2 $PREFIX/tmpkeytab-server