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

Commit 9b6abed

Browse files
committed
fix test
1 parent 260978d commit 9b6abed

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

upload/tests/views/test_uploads.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -930,11 +930,16 @@ def test_uploads_post_github_enterprise_oidc_auth_jwks_url(
930930
"https://example.com/_services/token/.well-known/jwks"
931931
)
932932

933-
def test_uploads_post_github_enterprise_oidc_auth_no_url(self):
934-
# Mock the configuration to set the URL to None
933+
@patch("upload.views.uploads.AnalyticsService")
934+
@patch("upload.helpers.jwt.decode")
935+
@patch("upload.helpers.PyJWKClient")
936+
def test_uploads_post_github_enterprise_oidc_auth_no_url(
937+
self,
938+
mock_jwks_client,
939+
mock_jwt_decode,
940+
analytics_service_mock,
941+
):
935942
mock_config_helper(self.mocker, configs={"github_enterprise.url": None})
936-
937-
# Mock necessary services
938943
self.mocker.patch(
939944
"shared.api_archive.archive.StorageService.create_presigned_put",
940945
return_value="presigned put",
@@ -948,6 +953,12 @@ def test_uploads_post_github_enterprise_oidc_auth_no_url(self):
948953
author__upload_token_required_for_public_repos=True,
949954
private=False,
950955
)
956+
mock_jwt_decode.return_value = {
957+
"repository": f"url/{repository.name}",
958+
"repository_owner": repository.author.username,
959+
"iss": "https://enterprise-client.actions.githubusercontent.com",
960+
"audience": [settings.CODECOV_API_URL],
961+
}
951962
token = "ThisValueDoesNotMatterBecauseOf_mock_jwt_decode"
952963

953964
commit = CommitFactory(repository=repository)
@@ -972,6 +983,5 @@ def test_uploads_post_github_enterprise_oidc_auth_no_url(self):
972983
},
973984
headers={"Authorization": f"token {token}"},
974985
)
975-
976986
assert response.status_code == 401
977987
assert response.json().get("detail") == "Not valid tokenless upload"

0 commit comments

Comments
 (0)