diff options
author | jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> | 2022-03-28 23:46:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-29 14:46:36 +1100 |
commit | 1abbd8bf089660da96367b0370855f99e3aa2df6 (patch) | |
tree | 2055137424310682dd05ea72e43966b8fd172b06 /infra/cifuzz | |
parent | 090c5fc5861180ffdf53662c4f5dfcc677410d08 (diff) |
Revert "Fix run_fuzzers_test::CoverageReportIntegrationTest. (#7325)" (#7466)
This reverts commit 9553ab10d770ef7aeba47829e3e7dbd71dc6af6c.
Diffstat (limited to 'infra/cifuzz')
4 files changed, 14 insertions, 15 deletions
diff --git a/infra/cifuzz/filestore/github_actions/__init__.py b/infra/cifuzz/filestore/github_actions/__init__.py index f8daab55..d1cd7928 100644 --- a/infra/cifuzz/filestore/github_actions/__init__.py +++ b/infra/cifuzz/filestore/github_actions/__init__.py @@ -63,7 +63,7 @@ class GithubActionsFilestore(filestore.BaseFilestore): def __init__(self, config): super().__init__(config) - self.github_api_http_headers = github_api.get_http_auth_headers() + self.github_api_http_headers = github_api.get_http_auth_headers(config) def _get_artifact_name(self, name): """Returns |name| prefixed with |self.ARITFACT_PREFIX| if it isn't already diff --git a/infra/cifuzz/filestore/github_actions/github_actions_test.py b/infra/cifuzz/filestore/github_actions/github_actions_test.py index 015901e0..90a0b070 100644 --- a/infra/cifuzz/filestore/github_actions/github_actions_test.py +++ b/infra/cifuzz/filestore/github_actions/github_actions_test.py @@ -39,20 +39,21 @@ class GithubActionsFilestoreTest(fake_filesystem_unittest.TestCase): @mock.patch('platform_config.github._get_event_data', return_value={}) def setUp(self, _): # pylint: disable=arguments-differ test_helpers.patch_environ(self) + self.token = 'example githubtoken' self.owner = 'exampleowner' self.repo = 'examplerepo' os.environ['GITHUB_REPOSITORY'] = f'{self.owner}/{self.repo}' os.environ['GITHUB_EVENT_PATH'] = '/fake' os.environ['CFL_PLATFORM'] = 'github' os.environ['GITHUB_WORKSPACE'] = '/workspace' - os.environ['ACTIONS_RUNTIME_TOKEN'] = 'githubtoken' - self.config = test_helpers.create_run_config() + self.config = test_helpers.create_run_config(token=self.token) self.local_dir = '/local-dir' self.testcase = os.path.join(self.local_dir, 'testcase') def _get_expected_http_headers(self): return { - 'Authorization': 'Bearer githubtoken', + 'Authorization': f'token {self.token}', + 'Accept': 'application/vnd.github.v3+json', } @mock.patch('filestore.github_actions.github_api.list_artifacts') diff --git a/infra/cifuzz/filestore/github_actions/github_api.py b/infra/cifuzz/filestore/github_actions/github_api.py index 457fb1bb..191b7505 100644 --- a/infra/cifuzz/filestore/github_actions/github_api.py +++ b/infra/cifuzz/filestore/github_actions/github_api.py @@ -35,16 +35,12 @@ _GET_ATTEMPTS = 3 _GET_BACKOFF = 1 -def get_http_auth_headers(): +def get_http_auth_headers(config): """Returns HTTP headers for authentication to the API.""" - # Undocumented token used for artifacts auth. - token = os.environ.get('ACTIONS_RUNTIME_TOKEN') - if not token: - return {} - - authorization = f'Bearer {token}' + authorization = f'token {config.token}' return { 'Authorization': authorization, + 'Accept': 'application/vnd.github.v3+json' } diff --git a/infra/cifuzz/filestore/github_actions/github_api_test.py b/infra/cifuzz/filestore/github_actions/github_api_test.py index 8027992d..1d6f54e4 100644 --- a/infra/cifuzz/filestore/github_actions/github_api_test.py +++ b/infra/cifuzz/filestore/github_actions/github_api_test.py @@ -31,9 +31,11 @@ class GetHttpAuthHeaders(unittest.TestCase): def test_get_http_auth_headers(self): """Tests that get_http_auth_headers returns the correct result.""" - test_helpers.patch_environ(self) - os.environ['ACTIONS_RUNTIME_TOKEN'] = 'githubtoken' + token = 'example githubtoken' + run_config = test_helpers.create_run_config(token=token) expected_headers = { - 'Authorization': 'Bearer githubtoken', + 'Authorization': f'token {token}', + 'Accept': 'application/vnd.github.v3+json', } - self.assertEqual(expected_headers, github_api.get_http_auth_headers()) + self.assertEqual(expected_headers, + github_api.get_http_auth_headers(run_config)) |