fix: scope the auth header to the Gitea server; README trust note
- review.yml and git.push set http.<GITHUB_SERVER_URL>/.extraHeader, so the bot token is sent only to the Gitea server; git.push falls back to the unscoped key when no server is known. - README: a same-repository PR runs the caller workflow from its head, so the safeguards bound PR content, not edits to the caller; drafter: local fails the job. - Tests: the source-grep fetch test is replaced by a behavioral one over a resumed run (fetch ends options, push uses the scoped key); the no-op summary test is dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7783b6e78f
commit
70c762bf8a
7 files changed
+64
-23
No files matched your search
+23
-6
@@ -4,6 +4,7 @@ import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from pathlib import Path
|
||||
|
||||
from docs_review.cli import main
|
||||
@@ -169,6 +170,28 @@ class ClaudeDrafterTests(CliCase):
|
||||
self.fake.email)
|
||||
self.assertEqual(self.comment_bodies(), [])
|
||||
|
||||
def test_resume_fetches_with_end_of_options_and_scoped_push(self):
|
||||
self.assertEqual(self.run_pr(self.feature_commit()), 0)
|
||||
calls = []
|
||||
real = subprocess.run
|
||||
|
||||
def record(argv, **kw):
|
||||
calls.append((list(argv), kw.get("env") or {}))
|
||||
return real(argv, **kw)
|
||||
|
||||
server = "https://gitea.example.org"
|
||||
sha = self.feature_commit()
|
||||
with mock.patch("docs_review.git.subprocess.run", side_effect=record):
|
||||
self.assertEqual(self.run_pr(sha, GITHUB_SERVER_URL=server), 0)
|
||||
# The harness's own `git fetch -q origin` (run_pr's setup) names no branch.
|
||||
fetches = [a for a, _ in calls if a[:2] == ["git", "fetch"] and a[-1] != "origin"]
|
||||
self.assertTrue(fetches)
|
||||
for argv in fetches:
|
||||
self.assertEqual(argv[-2:], ["--end-of-options", BRANCH])
|
||||
pushes = [e for a, e in calls if a[:2] == ["git", "push"]]
|
||||
self.assertEqual(len(pushes), 1)
|
||||
self.assertEqual(pushes[0]["GIT_CONFIG_KEY_0"], f"http.{server}/.extraHeader")
|
||||
|
||||
def test_rerun_appends_and_keeps_hand_edit(self):
|
||||
self.assertEqual(self.run_pr(self.feature_commit()), 0)
|
||||
git(self.seed, "fetch", "-q", "origin", BRANCH)
|
||||
@@ -256,12 +279,6 @@ class CredentialAndSummaryTests(CliCase):
|
||||
self.assertIn("total_cost_usd: 0.12", text)
|
||||
self.assertIn("num_turns: 3", text)
|
||||
|
||||
def test_no_summary_file_without_the_variable(self):
|
||||
sha = self.feature_commit()
|
||||
self.env.pop("GITHUB_STEP_SUMMARY", None)
|
||||
self.assertEqual(self.run_pr(sha), 0)
|
||||
self.assertFalse((Path(self.env["RUNNER_TEMP"]) / "step-summary.md").exists())
|
||||
|
||||
|
||||
class DocsPrLifecycleTests(CliCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in new issue
Block a user