Skip to content

Commit 49d979b

Browse files
userhas404dCopilot
andcommitted
fix: address second round of Copilot review feedback
- Fix docstring to say Bearer instead of token (matches implementation) - Remove unused imports/fixtures from redirect tests (GITHUB_HOSTS, MagicMock, temp_dir, monkeypatch) - Replace __import__('io').BytesIO() with normal import io pattern in test_presets.py Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fe23095 commit 49d979b

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/specify_cli/_github_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def build_github_request(url: str) -> urllib.request.Request:
2727
"""Build a urllib Request, adding a GitHub auth header when available.
2828
2929
Reads GITHUB_TOKEN or GH_TOKEN from the environment and attaches an
30-
``Authorization: token <value>`` header when the target hostname is one
30+
``Authorization: Bearer <value>`` header when the target hostname is one
3131
of the known GitHub-owned domains. Non-GitHub URLs are returned as plain
3232
requests so credentials are never leaked to third-party hosts.
3333
"""

tests/test_extensions.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,11 +2514,10 @@ def test_make_request_token_added_for_codeload_github_com(self, temp_dir, monkey
25142514
req = catalog._make_request("https://codeload.github.com/org/repo/zip/refs/tags/v1.0.0")
25152515
assert req.get_header("Authorization") == "Bearer ghp_testtoken"
25162516

2517-
def test_redirect_preserves_auth_for_github_to_codeload(self, temp_dir, monkeypatch):
2517+
def test_redirect_preserves_auth_for_github_to_codeload(self):
25182518
"""Auth header is preserved when GitHub redirects to codeload.github.com."""
2519-
from specify_cli._github_http import _StripAuthOnRedirect, GITHUB_HOSTS
2519+
from specify_cli._github_http import _StripAuthOnRedirect
25202520
from urllib.request import Request
2521-
from unittest.mock import MagicMock
25222521
import io
25232522

25242523
handler = _StripAuthOnRedirect()
@@ -2531,7 +2530,7 @@ def test_redirect_preserves_auth_for_github_to_codeload(self, temp_dir, monkeypa
25312530
auth = new_req.get_header("Authorization") or new_req.unredirected_hdrs.get("Authorization")
25322531
assert auth == "Bearer ghp_test"
25332532

2534-
def test_redirect_strips_auth_for_github_to_external(self, temp_dir, monkeypatch):
2533+
def test_redirect_strips_auth_for_github_to_external(self):
25352534
"""Auth header is stripped when GitHub redirects to a non-GitHub host."""
25362535
from specify_cli._github_http import _StripAuthOnRedirect
25372536
from urllib.request import Request

tests/test_presets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,8 @@ def test_download_pack_sends_auth_header(self, project_dir, monkeypatch):
14891489
monkeypatch.setenv("GITHUB_TOKEN", "ghp_testtoken")
14901490
catalog = PresetCatalog(project_dir)
14911491

1492-
zip_buf = __import__("io").BytesIO()
1492+
import io
1493+
zip_buf = io.BytesIO()
14931494
with zipfile.ZipFile(zip_buf, "w") as zf:
14941495
zf.writestr("preset.yml", "id: test-pack\nname: Test\nversion: 1.0.0\n")
14951496
zip_bytes = zip_buf.getvalue()

0 commit comments

Comments
 (0)