Add some tests

This commit is contained in:
twangboy 2020-02-05 10:15:17 -07:00
parent 944b022f33
commit 7c81874a5b
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB

View file

@ -60,6 +60,88 @@ class WinLGPOTestCase(TestCase):
expected = '300000 or 5 minutes (recommended)'
self.assertEqual(result, expected)
def test__regexSearchKeyValueCombo_enabled(self):
'''
Make sure
'''
policy_data = '[\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00\x00;\x00D' \
'\x00e\x00f\x00a\x00u\x00l\x00t\x00C\x00o\x00n\x00s' \
'\x00e\x00n\x00t\x00\x00\x00;\x00\x01\x00\x00\x00;\x00' \
'\x04\x00\x00\x00;\x00\x02\x00\x00\x00]\x00'
policy_regpath = '\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00'
policy_regkey = '\x00D\x00e\x00f\x00a\x00u\x00l\x00t\x00C\x00o\x00n' \
'\x00s\x00e\x00n\x00t\x00\x00'
test = win_lgpo._regexSearchKeyValueCombo(
policy_data=policy_data,
policy_regpath=policy_regpath,
policy_regkey=policy_regkey
)
self.assertEqual(test, policy_data)
def test__regexSearchKeyValueCombo_not_configured(self):
'''
Make sure
'''
policy_data = ''
policy_regpath = '\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00'
policy_regkey = '\x00D\x00e\x00f\x00a\x00u\x00l\x00t\x00C\x00o\x00n' \
'\x00s\x00e\x00n\x00t\x00\x00'
test = win_lgpo._regexSearchKeyValueCombo(
policy_data=policy_data,
policy_regpath=policy_regpath,
policy_regkey=policy_regkey
)
self.assertIsNone(test)
def test__regexSearchKeyValueCombo_disabled(self):
'''
Make sure
'''
policy_data = '[\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00\x00;\x00*' \
'\x00*\x00d\x00e\x00l\x00.\x00D\x00e\x00f\x00a\x00u' \
'\x00l\x00t\x00C\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00' \
'\x00;\x00\x01\x00\x00\x00;\x00\x04\x00\x00\x00;\x00 ' \
'\x00\x00\x00]\x00'
policy_regpath = '\x00s\x00o\x00f\x00t\x00w\x00a\x00r\x00e\x00\\\x00p' \
'\x00o\x00l\x00i\x00c\x00i\x00e\x00s\x00\\\x00m\x00i' \
'\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00\\\x00w\x00i' \
'\x00n\x00d\x00o\x00w\x00s\x00\\\x00w\x00i\x00n\x00d' \
'\x00o\x00w\x00s\x00 \x00e\x00r\x00r\x00o\x00r\x00 ' \
'\x00r\x00e\x00p\x00o\x00r\x00t\x00i\x00n\x00g\x00\\' \
'\x00c\x00o\x00n\x00s\x00e\x00n\x00t\x00\x00'
policy_regkey = '\x00D\x00e\x00f\x00a\x00u\x00l\x00t\x00C\x00o\x00n' \
'\x00s\x00e\x00n\x00t\x00\x00'
test = win_lgpo._regexSearchKeyValueCombo(
policy_data=policy_data,
policy_regpath=policy_regpath,
policy_regkey=policy_regkey
)
self.assertEqual(test, policy_data)
def test__encode_string(self):
'''
``_encode_string`` should return a null terminated ``utf-16-le`` encoded