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)
def test_set_value_unicode_key(self): ''' Test the set_value function on a unicode key ''' try: self.assertTrue( win_reg.set_value(hive='HKLM', key='{0}\\{1}'.format(FAKE_KEY, UNICODE_KEY), vname='fake_name', vdata='fake_value')) expected = { 'hive': 'HKLM', 'key': '{0}\\{1}'.format(FAKE_KEY, UNICODE_KEY), 'success': True, 'vdata': 'fake_value', 'vname': 'fake_name', 'vtype': 'REG_SZ' } self.assertEqual( win_reg.read_value(hive='HKLM', key='{0}\\{1}'.format( FAKE_KEY, UNICODE_KEY), vname='fake_name'), expected) finally: win_reg.delete_key_recursive(hive='HKLM', key=FAKE_KEY)
def test_read_value_default(self): ''' Test the read_value function reading the default value using a well known registry key ''' ret = win_reg.read_value( hive='HKLM', key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion') self.assertEqual(ret['vdata'], '(value not set)')
def test_read_value_existing(self): ''' Test the read_value function using a well known registry value ''' ret = win_reg.read_value( hive='HKLM', key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion', vname='ProgramFilesPath') self.assertEqual(ret['vdata'], '%ProgramFiles%')
def test_read_value_non_existing_key(self): ''' Test the read_value function using a non existing registry key ''' expected = { 'comment': 'Cannot find key: HKLM\\{0}'.format(FAKE_KEY), 'vdata': None, 'vname': 'fake_name', 'success': False, 'hive': 'HKLM', 'key': FAKE_KEY } self.assertEqual( win_reg.read_value(hive='HKLM', key=FAKE_KEY, vname='fake_name'), expected)
def test_read_value_non_existing(self): ''' Test the read_value function using a non existing value pair ''' expected = { 'comment': 'Cannot find fake_name in HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion', 'vdata': None, 'vname': 'fake_name', 'success': False, 'hive': 'HKLM', 'key': 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' } self.assertEqual( win_reg.read_value( hive='HKLM', key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion', vname='fake_name'), expected)
def test_set_value_default(self): ''' Test the set_value function on the default value ''' try: self.assertTrue( win_reg.set_value(hive='HKLM', key=FAKE_KEY, vdata='fake_default_data')) expected = { 'hive': 'HKLM', 'key': FAKE_KEY, 'success': True, 'vdata': 'fake_default_data', 'vname': '(Default)', 'vtype': 'REG_SZ' } self.assertEqual(win_reg.read_value( hive='HKLM', key=FAKE_KEY, ), expected) finally: win_reg.delete_key_recursive(hive='HKLM', key=FAKE_KEY)