cyberark-tpc-plugin-validator 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. cyberark_tpc_plugin_validator-0.2.0/LICENSE +21 -0
  2. cyberark_tpc_plugin_validator-0.2.0/PKG-INFO +45 -0
  3. cyberark_tpc_plugin_validator-0.2.0/README.md +5 -0
  4. cyberark_tpc_plugin_validator-0.2.0/cyberark_tpc_plugin_validator.egg-info/PKG-INFO +45 -0
  5. cyberark_tpc_plugin_validator-0.2.0/cyberark_tpc_plugin_validator.egg-info/SOURCES.txt +52 -0
  6. cyberark_tpc_plugin_validator-0.2.0/cyberark_tpc_plugin_validator.egg-info/dependency_links.txt +1 -0
  7. cyberark_tpc_plugin_validator-0.2.0/cyberark_tpc_plugin_validator.egg-info/entry_points.txt +2 -0
  8. cyberark_tpc_plugin_validator-0.2.0/cyberark_tpc_plugin_validator.egg-info/top_level.txt +1 -0
  9. cyberark_tpc_plugin_validator-0.2.0/pyproject.toml +38 -0
  10. cyberark_tpc_plugin_validator-0.2.0/setup.cfg +4 -0
  11. cyberark_tpc_plugin_validator-0.2.0/tests/test_conditions_section_rule_set.py +80 -0
  12. cyberark_tpc_plugin_validator-0.2.0/tests/test_cpm_parameters_validation_section_rule_set.py +82 -0
  13. cyberark_tpc_plugin_validator-0.2.0/tests/test_debug_information_section_rule_set.py +117 -0
  14. cyberark_tpc_plugin_validator-0.2.0/tests/test_lexer.py +237 -0
  15. cyberark_tpc_plugin_validator-0.2.0/tests/test_parameters_section_rule_set.py +107 -0
  16. cyberark_tpc_plugin_validator-0.2.0/tests/test_process_file_rule_set.py +109 -0
  17. cyberark_tpc_plugin_validator-0.2.0/tests/test_prompts_file_rule_set.py +79 -0
  18. cyberark_tpc_plugin_validator-0.2.0/tests/test_states_section_rule_set.py +94 -0
  19. cyberark_tpc_plugin_validator-0.2.0/tests/test_transitions_section_rule_set.py +80 -0
  20. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/__init__.py +1 -0
  21. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/__init__.py +1 -0
  22. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/lexer.py +221 -0
  23. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/tokens/__init__.py +1 -0
  24. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/tokens/assignment.py +16 -0
  25. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/tokens/comment.py +14 -0
  26. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/tokens/cpm_parameter_validation.py +17 -0
  27. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/tokens/fail_state.py +16 -0
  28. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/tokens/section_header.py +14 -0
  29. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/tokens/transition.py +16 -0
  30. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/utilities/__init__.py +1 -0
  31. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/utilities/regex.py +10 -0
  32. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/utilities/token_name.py +14 -0
  33. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/lexer/utilities/types.py +22 -0
  34. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/main.py +41 -0
  35. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/parser/__init__.py +1 -0
  36. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/parser/parser.py +91 -0
  37. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/__init__.py +1 -0
  38. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/conditions_section_rule_set.py +88 -0
  39. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/cpm_parameters_validation_section_rule_set.py +96 -0
  40. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/debug_information_section_rule_set.py +154 -0
  41. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/file_rule_set.py +82 -0
  42. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/parameters_section_rule_set.py +135 -0
  43. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/process_file_rule_set.py +47 -0
  44. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/prompts_file_rule_set.py +40 -0
  45. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/rule_set.py +157 -0
  46. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/section_rule_set.py +48 -0
  47. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/states_section_rule_set.py +128 -0
  48. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/rule_sets/transitions_section_rule_set.py +158 -0
  49. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/utilities/__init__.py +1 -0
  50. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/utilities/exceptions.py +13 -0
  51. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/utilities/severity.py +11 -0
  52. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/utilities/types.py +53 -0
  53. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/utilities/validation_result.py +14 -0
  54. cyberark_tpc_plugin_validator-0.2.0/tpc_plugin_validator/validator.py +75 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 (Peter McDonald)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: cyberark-tpc-plugin-validator
