mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
pytest: samba-tool ntacl should report errors better
We want `samba-tool ntacl sysvolreset` and `samba-tool ntacl sysvolcheck` to fail when the Policies folder is not in place, but not to produce an inscrutable stacktrace. https://bugzilla.samba.org/show_bug.cgi?id=14937 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
8400228141
commit
8df9fdc551
@ -22,6 +22,7 @@ import os
|
||||
import time
|
||||
import ldb
|
||||
from samba.tests.samba_tool.base import SambaToolCmdTest
|
||||
from samba.tests import env_loadparm
|
||||
import random
|
||||
|
||||
|
||||
@ -69,6 +70,32 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest):
|
||||
self.assertEqual(err, "", "Shouldn't be any error messages")
|
||||
self.assertEqual(out, "", "Shouldn't be any output messages")
|
||||
|
||||
def test_with_missing_files(self):
|
||||
lp = env_loadparm()
|
||||
sysvol = lp.get('path', 'sysvol')
|
||||
realm = lp.get('realm').lower()
|
||||
|
||||
src = os.path.join(sysvol, realm, 'Policies')
|
||||
dest = os.path.join(sysvol, realm, 'Policies-NOT-IN-THE-EXPECTED-PLACE')
|
||||
try:
|
||||
os.rename(src, dest)
|
||||
|
||||
for args in (["sysvolreset", "--use-s3fs"],
|
||||
["sysvolreset", "--use-ntvfs"],
|
||||
["sysvolreset"],
|
||||
["sysvolcheck"]
|
||||
):
|
||||
|
||||
(result, out, err) = self.runsubcmd("ntacl", *args)
|
||||
self.assertCmdFail(result, f"succeeded with {args} with missing dir")
|
||||
self.assertNotIn("uncaught exception", err,
|
||||
"Shouldn't be uncaught exception")
|
||||
self.assertNotRegex(err, '^\s*File [^,]+, line \d+, in',
|
||||
"Shouldn't be lines of traceback")
|
||||
self.assertEqual(out, "", "Shouldn't be any output messages")
|
||||
finally:
|
||||
os.rename(dest, src)
|
||||
|
||||
|
||||
class NtACLCmdGetSetTestCase(SambaToolCmdTest):
|
||||
"""Tests for samba-tool ntacl get/set subcommands"""
|
||||
|
1
selftest/knownfail.d/samba-tool-ntacl
Normal file
1
selftest/knownfail.d/samba-tool-ntacl
Normal file
@ -0,0 +1 @@
|
||||
^samba.tests.samba_tool.ntacl.+test_with_missing_files
|
Loading…
x
Reference in New Issue
Block a user