diff options
author | Tim Beale <timbeale@catalyst.net.nz> | 2018-12-12 10:04:09 +1300 |
---|---|---|
committer | Tim Beale <timbeale@samba.org> | 2019-01-07 01:23:08 +0100 |
commit | 7f731d7642de3b1e4cbe43dcd354f0e9dc902787 (patch) | |
tree | 1dcc234371c93d3e10e2743804f35cfe2dee50d3 | |
parent | c95a869e85201f836c1579e0f50021e3ffc4cbe0 (diff) | |
download | samba-7f731d7642de3b1e4cbe43dcd354f0e9dc902787.tar.gz |
tests: Avoid hardcoding domain in test
Currently the sysvol domain directory is hard-coded, so the tests can
only ever run on the ad_dc.
This patch makes things marginally better by using the REALM
environmental variable instead. This allows us to run it against other
testenvs (like the SMBv2-only restoredc).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | python/samba/tests/smb.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py index 98e669c5f8c..9700953d57a 100644 --- a/python/samba/tests/smb.py +++ b/python/samba/tests/smb.py @@ -27,13 +27,14 @@ from samba.samba3 import libsmb_samba_internal from samba.samba3 import param as s3param PY3 = sys.version_info[0] == 3 -addom = 'addom.samba.example.com/' +realm = os.environ.get('REALM') +domain_dir = realm.lower() + '/' test_contents = 'abcd' * 256 utf_contents = u'Süßigkeiten Äpfel ' * 128 test_literal_bytes_embed_nulls = b'\xff\xfe\x14\x61\x00\x00\x62\x63\x64' * 256 binary_contents = b'\xff\xfe' binary_contents = binary_contents + "Hello cruel world of python3".encode('utf8') * 128 -test_dir = os.path.join(addom, 'testing_%d' % random.randint(0, 0xFFFF)) +test_dir = os.path.join(domain_dir, 'testing_%d' % random.randint(0, 0xFFFF)) test_file = os.path.join(test_dir, 'testing').replace('/', '\\') @@ -60,7 +61,7 @@ class SMBTests(samba.tests.TestCase): def test_list(self): # check a basic listing returns the items we expect - ls = [f['name'] for f in self.smb_conn.list(addom)] + ls = [f['name'] for f in self.smb_conn.list(domain_dir)] self.assertIn('scripts', ls, msg='"scripts" directory not found in sysvol') self.assertIn('Policies', ls, @@ -71,17 +72,17 @@ class SMBTests(samba.tests.TestCase): msg='Current dir (.) found in directory listing') # using a '*' mask should be the same as using no mask - ls_wildcard = [f['name'] for f in self.smb_conn.list(addom, "*")] + ls_wildcard = [f['name'] for f in self.smb_conn.list(domain_dir, "*")] self.assertEqual(ls, ls_wildcard) # applying a mask should only return items that match that mask - ls_pol = [f['name'] for f in self.smb_conn.list(addom, "Pol*")] + ls_pol = [f['name'] for f in self.smb_conn.list(domain_dir, "Pol*")] expected = ["Policies"] self.assertEqual(ls_pol, expected) # each item in the listing is a has with expected keys expected_keys = ['attrib', 'mtime', 'name', 'short_name', 'size'] - for item in self.smb_conn.list(addom): + for item in self.smb_conn.list(domain_dir): for key in expected_keys: self.assertIn(key, item, msg="Key '%s' not in listing '%s'" % (key, item)) |