mirror of
https://github.com/samba-team/samba.git
synced 2025-02-25 17:57:42 +03:00
tests: Add a test for the idmap_nss : use_upn setting
Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Samuel Cabrero <scabrero@samba.org> Autobuild-Date(master): Wed Dec 13 16:05:19 UTC 2023 on atb-devel-224
This commit is contained in:
parent
086a90d52b
commit
3a01ef710d
79
nsswitch/tests/test_idmap_nss_use_upn.sh
Executable file
79
nsswitch/tests/test_idmap_nss_use_upn.sh
Executable file
@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
|
||||
wbinfo="$BINDIR/wbinfo"
|
||||
smbcontrol="$BINDIR/smbcontrol"
|
||||
net="$BINDIR/net"
|
||||
global_inject_conf=$(dirname $SMB_CONF_PATH)/global_inject.conf
|
||||
|
||||
failed=0
|
||||
|
||||
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
|
||||
|
||||
# Reset idmap_nss configuration and clear cache
|
||||
echo "idmap config $DOMAIN : use_upn = no" >$global_inject_conf
|
||||
$smbcontrol winbindd reload-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not reload config" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
fi
|
||||
|
||||
$net cache flush
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not flush cache" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
fi
|
||||
|
||||
# Get the user SID
|
||||
USER="bob"
|
||||
USER_SID=$($wbinfo --name-to-sid="$USER")
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not find SID for user '$USER'" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
USER_SID=$(echo $USER_SID | cut -d " " -f 1)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not find SID for user '$USER'" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
testit "SID to UID (use_upn = no)" $wbinfo --sid-to-uid=${USER_SID} || failed=$(expr $failed + 1)
|
||||
|
||||
echo "idmap config $DOMAIN : use_upn = yes" >$global_inject_conf
|
||||
$smbcontrol winbindd reload-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not reload config" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
fi
|
||||
|
||||
$net cache flush
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not flush cache" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
fi
|
||||
|
||||
# The following test will fail because idmap_nss will search ADDOMAIN/bob, which does not
|
||||
# exists in NSS_WRAPPER_PASSWD
|
||||
testit_expect_failure "SID to UID (use_upn = yes)" $wbinfo --sid-to-uid=${USER_SID} || failed=$(expr $failed + 1)
|
||||
|
||||
$net cache flush
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not flush cache" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
fi
|
||||
|
||||
# Add the ADDOMAIN/bob temporarily
|
||||
ENTRY="$(getent passwd bob)"
|
||||
ENTRY="$DOMAIN/${ENTRY}"
|
||||
sed -i "1i ${ENTRY}" $NSS_WRAPPER_PASSWD
|
||||
testit "Get user UID (use_upn = yes)" $wbinfo --sid-to-uid=${USER_SID} || failed=$(expr $failed + 1)
|
||||
sed -i "1d" $NSS_WRAPPER_PASSWD
|
||||
|
||||
# Reset config
|
||||
echo "idmap config $DOMAIN : use_upn = no" >$global_inject_conf
|
||||
$smbcontrol winbindd reload-config
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not reload config" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
fi
|
||||
|
||||
$net cache flush
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not flush cache" | subunit_fail_test "test_idmap_nss_use_upn"
|
||||
fi
|
||||
|
||||
exit $failed
|
@ -1106,7 +1106,7 @@ rpc = ["rpc.authcontext",
|
||||
|
||||
local = ["local.nss"]
|
||||
|
||||
idmap = ["idmap.rfc2307", "idmap.alloc", "idmap.rid", "idmap.ad"]
|
||||
idmap = ["idmap.rfc2307", "idmap.alloc", "idmap.rid", "idmap.ad", "idmap.nss"]
|
||||
|
||||
rap = ["rap.basic", "rap.rpc", "rap.printing", "rap.sam"]
|
||||
|
||||
@ -1217,6 +1217,8 @@ for t in tests:
|
||||
'$DC_SERVER', '$DC_USERNAME', '$DC_PASSWORD'])
|
||||
elif t == "idmap.alloc":
|
||||
plantestsuite(t, "ad_member_rfc2307", [os.path.join(samba3srcdir, "../nsswitch/tests/test_idmap_nss.sh"), '$DOMAIN'])
|
||||
elif t == "idmap.nss":
|
||||
plantestsuite(t, "ad_member_idmap_nss:local", [os.path.join(samba3srcdir, "../nsswitch/tests/test_idmap_nss_use_upn.sh")])
|
||||
elif t == "idmap.rid":
|
||||
plantestsuite(t, "ad_member_idmap_rid", [os.path.join(samba3srcdir, "../nsswitch/tests/test_idmap_rid.sh"), '$DOMAIN', '2000000'])
|
||||
plantestsuite(t,
|
||||
|
Loading…
x
Reference in New Issue
Block a user