Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 260978d

Browse files
committed
add test
1 parent 38d82fe commit 260978d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

upload/tests/views/test_uploads.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,3 +929,49 @@ def test_uploads_post_github_enterprise_oidc_auth_jwks_url(
929929
mock_jwks_client.assert_called_with(
930930
"https://example.com/_services/token/.well-known/jwks"
931931
)
932+
933+
def test_uploads_post_github_enterprise_oidc_auth_no_url(self):
934+
# Mock the configuration to set the URL to None
935+
mock_config_helper(self.mocker, configs={"github_enterprise.url": None})
936+
937+
# Mock necessary services
938+
self.mocker.patch(
939+
"shared.api_archive.archive.StorageService.create_presigned_put",
940+
return_value="presigned put",
941+
)
942+
self.mocker.patch("upload.views.uploads.trigger_upload_task", return_value=True)
943+
944+
repository = RepositoryFactory(
945+
name="the_repo",
946+
author__username="codecov",
947+
author__service="github_enterprise",
948+
author__upload_token_required_for_public_repos=True,
949+
private=False,
950+
)
951+
token = "ThisValueDoesNotMatterBecauseOf_mock_jwt_decode"
952+
953+
commit = CommitFactory(repository=repository)
954+
commit_report = CommitReport.objects.create(commit=commit, code="code")
955+
956+
client = APIClient()
957+
url = reverse(
958+
"new_upload.uploads",
959+
args=[
960+
"github_enterprise",
961+
"codecov::::the_repo",
962+
commit.commitid,
963+
commit_report.code,
964+
],
965+
)
966+
response = client.post(
967+
url,
968+
{
969+
"state": "uploaded",
970+
"flags": ["flag1", "flag2"],
971+
"version": "version",
972+
},
973+
headers={"Authorization": f"token {token}"},
974+
)
975+
976+
assert response.status_code == 401
977+
assert response.json().get("detail") == "Not valid tokenless upload"

0 commit comments

Comments
 (0)