3
+ Version: 0.2.0
4
+ Summary: A tool to help validate a custom TPC plugin.
5
+ Author-email: Peter McDonald <git@petermcdonald.co.uk>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 (Peter McDonald)
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Classifier: Development Status :: 4 - Beta
29
+ Classifier: Programming Language :: Python
30
+ Classifier: Programming Language :: Python :: 3.11
31
+ Classifier: Programming Language :: Python :: 3.12
32
+ Classifier: Programming Language :: Python :: 3.13
33
+ Classifier: Programming Language :: Python :: 3.14
34
+ Classifier: Programming Language :: Python :: 3.15
35
+ Classifier: Typing :: Typed
36
+ Requires-Python: >=3.11
37
+ Description-Content-Type: text/markdown
38
+ License-File: LICENSE
39
+ Dynamic: license-file
40
+
41
+ # CyberArk TPC Plugin Validator
42
+
43
+ This repository is a placeholder for a new package that is intended to validate CyberArk TPC plugins. The package will
44
+ include a set of tools and scripts to ensure that the plugins meet the required standards and function correctly within
45
+ the CyberArk environment.
@@ -0,0 +1,5 @@
1
+ # CyberArk TPC Plugin Validator
2
+
3
+ This repository is a placeholder for a new package that is intended to validate CyberArk TPC plugins. The package will
4
+ include a set of tools and scripts to ensure that the plugins meet the required standards and function correctly within
5
+ the CyberArk environment.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: cyberark-tpc-plugin-validator
3
+ Version: 0.2.0
4
+ Summary: A tool to help validate a custom TPC plugin.
5
+ Author-email: Peter McDonald <git@petermcdonald.co.uk>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 (Peter McDonald)
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Classifier: Development Status :: 4 - Beta
29
+ Classifier: Programming Language :: Python
30
+ Classifier: Programming Language :: Python :: 3.11
31
+ Classifier: Programming Language :: Python :: 3.12
32
+ Classifier: Programming Language :: Python :: 3.13
33
+ Classifier: Programming Language :: Python :: 3.14
34
+ Classifier: Programming Language :: Python :: 3.15
35
+ Classifier: Typing :: Typed
36
+ Requires-Python: >=3.11
37
+ Description-Content-Type: text/markdown
38
+ License-File: LICENSE
39
+ Dynamic: license-file
40
+
41
+ # CyberArk TPC Plugin Validator
42
+
43
+ This repository is a placeholder for a new package that is intended to validate CyberArk TPC plugins. The package will
44
+ include a set of tools and scripts to ensure that the plugins meet the required standards and function correctly within
45
+ the CyberArk environment.
@@ -0,0 +1,52 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ cyberark_tpc_plugin_validator.egg-info/PKG-INFO
5
+ cyberark_tpc_plugin_validator.egg-info/SOURCES.txt
6
+ cyberark_tpc_plugin_validator.egg-info/dependency_links.txt
7
+ cyberark_tpc_plugin_validator.egg-info/entry_points.txt
8
+ cyberark_tpc_plugin_validator.egg-info/top_level.txt
9
+ tests/test_conditions_section_rule_set.py
10
+ tests/test_cpm_parameters_validation_section_rule_set.py
11
+ tests/test_debug_information_section_rule_set.py
12
+ tests/test_lexer.py
13
+ tests/test_parameters_section_rule_set.py
14
+ tests/test_process_file_rule_set.py
15
+ tests/test_prompts_file_rule_set.py
16
+ tests/test_states_section_rule_set.py
17
+ tests/test_transitions_section_rule_set.py
18
+ tpc_plugin_validator/__init__.py
19
+ tpc_plugin_validator/main.py
20
+ tpc_plugin_validator/validator.py
21
+ tpc_plugin_validator/lexer/__init__.py
22
+ tpc_plugin_validator/lexer/lexer.py
23
+ tpc_plugin_validator/lexer/tokens/__init__.py
24
+ tpc_plugin_validator/lexer/tokens/assignment.py
25
+ tpc_plugin_validator/lexer/tokens/comment.py
26
+ tpc_plugin_validator/lexer/tokens/cpm_parameter_validation.py
27
+ tpc_plugin_validator/lexer/tokens/fail_state.py
28
+ tpc_plugin_validator/lexer/tokens/section_header.py
29
+ tpc_plugin_validator/lexer/tokens/transition.py
30
+ tpc_plugin_validator/lexer/utilities/__init__.py
31
+ tpc_plugin_validator/lexer/utilities/regex.py
32
+ tpc_plugin_validator/lexer/utilities/token_name.py
33
+ tpc_plugin_validator/lexer/utilities/types.py
34
+ tpc_plugin_validator/parser/__init__.py
35
+ tpc_plugin_validator/parser/parser.py
36
+ tpc_plugin_validator/rule_sets/__init__.py
37
+ tpc_plugin_validator/rule_sets/conditions_section_rule_set.py
38
+ tpc_plugin_validator/rule_sets/cpm_parameters_validation_section_rule_set.py
39
+ tpc_plugin_validator/rule_sets/debug_information_section_rule_set.py
40
+ tpc_plugin_validator/rule_sets/file_rule_set.py
41
+ tpc_plugin_validator/rule_sets/parameters_section_rule_set.py
42
+ tpc_plugin_validator/rule_sets/process_file_rule_set.py
43
+ tpc_plugin_validator/rule_sets/prompts_file_rule_set.py
44
+ tpc_plugin_validator/rule_sets/rule_set.py
45
+ tpc_plugin_validator/rule_sets/section_rule_set.py
46
+ tpc_plugin_validator/rule_sets/states_section_rule_set.py
47
+ tpc_plugin_validator/rule_sets/transitions_section_rule_set.py
48
+ tpc_plugin_validator/utilities/__init__.py
49
+ tpc_plugin_validator/utilities/exceptions.py
50
+ tpc_plugin_validator/utilities/severity.py
51
+ tpc_plugin_validator/utilities/types.py
52
+ tpc_plugin_validator/utilities/validation_result.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tpc-validator = tpc_plugin_validator.main:main
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "cyberark-tpc-plugin-validator"
3
+ version = "0.2.0"
4
+ description = "A tool to help validate a custom TPC plugin."
5
+ authors = [{ name = "Peter McDonald", email = "git@petermcdonald.co.uk"}]
6
+ readme = "README.md"
7
+ license = { file = "LICENSE" }
8
+ requires-python = ">=3.11"
9
+ dependencies = []
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Programming Language :: Python",
13
+ "Programming Language :: Python :: 3.11",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Programming Language :: Python :: 3.13",
16
+ "Programming Language :: Python :: 3.14",
17
+ "Programming Language :: Python :: 3.15",
18
+ "Typing :: Typed",
19
+ ]
20
+
21
+ [dependency-groups]
22
+ dev = [
23
+ "pytest>=8.4.2",
24
+ "pytest-cov>=6.3.0",
25
+ "pytest-mypy-plugins>=3.2.0",
26
+ "ruff>=0.12.12",
27
+ "troml>=0.4.1",
28
+ "ty>=0.0.1a20",
29
+ ]
30
+
31
+ [project.scripts]
32
+ tpc-validator = "tpc_plugin_validator.main:main"
33
+
34
+ [tool.pytest.ini_options]
35
+ addopts = "--cov=tpc_plugin_validator --cov-report term-missing --cov-report xml:coverage.xml"
36
+
37
+ [tool.ruff]
38
+ line-length = 120
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,80 @@
1
+ """Tests for the conditions section rule set."""
2
+
3
+ import pytest
4
+
5
+ from tpc_plugin_validator.parser.parser import Parser
6
+ from tpc_plugin_validator.rule_sets.conditions_section_rule_set import (
7
+ ConditionsSectionRuleSet,
8
+ )
9
+ from tpc_plugin_validator.utilities.severity import Severity
10
+ from tpc_plugin_validator.utilities.validation_result import ValidationResult
11
+
12
+
13
+ class TestConditionsSectionRuleSet(object):
14
+ """Tests for the debug information rule set."""
15
+
16
+ @pytest.mark.parametrize(
17
+ "process_file,prompts_file,expected_results",
18
+ [
19
+ (
20
+ "tests/data/valid-process.ini",
21
+ "tests/data/valid-prompts.ini",
22
+ [],
23
+ ),
24
+ (
25
+ "tests/data/invalid-process.ini",
26
+ "tests/data/invalid-prompts.ini",
27
+ [
28
+ ValidationResult(
29
+ rule="InvalidTokenTypeViolation",
30
+ severity=Severity.WARNING,
31
+ message='The token type "Transition" is not valid in this section, file: prompts.ini, section: conditions, line: 18.',
32
+ ),
33
+ ValidationResult(
34
+ rule="DuplicateAssignmentViolation",
35
+ severity=Severity.CRITICAL,
36
+ message='The assignment "failure" has been declared 2 times, file: prompts.ini, section: conditions.',
37
+ ),
38
+ ValidationResult(
39
+ rule="NameCaseMismatchViolation",
40
+ severity=Severity.WARNING,
41
+ message='The condition "Hello" is declared but is used as "hello", file: prompts.ini, section: conditions, line: 13.',
42
+ ),
43
+ ValidationResult(
44
+ rule="UnusedConditionViolation",
45
+ severity=Severity.WARNING,
46
+ message='The condition "Unused" is declared but is not used, file: prompts.ini, section: conditions, line: 19.',
47
+ ),
48
+ ],
49
+ ),
50
+ ],
51
+ )
52
+ def test_conditions_section_rule_set(
53
+ self,
54
+ process_file: str,
55
+ prompts_file: str,
56
+ expected_results: list[ValidationResult],
57
+ ) -> None:
58
+ """
59
+ Tests for the conditions section rule set.
60
+
61
+ :param process_file: Path to the process file to use for the test case.
62
+ :param prompts_file: Path to the prompts file to use for the test case.
63
+ :param expected_results: List of expected ValidationResult
64
+ """
65
+ with open(process_file, "r") as process_fh, open(prompts_file, "r") as prompts_fh:
66
+ process_file_content = process_fh.read()
67
+ prompts_file_content = prompts_fh.read()
68
+
69
+ parser = Parser(process_file=process_file_content, prompts_file=prompts_file_content)
70
+ parsed_process_file = parser.process_file
71
+ parsed_prompts_file = parser.prompts_file
72
+
73
+ rule = ConditionsSectionRuleSet(prompts_file=parsed_prompts_file, process_file=parsed_process_file, config={})
74
+ rule.validate()
75
+ results = rule.get_violations()
76
+
77
+ assert len(results) == len(expected_results)
78
+
79
+ for result in results:
80
+ assert result in expected_results
@@ -0,0 +1,82 @@
1
+ """Tests for the CPM Parameters Validation section rule set."""
2
+
3
+ import pytest
4
+
5
+ from tpc_plugin_validator.parser.parser import Parser
6
+ from tpc_plugin_validator.rule_sets.cpm_parameters_validation_section_rule_set import (
7
+ CPMParametersValidationSectionRuleSet,
8
+ )
9
+ from tpc_plugin_validator.utilities.severity import Severity
10
+ from tpc_plugin_validator.utilities.validation_result import ValidationResult
11
+
12
+
13
+ class TestCPMParametersValidationSectionRuleSet(object):
14
+ """Tests for the CPM Parameters Validation section rule set."""
15
+
16
+ @pytest.mark.parametrize(
17
+ "process_file,prompts_file,expected_results",
18
+ [
19
+ (
20
+ "tests/data/valid-process.ini",
21
+ "tests/data/valid-prompts.ini",
22
+ [],
23
+ ),
24
+ (
25
+ "tests/data/invalid-process.ini",
26
+ "tests/data/invalid-prompts.ini",
27
+ [
28
+ ValidationResult(
29
+ rule="InvalidTokenTypeViolation",
30
+ severity=Severity.WARNING,
31
+ message='The token type "Transition" is not valid in this section, file: process.ini, section: CPM Parameters Validation, line: 53.',
32
+ ),
33
+ ValidationResult(
34
+ rule="UnusedParameterViolation",
35
+ severity=Severity.WARNING,
36
+ message='The parameter "extrapass2\\Username" has been validated but is not used, file: process.ini, section: CPM Parameters Validation, line: 54.',
37
+ ),
38
+ ValidationResult(
39
+ rule="UnusedParameterViolation",
40
+ severity=Severity.WARNING,
41
+ message='The parameter "extrapass2\\Username" has been validated but is not used, file: process.ini, section: CPM Parameters Validation, line: 56.',
42
+ ),
43
+ ValidationResult(
44
+ rule="DuplicateAssignmentViolation",
45
+ severity=Severity.CRITICAL,
46
+ message='The assignment "extrapass2\\Username" has been declared 2 times, file: process.ini, section: CPM Parameters Validation.',
47
+ ),
48
+ ],
49
+ ),
50
+ ],
51
+ )
52
+ def test_cpm_parameters_validation_section_rule_set(
53
+ self,
54
+ process_file: str,
55
+ prompts_file: str,
56
+ expected_results: list[ValidationResult],
57
+ ) -> None:
58
+ """
59
+ Tests for the CPM Parameters Validation section rule set.
60
+
61
+ :param process_file: Path to the process file to use for the test case.
62
+ :param prompts_file: Path to the prompts file to use for the test case.
63
+ :param expected_results: List of expected ValidationResult
64
+ """
65
+ with open(process_file, "r") as process_fh, open(prompts_file, "r") as prompts_fh:
66
+ process_file_content = process_fh.read()
67
+ prompts_file_content = prompts_fh.read()
68
+
69
+ parser = Parser(process_file=process_file_content, prompts_file=prompts_file_content)
70
+ parsed_process_file = parser.process_file
71
+ parsed_prompts_file = parser.prompts_file
72
+
73
+ rule = CPMParametersValidationSectionRuleSet(
74
+ prompts_file=parsed_prompts_file, process_file=parsed_process_file, config={}
75
+ )
76
+ rule.validate()
77
+ results = rule.get_violations()
78
+
79
+ assert len(results) == len(expected_results)
80
+
81
+ for result in results:
82
+ assert result in expected_results
@@ -0,0 +1,117 @@
1
+ """Tests for the debug information section rule set."""
2
+
3
+ import pytest
4
+
5
+ from tpc_plugin_validator.parser.parser import Parser
6
+ from tpc_plugin_validator.rule_sets.debug_information_section_rule_set import (
7
+ DebugInformationSectionRuleSet,
8
+ )
9
+ from tpc_plugin_validator.utilities.severity import Severity
10
+ from tpc_plugin_validator.utilities.validation_result import ValidationResult
11
+
12
+
13
+ class TestDebugInformationSectionRuleSet(object):
14
+ """Tests for the debug information section rule set."""
15
+
16
+ @pytest.mark.parametrize(
17
+ "process_file,prompts_file,expected_results",
18
+ [
19
+ (
20
+ "tests/data/valid-process.ini",
21
+ "tests/data/valid-prompts.ini",
22
+ [],
23
+ ),
24
+ (
25
+ "tests/data/invalid-process.ini",
26
+ "tests/data/invalid-prompts.ini",
27
+ [
28
+ ValidationResult(
29
+ rule="InvalidTokenTypeViolation",
30
+ severity=Severity.WARNING,
31
+ message='The token type "Transition" is not valid in this section, file: process.ini, section: Debug Information, line: 73.',
32
+ ),
33
+ ValidationResult(
34
+ rule="ValueCaseViolation",
35
+ severity=Severity.WARNING,
36
+ message='The value for "DebugLogFullExecutionInfo" is set to "No" this should be in lower case, file: process.ini, section: Debug Information, line: 75.',
37
+ ),
38
+ ValidationResult(
39
+ rule="NameViolation",
40
+ severity=Severity.WARNING,
41
+ message='The setting "InvalidName" is not a valid setting. Valid settings are: DebugLogFullParsingInfo, DebugLogFullExecutionInfo, DebugLogDetailBuiltInActions, ExpectLog, ConsoleOutput, file: process.ini, section: Debug Information, line: 79.',
42
+ ),
43
+ ValidationResult(
44
+ rule="NameCaseViolation",
45
+ severity=Severity.WARNING,
46
+ message='The setting "COnsoleOutput" should be set as "ConsoleOutput", file: process.ini, section: Debug Information, line: 78.',
47
+ ),
48
+ ValidationResult(
49
+ rule="NameCaseViolation",
50
+ severity=Severity.WARNING,
51
+ message='The setting "COnsoleOutput" should be set as "ConsoleOutput", file: process.ini, section: Debug Information, line: 80.',
52
+ ),
53
+ ValidationResult(
54
+ rule="ValueCaseViolation",
55
+ severity=Severity.WARNING,
56
+ message='The value for "COnsoleOutput" is set to "No" this should be in lower case, file: process.ini, section: Debug Information, line: 78.',
57
+ ),
58
+ ValidationResult(
59
+ rule="ValueCaseViolation",
60
+ severity=Severity.WARNING,
61
+ message='The value for "COnsoleOutput" is set to "No" this should be in lower case, file: process.ini, section: Debug Information, line: 80.',
62
+ ),
63
+ ValidationResult(
64
+ rule="ValueViolation",
65
+ severity=Severity.CRITICAL,
66
+ message='The value for "DebugLogDetailBuiltInActions" is set to "maybe" and is invalid. Valid values are "no" and "yes", file: process.ini, section: Debug Information, line: 76.',
67
+ ),
68
+ ValidationResult(
69
+ rule="ValueViolation",
70
+ severity=Severity.WARNING,
71
+ message='The value for "DebugLogFullParsingInfo" is blank. Setting should be explicitly set to "no", file: process.ini, section: Debug Information, line: 74.',
72
+ ),
73
+ ValidationResult(
74
+ rule="LoggingEnabledViolation",
75
+ severity=Severity.CRITICAL,
76
+ message='The value for "ExpectLog" is set to "yes". It is recommended to set all settings in this section to "no" for production environments, file: process.ini, section: Debug Information, line: 77.',
77
+ ),
78
+ ValidationResult(
79
+ rule="DuplicateAssignmentViolation",
80
+ severity=Severity.CRITICAL,
81
+ message='The assignment "COnsoleOutput" has been declared 2 times, file: process.ini, section: Debug Information.',
82
+ ),
83
+ ],
84
+ ),
85
+ ],
86
+ )
87
+ def test_debug_information_logging_section_rule_set(
88
+ self,
89
+ process_file: str,
90
+ prompts_file: str,
91
+ expected_results: list[ValidationResult],
92
+ ) -> None:
93
+ """
94
+ Tests for the debug information section rule set.
95
+
96
+ :param process_file: Path to the process file to use for the test case.
97
+ :param prompts_file: Path to the prompts file to use for the test case.
98
+ :param expected_results: List of expected ValidationResult
99
+ """
100
+ with open(process_file, "r") as process_fh, open(prompts_file, "r") as prompts_fh:
101
+ process_file_content = process_fh.read()
102
+ prompts_file_content = prompts_fh.read()
103
+
104
+ parser = Parser(process_file=process_file_content, prompts_file=prompts_file_content)
105
+ parsed_process_file = parser.process_file
106
+ parsed_prompts_file = parser.prompts_file
107
+
108
+ rule = DebugInformationSectionRuleSet(
109
+ prompts_file=parsed_prompts_file, process_file=parsed_process_file, config={}
110
+ )
111
+ rule.validate()
112
+ results = rule.get_violations()
113
+
114
+ assert len(results) == len(expected_results)
115
+
116
+ for result in results:
117
+ assert result in expected_results