mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
gpo: Test gpo hourly scripts apply
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
committed by
David Mulder
parent
182cde4f9e
commit
ae56a07ae7
@ -320,7 +320,7 @@ class GPOTests(tests.TestCase):
|
|||||||
gpttmpl = gpofile % (local_path, guid)
|
gpttmpl = gpofile % (local_path, guid)
|
||||||
unstage_file(gpttmpl)
|
unstage_file(gpttmpl)
|
||||||
|
|
||||||
def test_gp_daily_scripts(self):
|
def test_gp_scripts(self):
|
||||||
local_path = self.lp.cache_path('gpo_cache')
|
local_path = self.lp.cache_path('gpo_cache')
|
||||||
guid = '{31B2F340-016D-11D2-945F-00C04FB984F9}'
|
guid = '{31B2F340-016D-11D2-945F-00C04FB984F9}'
|
||||||
reg_pol = os.path.join(local_path, policies, guid,
|
reg_pol = os.path.join(local_path, policies, guid,
|
||||||
@ -340,10 +340,14 @@ class GPOTests(tests.TestCase):
|
|||||||
if ads.connect():
|
if ads.connect():
|
||||||
gpos = ads.get_gpo_list(machine_creds.get_username())
|
gpos = ads.get_gpo_list(machine_creds.get_username())
|
||||||
|
|
||||||
|
reg_key = b'Software\\Policies\\Samba\\Unix Settings'
|
||||||
|
sections = { b'%s\\Daily Scripts' % reg_key : '.cron.daily',
|
||||||
|
b'%s\\Hourly Scripts' % reg_key : '.cron.hourly' }
|
||||||
|
for keyname in sections.keys():
|
||||||
# Stage the Registry.pol file with test data
|
# Stage the Registry.pol file with test data
|
||||||
stage = preg.file()
|
stage = preg.file()
|
||||||
e = preg.entry()
|
e = preg.entry()
|
||||||
e.keyname = b'Software\\Policies\\Samba\\Unix Settings\\Daily Scripts'
|
e.keyname = keyname
|
||||||
e.valuename = b'Software\\Policies\\Samba\\Unix Settings'
|
e.valuename = b'Software\\Policies\\Samba\\Unix Settings'
|
||||||
e.type = 1
|
e.type = 1
|
||||||
e.data = b'echo hello world'
|
e.data = b'echo hello world'
|
||||||
@ -353,12 +357,14 @@ class GPOTests(tests.TestCase):
|
|||||||
self.assertTrue(ret, 'Could not create the target %s' % reg_pol)
|
self.assertTrue(ret, 'Could not create the target %s' % reg_pol)
|
||||||
|
|
||||||
# Process all gpos, with temp output directory
|
# Process all gpos, with temp output directory
|
||||||
with TemporaryDirectory() as dname:
|
with TemporaryDirectory(sections[keyname]) as dname:
|
||||||
ext.process_group_policy([], gpos, dname)
|
ext.process_group_policy([], gpos, dname)
|
||||||
scripts = os.listdir(dname)
|
scripts = os.listdir(dname)
|
||||||
self.assertEquals(len(scripts), 1, 'The daily script was not created')
|
self.assertEquals(len(scripts), 1,
|
||||||
|
'The %s script was not created' % keyname.decode())
|
||||||
out, _ = Popen([os.path.join(dname, scripts[0])], stdout=PIPE).communicate()
|
out, _ = Popen([os.path.join(dname, scripts[0])], stdout=PIPE).communicate()
|
||||||
self.assertIn(b'hello world', out, 'Daily script execution failed')
|
self.assertIn(b'hello world', out,
|
||||||
|
'%s script execution failed' % keyname.decode())
|
||||||
|
|
||||||
# Unstage the Registry.pol file
|
# Unstage the Registry.pol file
|
||||||
unstage_file(reg_pol)
|
unstage_file(reg_pol)
|
||||||
|
1
selftest/knownfail.d/gpo
Normal file
1
selftest/knownfail.d/gpo
Normal file
@ -0,0 +1 @@
|
|||||||
|
^samba.tests.gpo.samba.tests.gpo.GPOTests.test_gp_scripts
|
Reference in New Issue
Block a user