1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-17 04:23:50 +03:00

pytest: sddl strings dir can be defined in class

Before we had to do this in an environment variable. In that case we
are probably wanting to monitor changes, so we like it to print more
messages than we want to see in an autobuild run that will hopefully
never do anything interesting.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall
2023-09-07 15:27:21 +12:00
committed by Andrew Bartlett
parent 2f30103f92
commit 2a4fc3fedf

View File

@@ -31,6 +31,10 @@ class SddlDecodeEncodeBase(TestCase):
def setUpDynamicTestCases(cls):
cls.domain_sid = security.dom_sid("S-1-2-3-4")
strings_dir = getattr(cls, 'strings_dir', None)
if strings_dir is not None:
cls.read_windows_strings(strings_dir, False)
for (key, fn) in [
("SAMBA_WRITE_WINDOWS_STRINGS_DIR",
cls.write_windows_strings),
@@ -136,7 +140,7 @@ class SddlDecodeEncodeBase(TestCase):
print(f"{p[0]} -> {p[1]}", file=f)
@classmethod
def read_windows_strings(cls, dir):
def read_windows_strings(cls, dir, verbose=True):
"""This is complementary to cls.write_windows_strings(), which writes
these tests in a format usable on Windows. In this case
examples will be read in, replacing the strings here with the
@@ -170,17 +174,19 @@ class SddlDecodeEncodeBase(TestCase):
new_pairs.add((o, c))
if old_pairs == new_pairs:
print(f"no change in {c_GREEN(cls.name)}")
# nothing to do
if verbose:
print(f"no change in {c_GREEN(cls.name)}")
return
print(f"change in {c_RED(cls.name)}")
print("added:")
for x in sorted(new_pairs - old_pairs):
print(x)
print("removed:")
for x in sorted(old_pairs - new_pairs):
print(x)
if verbose:
print(f"change in {c_RED(cls.name)}")
print("added:")
for x in sorted(new_pairs - old_pairs):
print(x)
print("removed:")
for x in sorted(old_pairs - new_pairs):
print(x)
cls.strings[:] = sorted(new_pairs)