diff options
author | Lukasz Jarocki <lukasz.jarocki@sonarsource.com> | 2021-04-06 10:05:14 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-04-06 20:03:20 +0000 |
commit | e08feaed8902703c7527cb4dfccb389489d0701f (patch) | |
tree | 19d2d21a3fe38bb52d273aa104e5c84944c43e9a /server/sonar-alm-client | |
parent | 39abd3de73733b18e99c5e81ab7f2dec45d9aec7 (diff) | |
download | sonarqube-e08feaed8902703c7527cb4dfccb389489d0701f.tar.gz sonarqube-e08feaed8902703c7527cb4dfccb389489d0701f.zip |
SONAR-14644 updated headers for github api
Diffstat (limited to 'server/sonar-alm-client')
2 files changed, 8 insertions, 8 deletions
diff --git a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationHttpClientImpl.java b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationHttpClientImpl.java index d5655e3b048..0f56ffc5c52 100644 --- a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationHttpClientImpl.java +++ b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationHttpClientImpl.java @@ -51,8 +51,9 @@ public class GithubApplicationHttpClientImpl implements GithubApplicationHttpCli private static final Logger LOG = Loggers.get(GithubApplicationHttpClientImpl.class); private static final Pattern NEXT_LINK_PATTERN = Pattern.compile(".*<(.*)>; rel=\"next\""); - private static final String MACHINE_MAN_PREVIEW_JSON = "application/vnd.github.machine-man-preview+json"; + private static final String GITHUB_API_VERSION_JSON = "application/vnd.github.v3+json"; private static final String ANTIOPE_PREVIEW_JSON = "application/vnd.github.antiope-preview+json"; + private static final String MACHINE_MAN_PREVIEW_JSON = "application/vnd.github.machine-man-preview+json"; private final OkHttpClient client; @@ -162,13 +163,10 @@ public class GithubApplicationHttpClientImpl implements GithubApplicationHttpCli } private static Request.Builder newRequestBuilder(String appUrl, @Nullable AccessToken token, String endPoint) { - Request.Builder url = new Request.Builder() - .url(toAbsoluteEndPoint(appUrl, endPoint)); + Request.Builder url = new Request.Builder().url(toAbsoluteEndPoint(appUrl, endPoint)); if (token != null) { - url - .addHeader("Authorization", token.getAuthorizationHeaderPrefix() + " " + token) - // TODO: Remove when CheckAPI is no longer in beta - .addHeader("Accept", ANTIOPE_PREVIEW_JSON + ", " + MACHINE_MAN_PREVIEW_JSON); + url.addHeader("Authorization", token.getAuthorizationHeaderPrefix() + " " + token); + url.addHeader("Accept", String.format("%s, %s, %s", ANTIOPE_PREVIEW_JSON, MACHINE_MAN_PREVIEW_JSON, GITHUB_API_VERSION_JSON)); } return url; } diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java index 44516fbaeaf..5922ececdb2 100644 --- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java +++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java @@ -46,7 +46,9 @@ import static org.junit.Assert.fail; @RunWith(DataProviderRunner.class) public class GithubApplicationHttpClientImplTest { - private static final String BETA_API_HEADER = "application/vnd.github.antiope-preview+json, application/vnd.github.machine-man-preview+json"; + private static final String BETA_API_HEADER = "application/vnd.github.antiope-preview+json, " + + "application/vnd.github.machine-man-preview+json, " + + "application/vnd.github.v3+json"; @Rule public MockWebServer server = new MockWebServer(); |