From 49f0c52ea17416680df7317e542332770f8333b2 Mon Sep 17 00:00:00 2001 From: Belen Pruvost Date: Thu, 3 Jun 2021 12:42:55 +0200 Subject: [PATCH] SONAR-14812 - BBC Integration Tests --- .cirrus.yml | 25 +++++++ .../AlmIntegrationsService.java | 32 +++++++++ .../ImportBitbucketcloudRepoRequest.java | 59 ++++++++++++++++ .../SearchBitbucketcloudReposRequest.java | 70 +++++++++++++++++++ .../client/almintegrations/SetPatRequest.java | 10 +++ 5 files changed, 196 insertions(+) create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportBitbucketcloudRepoRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/SearchBitbucketcloudReposRequest.java diff --git a/.cirrus.yml b/.cirrus.yml index 665a8c3d35e..6bf844e3d47 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -208,6 +208,31 @@ qa_bitbucket_task: on_failure: <<: *REPORTS_JUNIT_SCREENSHOTS_ON_FAILURE_TEMPLATE +qa_bitbucket_cloud_task: + <<: *ONLY_NIGHTLY_DEPENDING_ON_BUILD_TEMPLATE + gke_container: + <<: *GKE_CONTAINER_TEMPLATE + cpu: 2.4 + memory: 5Gb + env: + # No need to clone the full history. + # Depth of 1 is not enough because it would fail the build in case of consecutive pushes + # (example of error: "Hard resetting to c968ecaf7a1942dacecd78480b3751ac74d53c33...Failed to force reset to c968ecaf7a1942dacecd78480b3751ac74d53c33: object not found!") + CIRRUS_CLONE_DEPTH: 50 + QA_CATEGORY: BITBUCKET_CLOUD + BBC_CLIENT_ID: ENCRYPTED[f1c2c57d5f02885345b3db5776a3b28f5dbcc89723809f73ad05ada903ece9584f1dfe61b026c10eabd72c75d1258bac] + BBC_CLIENT_SECRET: ENCRYPTED[39cc89ce4695c243fd688e687879bd473a60882fd30ba8613d6697e5d2b04e2017c68cae3a9a7ed9704f69c52bf229ee] + BBC_READ_REPOS_APP_PASSWORD: ENCRYPTED[d33b02d02987e188b5cec2a14f6ddd04d1fcac39ed5d6ced08891fc562ebb6721c9fbf307c0eba81df78c83f75b3c27c] + BBC_USERNAME: ENCRYPTED[f0af9be9d2fbaa55fbf69e4fce706ebc9131e0dc22cf8bce5d7ab2e0c2b57aff3ddbf6b3b77166e803a6000276256cea] + gradle_cache: + folder: ~/.gradle/caches + script: + - ./private/cirrus/cirrus-qa.sh h2 + cleanup_before_cache_script: + - ./private/cirrus/cleanup-gradle-cache.sh + on_failure: + <<: *REPORTS_JUNIT_SCREENSHOTS_ON_FAILURE_TEMPLATE + qa_ha_task: <<: *ONLY_NIGHTLY_DEPENDING_ON_BUILD_TEMPLATE gke_container: diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/AlmIntegrationsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/AlmIntegrationsService.java index 13c73ed4e67..479c8d04245 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/AlmIntegrationsService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/AlmIntegrationsService.java @@ -70,6 +70,22 @@ public class AlmIntegrationsService extends BaseService { Projects.CreateWsResponse.parser()); } + /** + * This is part of the internal API. + * This is a POST request. + * + * @see Further information about this action online (including a response example) + * @since 8.2 + */ + public Projects.CreateWsResponse importBitbucketcloudProject(ImportBitbucketcloudRepoRequest request) { + return call( + new PostRequest(path("import_bitbucketcloud_repo")) + .setParam("almSetting", request.getAlmSetting()) + .setParam("repositorySlug", request.getRepositorySlug()) + .setMediaType(MediaTypes.JSON), + Projects.CreateWsResponse.parser()); + } + /** * This is a POST request. * @@ -166,6 +182,21 @@ public class AlmIntegrationsService extends BaseService { AlmIntegrations.SearchBitbucketserverReposWsResponse.parser()); } + /** + * This is part of the internal API. + * This is a GET request. + * + * @see Further information about this action online (including a response example) + * @since 8.2 + */ + public AlmIntegrations.SearchBitbucketcloudReposWsResponse searchBitbucketcloudRepos(SearchBitbucketcloudReposRequest request) { + return call( + new GetRequest(path("search_bitbucketcloud_repos")) + .setParam("almSetting", request.getAlmSetting()) + .setMediaType(MediaTypes.JSON), + AlmIntegrations.SearchBitbucketcloudReposWsResponse.parser()); + } + /** * This is part of the internal API. * This is a POST request. @@ -178,6 +209,7 @@ public class AlmIntegrationsService extends BaseService { new PostRequest(path("set_pat")) .setParam("almSetting", request.getAlmSetting()) .setParam("pat", request.getPat()) + .setParam("username", request.getUsername()) .setMediaType(MediaTypes.JSON) ).content(); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportBitbucketcloudRepoRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportBitbucketcloudRepoRequest.java new file mode 100644 index 00000000000..efd915341ad --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportBitbucketcloudRepoRequest.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.ws.client.almintegrations; + +import javax.annotation.Generated; + +/** + * This is part of the internal API. + * This is a POST request. + * @see Further information about this action online (including a response example) + * @since 8.2 + */ +@Generated("sonar-ws-generator") +public class ImportBitbucketcloudRepoRequest { + + private String almSetting; + private String repositorySlug; + + /** + * This is a mandatory parameter. + */ + public ImportBitbucketcloudRepoRequest setAlmSetting(String almSetting) { + this.almSetting = almSetting; + return this; + } + + public String getAlmSetting() { + return almSetting; + } + + /** + * This is a mandatory parameter. + */ + public ImportBitbucketcloudRepoRequest setRepositorySlug(String repositorySlug) { + this.repositorySlug = repositorySlug; + return this; + } + + public String getRepositorySlug() { + return repositorySlug; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/SearchBitbucketcloudReposRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/SearchBitbucketcloudReposRequest.java new file mode 100644 index 00000000000..6246babd2f5 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/SearchBitbucketcloudReposRequest.java @@ -0,0 +1,70 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.ws.client.almintegrations; + +import javax.annotation.Generated; + +/** + * This is part of the internal API. + * This is a POST request. + * @see Further information about this action online (including a response example) + * @since 8.2 + */ +@Generated("sonar-ws-generator") +public class SearchBitbucketcloudReposRequest { + + private String almSetting; + private String projectName; + private String repositoryName; + + /** + * This is a mandatory parameter. + */ + public SearchBitbucketcloudReposRequest setAlmSetting(String almSetting) { + this.almSetting = almSetting; + return this; + } + + public String getAlmSetting() { + return almSetting; + } + + /** + */ + public SearchBitbucketcloudReposRequest setProjectName(String projectName) { + this.projectName = projectName; + return this; + } + + public String getProjectName() { + return projectName; + } + + /** + */ + public SearchBitbucketcloudReposRequest setRepositoryName(String repositoryName) { + this.repositoryName = repositoryName; + return this; + } + + public String getRepositoryName() { + return repositoryName; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/SetPatRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/SetPatRequest.java index faa42bbe760..77986f21859 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/SetPatRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/SetPatRequest.java @@ -32,6 +32,7 @@ public class SetPatRequest { private String almSetting; private String pat; + private String username; /** * This is a mandatory parameter. @@ -56,4 +57,13 @@ public class SetPatRequest { public String getPat() { return pat; } + + public SetPatRequest setUsername(String username) { + this.username = username; + return this; + } + + public String getUsername() { + return username; + } } -- 2.39.5