Define the catalog publication identity
This commit is contained in:
@@ -26,11 +26,42 @@ from govoplan_release.publisher import ( # noqa: E402
|
|||||||
verify_committed_publication,
|
verify_committed_publication,
|
||||||
verify_remote_branch_head,
|
verify_remote_branch_head,
|
||||||
verify_remote_publication,
|
verify_remote_publication,
|
||||||
|
_sanitized_git_environment,
|
||||||
_trusted_npm_command,
|
_trusted_npm_command,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ReleaseCatalogPublicationTests(unittest.TestCase):
|
class ReleaseCatalogPublicationTests(unittest.TestCase):
|
||||||
|
def test_publication_git_identity_is_fixed_and_non_personal(self) -> None:
|
||||||
|
with patch.dict(
|
||||||
|
os.environ,
|
||||||
|
{
|
||||||
|
"GIT_AUTHOR_NAME": "Attacker",
|
||||||
|
"GIT_AUTHOR_EMAIL": "attacker@example.test",
|
||||||
|
"GIT_COMMITTER_NAME": "Attacker",
|
||||||
|
"GIT_COMMITTER_EMAIL": "attacker@example.test",
|
||||||
|
},
|
||||||
|
clear=False,
|
||||||
|
):
|
||||||
|
environment = _sanitized_git_environment()
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
"GovOPlaN Release Automation",
|
||||||
|
environment["GIT_AUTHOR_NAME"],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"release@govoplan.invalid",
|
||||||
|
environment["GIT_AUTHOR_EMAIL"],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
environment["GIT_AUTHOR_NAME"],
|
||||||
|
environment["GIT_COMMITTER_NAME"],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
environment["GIT_AUTHOR_EMAIL"],
|
||||||
|
environment["GIT_COMMITTER_EMAIL"],
|
||||||
|
)
|
||||||
|
|
||||||
def test_build_command_uses_its_pinned_node_directory(self) -> None:
|
def test_build_command_uses_its_pinned_node_directory(self) -> None:
|
||||||
completed = subprocess.CompletedProcess(
|
completed = subprocess.CompletedProcess(
|
||||||
["/trusted/node/bin/npm"],
|
["/trusted/node/bin/npm"],
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ _MAX_GIT_OUTPUT_BYTES = 16 * 1024 * 1024
|
|||||||
_MAX_REMOTE_METADATA_BYTES = 16 * 1024
|
_MAX_REMOTE_METADATA_BYTES = 16 * 1024
|
||||||
_MAX_REMOVED_TREE_ENTRIES = 100_000
|
_MAX_REMOVED_TREE_ENTRIES = 100_000
|
||||||
_MAX_REMOVED_TREE_DEPTH = 64
|
_MAX_REMOVED_TREE_DEPTH = 64
|
||||||
|
_RELEASE_GIT_NAME = "GovOPlaN Release Automation"
|
||||||
|
_RELEASE_GIT_EMAIL = "release@govoplan.invalid"
|
||||||
|
|
||||||
|
|
||||||
class CatalogPublicationAmbiguousError(RuntimeError):
|
class CatalogPublicationAmbiguousError(RuntimeError):
|
||||||
@@ -1898,6 +1900,10 @@ def _sanitized_git_environment(
|
|||||||
"GIT_CONFIG_COUNT": "0",
|
"GIT_CONFIG_COUNT": "0",
|
||||||
"GIT_CONFIG_GLOBAL": os.devnull,
|
"GIT_CONFIG_GLOBAL": os.devnull,
|
||||||
"GIT_CONFIG_NOSYSTEM": "1",
|
"GIT_CONFIG_NOSYSTEM": "1",
|
||||||
|
"GIT_AUTHOR_EMAIL": _RELEASE_GIT_EMAIL,
|
||||||
|
"GIT_AUTHOR_NAME": _RELEASE_GIT_NAME,
|
||||||
|
"GIT_COMMITTER_EMAIL": _RELEASE_GIT_EMAIL,
|
||||||
|
"GIT_COMMITTER_NAME": _RELEASE_GIT_NAME,
|
||||||
"GIT_NO_REPLACE_OBJECTS": "1",
|
"GIT_NO_REPLACE_OBJECTS": "1",
|
||||||
"GIT_PAGER": "cat",
|
"GIT_PAGER": "cat",
|
||||||
"GIT_SSH_COMMAND": "/usr/bin/ssh -o BatchMode=yes -o ConnectTimeout=8",
|
"GIT_SSH_COMMAND": "/usr/bin/ssh -o BatchMode=yes -o ConnectTimeout=8",
|
||||||
|
|||||||
Reference in New Issue
Block a user