-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1177 from strictdoc-project/stanislaw/1157-includ…
…e-exclude-filters helpers/path_filter: basic validation of user input
- Loading branch information
Showing
7 changed files
with
125 additions
and
11 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from strictdoc.core.environment import SDocRuntimeEnvironment | ||
|
||
__version__ = "0.0.42a3" | ||
__version__ = "0.0.42a5" | ||
|
||
|
||
environment = SDocRuntimeEnvironment(__file__) |
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
6 changes: 6 additions & 0 deletions
6
...tion/options/options_per_project/include_doc_paths/02_invalid_option/docs1/document1.sdoc
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,6 @@ | ||
[DOCUMENT] | ||
TITLE: Document 1 | ||
|
||
[FREETEXT] | ||
**Hello world** | ||
[/FREETEXT] |
7 changes: 7 additions & 0 deletions
7
...ntegration/options/options_per_project/include_doc_paths/02_invalid_option/strictdoc.toml
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,7 @@ | ||
[project] | ||
|
||
include_doc_paths = [ | ||
" " | ||
] | ||
|
||
features = [] |
3 changes: 3 additions & 0 deletions
3
tests/integration/options/options_per_project/include_doc_paths/02_invalid_option/test.itest
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 @@ | ||
RUN: %expect_exit 1 %strictdoc export %S --output-dir Output/ | filecheck %s --dump-input=fail | ||
|
||
CHECK: error: strictdoc.toml: 'include_doc_paths': Path mask must start with an alphanumeric character or a wildcard symbol '*'. Provided string: ' '. |
43 changes: 43 additions & 0 deletions
43
tests/unit/strictdoc/helpers/test_path_filter_mask_validation.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
|
||
from strictdoc.helpers.path_filter import validate_mask | ||
|
||
|
||
def test_case_01_empty_mask_allows_everything(): | ||
# Does not raise is success. | ||
validate_mask("docs/") | ||
validate_mask("Docs/") | ||
|
||
with pytest.raises(SyntaxError) as exc_info: | ||
validate_mask("") | ||
assert "Path mask must not be empty." in exc_info.value.args[0] | ||
|
||
with pytest.raises(SyntaxError) as exc_info: | ||
validate_mask(".") | ||
assert ( | ||
"Path mask must start with an alphanumeric character or " | ||
"a wildcard symbol '*'." | ||
) in exc_info.value.args[0] | ||
|
||
with pytest.raises(SyntaxError) as exc_info: | ||
validate_mask("foo//") | ||
assert ( | ||
"Path mask must not contain double slashes." in exc_info.value.args[0] | ||
) | ||
|
||
with pytest.raises(SyntaxError) as exc_info: | ||
validate_mask("bar\\\\") | ||
assert ( | ||
"Path mask must not contain double slashes." in exc_info.value.args[0] | ||
) | ||
|
||
with pytest.raises(SyntaxError) as exc_info: | ||
validate_mask("***") | ||
assert "Invalid wildcard: '***'." in exc_info.value.args[0] | ||
|
||
with pytest.raises(SyntaxError) as exc_info: | ||
validate_mask("a[") | ||
assert ( | ||
"Path mask must not contain any of the special characters: " | ||
"('[', ']', '(', ')', '{', '}', '?', '+', '!')." | ||
) in exc_info.value.args[0] |