Skip to content

Commit cd8a437

Browse files
committed
test: reject mutable raw GitHub sources
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 1ddaf25 commit cd8a437

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎tests/test_sync_upstream.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ def test_rejects_invalid_hash(self) -> None:
5757
with self.assertRaisesRegex(ValueError, "sha256"):
5858
load_sources(manifest)
5959

60+
def test_rejects_mutable_raw_github_revision(self) -> None:
61+
with tempfile.TemporaryDirectory() as directory:
62+
manifest = Path(directory) / "sources.json"
63+
manifest.write_text(
64+
json.dumps(
65+
{
66+
"sources": [
67+
{
68+
"name": "workflow",
69+
"url": "https://raw.githubusercontent.com/example/project/master/workflow.yml",
70+
"sha256": "a" * 64,
71+
"destination": "templates/workflow.yml",
72+
}
73+
]
74+
}
75+
),
76+
encoding="utf-8",
77+
)
78+
79+
with self.assertRaisesRegex(ValueError, "40-character Git commit SHA"):
80+
load_sources(manifest)
81+
6082
def test_sync_writes_verified_content(self) -> None:
6183
content = b"name: Example\n"
6284
source = Source(

0 commit comments

Comments
 (0)