diff options
author | Garming Sam <garming@catalyst.net.nz> | 2014-11-25 16:52:53 +1300 |
---|---|---|
committer | Garming Sam <garming@samba.org> | 2014-11-27 05:16:53 +0100 |
commit | 9cef81db97968f8d69bdae19e8a091225ae86207 (patch) | |
tree | 7f336a59a83db072487cceba3d892ee689454556 | |
parent | 5adc171ffe8b5d4d7ba280aa93414921d29b383d (diff) | |
download | samba-9cef81db97968f8d69bdae19e8a091225ae86207.tar.gz |
wbinfo: create a more comprehensive test for sids2xids
In particular, this tests that ID_TYPE_BOTH is cached correctly.
Change-Id: I2475f22d3f4506c93b15d82b0d337d3729bbbd4c
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Garming Sam <garming@samba.org>
Autobuild-Date(master): Thu Nov 27 05:16:53 CET 2014 on sn-devel-104
-rw-r--r-- | selftest/knownfail | 2 | ||||
-rwxr-xr-x | source3/script/tests/test_wbinfo_sids2xids_int.py | 86 |
2 files changed, 73 insertions, 15 deletions
diff --git a/selftest/knownfail b/selftest/knownfail index 1c4f446129a..e9e62396d82 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -230,6 +230,8 @@ ^samba3.rpc.spoolss.printer.addprinterex.driver_info_winreg # knownfail or flapping? ^samba3.rpc.spoolss.printer.*.publish_toggle\(.*\)$ # needs spoolss AD member env ^samba3.rpc.spoolss.printserver.*.add_processor\(.*\)$ +^samba.wbinfo_sids2xids.\(plugin_s4_dc:local\) +^samba.wbinfo_sids2xids.\(s4member:local\) # # The following tests fail against plugin_s4_dc (aka s3fs) currently. # These need to be examined and either fixed or correctly categorised. diff --git a/source3/script/tests/test_wbinfo_sids2xids_int.py b/source3/script/tests/test_wbinfo_sids2xids_int.py index b26f6d62e9e..f3dbed8a6ea 100755 --- a/source3/script/tests/test_wbinfo_sids2xids_int.py +++ b/source3/script/tests/test_wbinfo_sids2xids_int.py @@ -11,7 +11,14 @@ wbinfo = sys.argv[1] netcmd = sys.argv[2] def flush_cache(): - os.system(netcmd + "cache flush") + os.system(netcmd + " cache flush") + +def fill_cache(inids, idtype='gid'): + for inid in inids: + if inid is None: + continue + subprocess.Popen([wbinfo, '--%s-to-sid=%s' % (idtype, inid)], + stdout=subprocess.PIPE).communicate() domain = subprocess.Popen([wbinfo, "--own-domain"], stdout=subprocess.PIPE).communicate()[0].strip() @@ -30,35 +37,84 @@ sids2xids = subprocess.Popen([wbinfo, '--sids-to-unix-ids=' + ','.join(sids)], stdout=subprocess.PIPE).communicate()[0].strip() gids=[] +uids=[] +idtypes = [] for line in sids2xids.split('\n'): result = line.split(' ')[2:] + idtypes.append(result[0]) - if result[0] == 'gid' or result[0] == 'uid/gid': + gid = None + uid = None + if result[0] == 'gid': gid = result[1] - else: - gid = '' + elif result[0] == 'uid': + uid = result[1] + elif result[0] == 'uid/gid': + gid = result[1] + uid = result[1] + if gid == '-1': gid = '' gids.append(gid) + if uid == '-1': + uid = '' + uids.append(uid) + # Check the list produced by the sids-to-xids call with the -# singular variant (sid-to-gid) for each sid in turn. -def check_singular(sids, gids): - i=0 +# singular variant (sid-to-xid) for each sid in turn. +def check_singular(sids, ids, idtype='gid'): + i = 0 for sid in sids: - gid = subprocess.Popen([wbinfo, '--sid-to-gid', sid], - stdout=subprocess.PIPE).communicate()[0].strip() - if gid != gids[i]: - print "Expected %s, got %s\n", gid, gids[i] + if ids[i] is None: + continue + + outid = subprocess.Popen([wbinfo, '--sid-to-%s' % idtype, sid], + stdout=subprocess.PIPE).communicate()[0].strip() + if outid != ids[i]: + print "Expected %s, got %s\n" % (outid, ids[i]) + flush_cache() + sys.exit(1) + i += 1 + +# Check the list produced by the sids-to-xids call with the +# multiple variant (sid-to-xid) for each sid in turn. +def check_multiple(sids, idtypes): + sids2xids = subprocess.Popen([wbinfo, '--sids-to-unix-ids=' + ','.join(sids)], + stdout=subprocess.PIPE).communicate()[0].strip() + # print sids2xids + i = 0 + for line in sids2xids.split('\n'): + result = line.split(' ')[2:] + + if result[0] != idtypes[i]: + print "Expected %s, got %s\n" % (idtypes[i], result[0]) + flush_cache() sys.exit(1) - i+=1 + i += 1 -# first round: with filled cache -check_singular(sids, gids) +# first round: with filled cache via sid-to-id +check_singular(sids, gids, 'gid') +check_singular(sids, uids, 'uid') # second round: with empty cache flush_cache() -check_singular(sids, gids) +check_singular(sids, gids, 'gid') +flush_cache() +check_singular(sids, uids, 'uid') + +# third round: with filled cache via uid-to-sid +flush_cache() +fill_cache(uids, 'uid') +check_multiple(sids, idtypes) + +# fourth round: with filled cache via gid-to-sid +flush_cache() +fill_cache(gids, 'gid') +check_multiple(sids, idtypes) + +# flush the cache so any incorrect mappings don't break other tests +flush_cache() sys.exit(0) |