@@ -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