mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Add test for explicit lists
This commit is contained in:
parent
84f5d639ae
commit
11681412af
@ -123,25 +123,25 @@ class WinLgpoTest(ModuleCase):
|
|||||||
ret = self.run_function('lgpo.set_computer_policy',
|
ret = self.run_function('lgpo.set_computer_policy',
|
||||||
(policy_name, policy_config))
|
(policy_name, policy_config))
|
||||||
log.debug('lgpo set_computer_policy ret == %s', ret)
|
log.debug('lgpo set_computer_policy ret == %s', ret)
|
||||||
|
cmd = ['lgpo.exe',
|
||||||
|
'/parse',
|
||||||
|
'/m',
|
||||||
|
r'c:\Windows\System32\GroupPolicy\Machine\Registry.pol']
|
||||||
if assert_true:
|
if assert_true:
|
||||||
self.assertTrue(ret)
|
self.assertTrue(ret)
|
||||||
lgpo_output = self.run_function(
|
lgpo_output = self.run_function('cmd.run', (), cmd=' '.join(cmd))
|
||||||
'cmd.run',
|
|
||||||
(),
|
|
||||||
cmd='lgpo.exe /parse /m c:\\Windows\\System32\\GroupPolicy\\Machine\\Registry.pol')
|
|
||||||
# validate that the lgpo output doesn't say the format is invalid
|
# validate that the lgpo output doesn't say the format is invalid
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
re.search(
|
re.search(r'Invalid file format\.', lgpo_output, re.IGNORECASE),
|
||||||
r'Invalid file format\.',
|
msg='Failed validating Registry.pol file format')
|
||||||
lgpo_output,
|
|
||||||
re.IGNORECASE), 'Failed validating Registry.pol file format')
|
|
||||||
# validate that the regexes we expect are in the output
|
# validate that the regexes we expect are in the output
|
||||||
for expected_regex in expected_regexes:
|
for expected_regex in expected_regexes:
|
||||||
match = re.search(
|
match = re.search(expected_regex, lgpo_output, re.IGNORECASE)
|
||||||
expected_regex,
|
self.assertIsNotNone(
|
||||||
lgpo_output,
|
match,
|
||||||
re.IGNORECASE)
|
msg='Failed validating policy "{0}" configuration, regex '
|
||||||
self.assertIsNotNone(match, 'Failed validating policy "{0}" configuration, regex "{1}" not found in lgpo output'.format(policy_name, expected_regex))
|
'"{1}" not found in lgpo output:\n{2}'
|
||||||
|
''.format(policy_name, expected_regex, lgpo_output))
|
||||||
else:
|
else:
|
||||||
# expecting it to fail
|
# expecting it to fail
|
||||||
self.assertNotEqual(ret, True)
|
self.assertNotEqual(ret, True)
|
||||||
@ -255,6 +255,35 @@ class WinLgpoTest(ModuleCase):
|
|||||||
'Not Configured',
|
'Not Configured',
|
||||||
[r'; Source file: c:\\windows\\system32\\grouppolicy\\machine\\registry.pol[\s]*; PARSING COMPLETED.'])
|
[r'; Source file: c:\\windows\\system32\\grouppolicy\\machine\\registry.pol[\s]*; PARSING COMPLETED.'])
|
||||||
|
|
||||||
|
@destructiveTest
|
||||||
|
def test_set_computer_policy_Pol_HardenedPaths(self):
|
||||||
|
# Disable Pol_HardenedPaths
|
||||||
|
log.debug('Attempting to disable Pol_HardenedPaths')
|
||||||
|
self._testComputerAdmxPolicy(
|
||||||
|
'Pol_HardenedPaths',
|
||||||
|
'Disabled',
|
||||||
|
[r'Computer[\s]*Software\\policies\\Microsoft\\Windows\\NetworkProvider\\HardenedPaths[\s]*\*[\s]*DELETEALLVALUES'])
|
||||||
|
# Configure Pol_HardenedPaths
|
||||||
|
log.debug('Attempting to configure Pol_HardenedPaths')
|
||||||
|
self._testComputerAdmxPolicy(
|
||||||
|
'Pol_HardenedPaths',
|
||||||
|
{
|
||||||
|
'Hardened UNC Paths': {
|
||||||
|
r'\\*\NETLOGON': 'RequireMutualAuthentication=1, RequireIntegrity=1',
|
||||||
|
r'\\*\SYSVOL': 'RequireMutualAuthentication=1, RequireIntegrity=1'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[
|
||||||
|
r'Computer[\s]*Software\\policies\\Microsoft\\Windows\\NetworkProvider\\HardenedPaths[\s]*\\\\\*\\NETLOGON[\s]*SZ:RequireMutualAuthentication=1, RequireIntegrity=1[\s]*',
|
||||||
|
r'Computer[\s]*Software\\policies\\Microsoft\\Windows\\NetworkProvider\\HardenedPaths[\s]*\\\\\*\\SYSVOL[\s]*SZ:RequireMutualAuthentication=1, RequireIntegrity=1[\s]*',
|
||||||
|
])
|
||||||
|
# Not Configure Pol_HardenedPaths
|
||||||
|
log.debug('Attempting to set Pol_HardenedPaths to Not Configured')
|
||||||
|
self._testComputerAdmxPolicy(
|
||||||
|
'Pol_HardenedPaths',
|
||||||
|
'Not Configured',
|
||||||
|
[r'; Source file: c:\\windows\\system32\\grouppolicy\\machine\\registry.pol[\s]*; PARSING COMPLETED.'])
|
||||||
|
|
||||||
@destructiveTest
|
@destructiveTest
|
||||||
def test_set_computer_policy_WindowsUpdate(self):
|
def test_set_computer_policy_WindowsUpdate(self):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user