Skip to content
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
18 changes: 18 additions & 0 deletions local_hooks/app_tests/json_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
from pathlib import Path

SKIP_SDK_APP = {"success": True, "message": "TEST SKIPPED - SDK app detected"}
CONNECTOR_TEMPLATE_IDENTITY = {
"appid": "ffffffff-ffff-4fff-afff-ffffffffffff",
"name": "Example App Name",
"package_name": "phantom_template",
}


class JSONTests(TestSuite):
Expand All @@ -32,6 +37,13 @@ def __init__(self, repo_location: Path) -> None:

self._app_is_certified = self._parser.app_json["publisher"] == "Splunk"

def _is_connector_template_placeholder(self) -> bool:
"""Return whether this is the canonical connector-template placeholder app."""
return self._app_code_dir.name == "connector-template" and all(
self._app_json.get(field) == value
for field, value in CONNECTOR_TEMPLATE_IDENTITY.items()
)

@staticmethod
def format_as_index(indices: list[Any], container: str = "schema") -> str:
"""
Expand Down Expand Up @@ -250,6 +262,9 @@ def check_valid_app_name_and_guid(self):
"""
App Name and GUID must be unique
"""
if self._is_connector_template_placeholder():
return create_test_result_response(success=True, message=TEST_PASS_MESSAGE)

app_name = self._app_json["name"]
app_guid = self._app_json["appid"]

Expand Down Expand Up @@ -285,6 +300,9 @@ def check_app_package_name(self):
"""
Package name is unique
"""
if self._is_connector_template_placeholder():
return create_test_result_response(success=True, message=TEST_PASS_MESSAGE)

package_name = self._app_json["package_name"]
app_guid = self._app_json["appid"]

Expand Down
30 changes: 30 additions & 0 deletions local_hooks/tests/test_static_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,33 @@ def test_pip313_dependencies_still_requires_generated_key(tmp_path: Path):
assert result["message"] == (
"App json must contain 'pip313_dependencies' key when requirements.txt exists"
)


def test_connector_template_placeholder_skips_registry_checks(tmp_path: Path):
suite = JSONTests.__new__(JSONTests)
suite._app_code_dir = tmp_path / "connector-template"
suite._app_json = {
"appid": "ffffffff-ffff-4fff-afff-ffffffffffff",
"name": "Example App Name",
"package_name": "phantom_template",
}

with patch("local_hooks.app_tests.json_tests.requests.get") as mock_get:
name_result = suite.check_valid_app_name_and_guid()
package_result = suite.check_app_package_name()

assert name_result["success"] is True
assert package_result["success"] is True
mock_get.assert_not_called()


def test_connector_template_exemption_requires_exact_placeholder(tmp_path: Path):
suite = JSONTests.__new__(JSONTests)
suite._app_code_dir = tmp_path / "connector-template"
suite._app_json = {
"appid": "ffffffff-ffff-4fff-afff-ffffffffffff",
"name": "A Real App",
"package_name": "phantom_template",
}

assert suite._is_connector_template_placeholder() is False
Loading