-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67c1fa1
commit 535e5e3
Showing
10 changed files
with
164 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Acknowledgements: winsps-kb | ||
|
||
Copyright (c) 2023-2024, Joachim Metz <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Names should be added to this file with this pattern: | ||
# | ||
# For individuals: | ||
# Name (email address) | ||
# | ||
# For organizations: | ||
# Organization (fnmatch pattern) | ||
# | ||
# See python fnmatch module documentation for more information. | ||
|
||
Joachim Metz ([email protected]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
include ACKNOWLEDGEMENTS AUTHORS LICENSE README | ||
include dependencies.ini run_tests.py utils/dependencies.py | ||
include utils/check_dependencies.py | ||
include requirements.txt test_requirements.txt | ||
exclude .gitignore | ||
exclude *.pyc | ||
recursive-exclude winspsrc *.pyc | ||
recursive-include test_data * | ||
# The test scripts are not required in a binary distribution package they | ||
# are considered source distribution files and excluded in find_package() | ||
# in setup.py. | ||
recursive-include tests *.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# winsps-kb property definitions. | ||
--- | ||
format_identifier: 00000000-0000-0000-0000-000000000000 | ||
name: System.Null | ||
property_identifier: 0 | ||
shell_property_key: PKEY_Null | ||
value_type: VT_NULL | ||
--- | ||
format_identifier: 7d683fc9-d155-45a8-bb1f-89d19bcb792f | ||
name: System.Identity.DisplayName | ||
property_identifier: 100 | ||
shell_property_key: PKEY_Identity_DisplayName | ||
value_type: VT_LPWSTR | ||
--- | ||
alias: PIDSI_TITLE | ||
format_class: FMTID_SummaryInformation | ||
format_identifier: f29f85e0-4ff9-1068-ab91-08002b27b3d9 | ||
name: System.Title | ||
property_identifier: 2 | ||
shell_property_key: PKEY_Title | ||
value_type: VT_LPWSTR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
"""Tests for the YAML-based properties definitions file.""" | ||
|
||
import unittest | ||
|
||
from winspsrc import yaml_definitions_file | ||
|
||
from tests import test_lib | ||
|
||
|
||
class YAMLPropertiesDefinitionsFileTest(test_lib.BaseTestCase): | ||
"""Tests for the YAML-based properties definitions file.""" | ||
|
||
# pylint: disable=protected-access | ||
|
||
_TEST_YAML = { | ||
'format_class': 'FMTID_IntSite', | ||
'format_identifier': '000214a1-0000-0000-c000-000000000046', | ||
'name': 'System.Status', | ||
'property_identifier': 9, | ||
'shell_property_key': 'PKEY_Status', | ||
'value_type': 'VT_LPWSTR'} | ||
|
||
def testReadPropertyDefinition(self): | ||
"""Tests the _ReadPropertyDefinition function.""" | ||
test_definitions_file = ( | ||
yaml_definitions_file.YAMLPropertiesDefinitionsFile()) | ||
|
||
definitions = test_definitions_file._ReadPropertyDefinition(self._TEST_YAML) | ||
|
||
self.assertIsNotNone(definitions) | ||
self.assertEqual(definitions.format_class, 'FMTID_IntSite') | ||
self.assertEqual( | ||
definitions.format_identifier, '000214a1-0000-0000-c000-000000000046') | ||
self.assertEqual(definitions.names, set(['System.Status'])) | ||
self.assertEqual(definitions.property_identifier, 9) | ||
self.assertEqual(definitions.shell_property_keys, set(['PKEY_Status'])) | ||
self.assertEqual(definitions.value_types, set(['VT_LPWSTR'])) | ||
|
||
with self.assertRaises(RuntimeError): | ||
test_definitions_file._ReadPropertyDefinition({}) | ||
|
||
with self.assertRaises(RuntimeError): | ||
test_definitions_file._ReadPropertyDefinition({ | ||
'format_class': 'FMTID_IntSite', | ||
'name': 'System.Status', | ||
'property_identifier': 9, | ||
'shell_property_key': 'PKEY_Status', | ||
'value_type': 'VT_LPWSTR'}) | ||
|
||
with self.assertRaises(RuntimeError): | ||
test_definitions_file._ReadPropertyDefinition({ | ||
'format_class': 'FMTID_IntSite', | ||
'format_identifier': '000214a1-0000-0000-c000-000000000046', | ||
'name': 'System.Status', | ||
'shell_property_key': 'PKEY_Status', | ||
'value_type': 'VT_LPWSTR'}) | ||
|
||
with self.assertRaises(RuntimeError): | ||
test_definitions_file._ReadPropertyDefinition({ | ||
'bogus': 'test'}) | ||
|
||
def testReadFromFileObject(self): | ||
"""Tests the _ReadFromFileObject function.""" | ||
test_file_path = self._GetTestFilePath(['properties.yaml']) | ||
self._SkipIfPathNotExists(test_file_path) | ||
|
||
test_definitions_file = ( | ||
yaml_definitions_file.YAMLPropertiesDefinitionsFile()) | ||
|
||
with open(test_file_path, 'r', encoding='utf-8') as file_object: | ||
definitions = list(test_definitions_file._ReadFromFileObject(file_object)) | ||
|
||
self.assertEqual(len(definitions), 3) | ||
|
||
def testReadFromFile(self): | ||
"""Tests the ReadFromFile function.""" | ||
test_file_path = self._GetTestFilePath(['properties.yaml']) | ||
self._SkipIfPathNotExists(test_file_path) | ||
|
||
test_definitions_file = ( | ||
yaml_definitions_file.YAMLPropertiesDefinitionsFile()) | ||
|
||
definitions = list(test_definitions_file.ReadFromFile(test_file_path)) | ||
|
||
self.assertEqual(len(definitions), 3) | ||
|
||
self.assertEqual( | ||
definitions[0].format_identifier, | ||
'00000000-0000-0000-0000-000000000000') | ||
self.assertEqual( | ||
definitions[2].format_identifier, | ||
'f29f85e0-4ff9-1068-ab91-08002b27b3d9') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters