mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Merge pull request #50063 from twangboy/fix_50039
Use long when setting REG_QWORD
This commit is contained in:
commit
9ad43f2b71
@ -767,6 +767,9 @@ def cast_vdata(vdata=None, vtype='REG_SZ'):
|
||||
# Make sure REG_MULTI_SZ is a list of strings
|
||||
elif vtype_value == win32con.REG_MULTI_SZ:
|
||||
return [_to_unicode(i) for i in vdata]
|
||||
# Make sure REG_QWORD is a 64 bit integer
|
||||
elif vtype_value == win32con.REG_QWORD:
|
||||
return vdata if six.PY3 else long(vdata) # pylint: disable=W1699
|
||||
# Everything else is int
|
||||
else:
|
||||
return int(vdata)
|
||||
|
@ -307,6 +307,74 @@ class WinFunctionsTestCase(TestCase):
|
||||
finally:
|
||||
win_reg.delete_key_recursive(hive='HKLM', key=FAKE_KEY)
|
||||
|
||||
@destructiveTest
|
||||
def test_set_value_reg_dword(self):
|
||||
'''
|
||||
Test the set_value function on a unicode value
|
||||
'''
|
||||
try:
|
||||
self.assertTrue(
|
||||
win_reg.set_value(
|
||||
hive='HKLM',
|
||||
key=FAKE_KEY,
|
||||
vname='dword_value',
|
||||
vdata=123,
|
||||
vtype='REG_DWORD'
|
||||
)
|
||||
)
|
||||
expected = {
|
||||
'hive': 'HKLM',
|
||||
'key': FAKE_KEY,
|
||||
'success': True,
|
||||
'vdata': 123,
|
||||
'vname': 'dword_value',
|
||||
'vtype': 'REG_DWORD'
|
||||
}
|
||||
self.assertEqual(
|
||||
win_reg.read_value(
|
||||
hive='HKLM',
|
||||
key=FAKE_KEY,
|
||||
vname='dword_value'
|
||||
),
|
||||
expected
|
||||
)
|
||||
finally:
|
||||
win_reg.delete_key_recursive(hive='HKLM', key=FAKE_KEY)
|
||||
|
||||
@destructiveTest
|
||||
def test_set_value_reg_qword(self):
|
||||
'''
|
||||
Test the set_value function on a unicode value
|
||||
'''
|
||||
try:
|
||||
self.assertTrue(
|
||||
win_reg.set_value(
|
||||
hive='HKLM',
|
||||
key=FAKE_KEY,
|
||||
vname='qword_value',
|
||||
vdata=123,
|
||||
vtype='REG_QWORD'
|
||||
)
|
||||
)
|
||||
expected = {
|
||||
'hive': 'HKLM',
|
||||
'key': FAKE_KEY,
|
||||
'success': True,
|
||||
'vdata': 123,
|
||||
'vname': 'qword_value',
|
||||
'vtype': 'REG_QWORD'
|
||||
}
|
||||
self.assertEqual(
|
||||
win_reg.read_value(
|
||||
hive='HKLM',
|
||||
key=FAKE_KEY,
|
||||
vname='qword_value'
|
||||
),
|
||||
expected
|
||||
)
|
||||
finally:
|
||||
win_reg.delete_key_recursive(hive='HKLM', key=FAKE_KEY)
|
||||
|
||||
@destructiveTest
|
||||
def test_delete_value(self):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user