Skip to content

Commit

Permalink
Revert "Fix run_fuzzers_test::CoverageReportIntegrationTest. (#7325)" (
Browse files Browse the repository at this point in the history
…#7466)

This reverts commit 9553ab1.
  • Loading branch information
jonathanmetzman committed Mar 29, 2022
1 parent 090c5fc commit 1abbd8b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion infra/cifuzz/filestore/github_actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions infra/cifuzz/filestore/github_actions/github_actions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 3 additions & 7 deletions infra/cifuzz/filestore/github_actions/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@
_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'
}


Expand Down
10 changes: 6 additions & 4 deletions infra/cifuzz/filestore/github_actions/github_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit 1abbd8b

Please sign in to comment.