Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow all suffixes in doc files #4337

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changelog/4337.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Fixed an issue where **validate-content-path** checked suffixes of test- or doc-files
type: fix
pr_number: 4337
4 changes: 3 additions & 1 deletion demisto_sdk/scripts/validate_content_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ def _validate(path: Path) -> None:
raise SpacesInFileName

if path.suffix not in ALLOWED_SUFFIXES:
raise InvalidSuffix
if set(path.parts).isdisjoint(TESTS_AND_DOC_DIRECTORIES):
# all files are allowed under TESTS_AND_DOC_DIRECTORIES
raise InvalidSuffix

if depth == 1: # Packs/myPack/<first level folder>/<the file>
_exempt_unified_files(path, first_level_folder) # Raises PathIsUnified
Expand Down
20 changes: 20 additions & 0 deletions demisto_sdk/tests/validate_content_path_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
CLASSIFIERS_DIR,
CONTENT_ENTITIES_DIRS,
DOC_FILES_DIR,
DOCS_DIRECTORIES,
INTEGRATIONS_DIR,
LAYOUTS_DIR,
PACKS_FOLDER,
PLAYBOOKS_DIR,
SCRIPTS_DIR,
TESTS_DIRECTORIES,
XDRC_TEMPLATE_DIR,
)
from demisto_sdk.scripts.validate_content_path import (
Expand Down Expand Up @@ -422,3 +424,21 @@ def test_doc_file_valid(file_name: str):
def test_doc_file_invalid(file_name: str):
with pytest.raises(InvalidImageFileName):
_validate(DUMMY_PACK_PATH / DOC_FILES_DIR / file_name)


EXOTIC_SUFFIXES = ("xys", "sh", "pem")


@pytest.mark.parametrize("folder", TESTS_DIRECTORIES)
@pytest.mark.parametrize("suffix", EXOTIC_SUFFIXES)
def test_exotic_suffix_test_data(folder: str, suffix: str):
# should NOT raise InvalidSuffix
with pytest.raises(PathIsTestData):
_validate((DUMMY_PACK_PATH / folder / "file").with_suffix(f".{suffix}"))


@pytest.mark.parametrize("folder", DOCS_DIRECTORIES)
@pytest.mark.parametrize("suffix", EXOTIC_SUFFIXES)
def test_exotic_suffix_doc_data(folder: str, suffix: str):
# should NOT raise InvalidSuffix
_validate((DUMMY_PACK_PATH / folder / "file").with_suffix(f".{suffix}"))