From 58f87ecdd4786496b33173660ee66a2a79c83cb2 Mon Sep 17 00:00:00 2001 From: Joachim Metz Date: Tue, 27 Feb 2024 08:12:08 +0100 Subject: [PATCH] Added test for registry.GetRootKey #121 --- tests/registry.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/registry.py b/tests/registry.py index e4aacde..98526ff 100644 --- a/tests/registry.py +++ b/tests/registry.py @@ -486,7 +486,29 @@ def testGetRegistryFileMappingOnSystem(self): # TODO: add GetRegistryFileMapping on UsrClass file test. - # TODO: add tests for GetRootKey + def testGetRootKey(self): + """Tests the GetRootKey function.""" + test_path = self._GetTestFilePath(['SYSTEM']) + self._SkipIfPathNotExists(test_path) + + win_registry = registry.WinRegistry( + registry_file_reader=TestREGFWinRegistryFileReader()) + win_registry.OpenAndMapFile(test_path) + + root_key = win_registry.GetRootKey() + self.assertIsNotNone(root_key) + + expected_subkey_names = [ + 'HKEY_CLASSES_ROOT', + 'HKEY_CURRENT_CONFIG', + 'HKEY_CURRENT_USER', + 'HKEY_DYN_DATA', + 'HKEY_LOCAL_MACHINE', + 'HKEY_PERFORMANCE_DATA', + 'HKEY_USERS'] + + subkey_names = sorted([subkey.name for subkey in root_key.GetSubkeys()]) + self.assertEqual(subkey_names, expected_subkey_names) def testMapFile(self): """Tests the MapFile function."""