From b9ee3198bbbbf0c242a208855f6f7d906653baf2 Mon Sep 17 00:00:00 2001 From: Aurelien Poscia Date: Thu, 12 Oct 2023 16:12:01 +0200 Subject: [PATCH] SONAR-20640 removed 'organization' parameter from api/alm_integrations/import_github_project --- .../github/ImportGithubProjectActionIT.java | 16 ---------------- .../ws/GitHubDevOpsPlatformServiceTest.java | 2 +- .../java/org/sonar/core/ce/package-info.java | 19 +++++++++++++++++++ .../AlmIntegrationsService.java | 1 - .../ImportGithubProjectRequest.java | 14 -------------- 5 files changed, 20 insertions(+), 32 deletions(-) diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java index d4c0480940c..501c5bbc09a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java @@ -90,7 +90,6 @@ import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME; import static org.sonar.db.newcodeperiod.NewCodePeriodType.NUMBER_OF_DAYS; import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH; import static org.sonar.server.almintegration.ws.ImportHelper.PARAM_ALM_SETTING; -import static org.sonar.server.almintegration.ws.github.ImportGithubProjectAction.PARAM_ORGANIZATION; import static org.sonar.server.almintegration.ws.github.ImportGithubProjectAction.PARAM_REPOSITORY_KEY; import static org.sonar.server.tester.UserSessionRule.standalone; import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NEW_CODE_DEFINITION_TYPE; @@ -173,7 +172,6 @@ public class ImportGithubProjectActionIT { Projects.CreateWsResponse response = ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME) .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "NUMBER_OF_DAYS") .setParam(PARAM_NEW_CODE_DEFINITION_VALUE, "30") @@ -202,7 +200,6 @@ public class ImportGithubProjectActionIT { Projects.CreateWsResponse response = ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME) .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "NUMBER_OF_DAYS") .setParam(PARAM_NEW_CODE_DEFINITION_VALUE, "30") @@ -234,7 +231,6 @@ public class ImportGithubProjectActionIT { Projects.CreateWsResponse response = ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME) .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "reference_branch") .executeProtobuf(Projects.CreateWsResponse.class); @@ -262,7 +258,6 @@ public class ImportGithubProjectActionIT { Projects.CreateWsResponse response = ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME) .setParam(PARAM_NEW_CODE_DEFINITION_TYPE, "reference_branch") .executeProtobuf(Projects.CreateWsResponse.class); @@ -289,7 +284,6 @@ public class ImportGithubProjectActionIT { Projects.CreateWsResponse response = ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "Hello-World") .executeProtobuf(Projects.CreateWsResponse.class); @@ -307,7 +301,6 @@ public class ImportGithubProjectActionIT { ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME) .executeProtobuf(Projects.CreateWsResponse.class); @@ -327,7 +320,6 @@ public class ImportGithubProjectActionIT { ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME) .executeProtobuf(Projects.CreateWsResponse.class); @@ -367,7 +359,6 @@ public class ImportGithubProjectActionIT { TestRequest request = ws.newRequest() .setParam(PARAM_ALM_SETTING, "unknown") - .setParam(PARAM_ORGANIZATION, "test") .setParam(PARAM_REPOSITORY_KEY, "test/repo"); assertThatThrownBy(request::execute) .isInstanceOf(NotFoundException.class) @@ -380,7 +371,6 @@ public class ImportGithubProjectActionIT { userSession.logIn(user).addPermission(GlobalPermission.PROVISION_PROJECTS); TestRequest request = ws.newRequest() - .setParam(PARAM_ORGANIZATION, "test") .setParam(PARAM_REPOSITORY_KEY, "test/repo"); assertThatThrownBy(request::execute) .isInstanceOf(NotFoundException.class) @@ -395,7 +385,6 @@ public class ImportGithubProjectActionIT { db.almSettings().insertGitHubAlmSetting(); TestRequest request = ws.newRequest() - .setParam(PARAM_ORGANIZATION, "test") .setParam(PARAM_REPOSITORY_KEY, "test/repo"); assertThatThrownBy(request::execute) .isInstanceOf(IllegalArgumentException.class) @@ -411,7 +400,6 @@ public class ImportGithubProjectActionIT { TestRequest request = ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME); assertThatNoException().isThrownBy(request::execute); @@ -420,7 +408,6 @@ public class ImportGithubProjectActionIT { private Projects.CreateWsResponse callWebService(AlmSettingDto githubAlmSetting) { return ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "octocat") .setParam(PARAM_REPOSITORY_KEY, "octocat/" + PROJECT_KEY_NAME) .executeProtobuf(Projects.CreateWsResponse.class); } @@ -438,7 +425,6 @@ public class ImportGithubProjectActionIT { public void fail_when_not_logged_in() { TestRequest request = ws.newRequest() .setParam(PARAM_ALM_SETTING, "asdfghjkl") - .setParam(PARAM_ORGANIZATION, "test") .setParam(PARAM_REPOSITORY_KEY, "test/repo"); assertThatThrownBy(request::execute) .isInstanceOf(UnauthorizedException.class); @@ -457,7 +443,6 @@ public class ImportGithubProjectActionIT { TestRequest request = ws.newRequest() .setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()) - .setParam(PARAM_ORGANIZATION, "test") .setParam(PARAM_REPOSITORY_KEY, "test/repo"); assertThatThrownBy(request::execute) .isInstanceOf(IllegalArgumentException.class) @@ -474,7 +459,6 @@ public class ImportGithubProjectActionIT { .extracting(WebService.Param::key, WebService.Param::isRequired) .containsExactlyInAnyOrder( tuple(PARAM_ALM_SETTING, false), - tuple(PARAM_ORGANIZATION, true), tuple(PARAM_REPOSITORY_KEY, true), tuple(PARAM_NEW_CODE_DEFINITION_TYPE, false), tuple(PARAM_NEW_CODE_DEFINITION_VALUE, false)); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/GitHubDevOpsPlatformServiceTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/GitHubDevOpsPlatformServiceTest.java index 7d2a4be977b..db7328ae407 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/GitHubDevOpsPlatformServiceTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/GitHubDevOpsPlatformServiceTest.java @@ -286,7 +286,7 @@ public class GitHubDevOpsPlatformServiceTest { when(repository.getDefaultBranch()).thenReturn(MAIN_BRANCH_NAME); when(repository.getName()).thenReturn(PROJECT_NAME); when(repository.getFullName()).thenReturn(GITHUB_REPO_FULL_NAME); - when(githubApplicationClient.getRepository(GITHUB_API_URL, appInstallationToken, PROJECT_NAME)).thenReturn(Optional.of(repository)); + when(githubApplicationClient.getRepository(GITHUB_API_URL, appInstallationToken, GITHUB_REPO_FULL_NAME)).thenReturn(Optional.of(repository)); when(projectKeyGenerator.generateUniqueProjectKey(repository.getFullName())).thenReturn("generated_" + PROJECT_KEY); } diff --git a/sonar-core/src/main/java/org/sonar/core/ce/package-info.java b/sonar-core/src/main/java/org/sonar/core/ce/package-info.java index 90dc6682f04..140cfc6fe77 100644 --- a/sonar-core/src/main/java/org/sonar/core/ce/package-info.java +++ b/sonar-core/src/main/java/org/sonar/core/ce/package-info.java @@ -1,3 +1,22 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 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. + */ @ParametersAreNonnullByDefault package org.sonar.core.ce; 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 43120ad451b..eb7cdea3c7e 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 @@ -110,7 +110,6 @@ public class AlmIntegrationsService extends BaseService { return call( new PostRequest(path("import_github_project")) .setParam("almSetting", request.getAlmSetting()) - .setParam("organization", request.getOrganization()) .setParam("repositoryKey", request.getRepositoryKey()) .setMediaType(MediaTypes.JSON), Projects.CreateWsResponse.parser()); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportGithubProjectRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportGithubProjectRequest.java index d6cfa80912b..6bf574f2dcf 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportGithubProjectRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportGithubProjectRequest.java @@ -30,8 +30,6 @@ public class ImportGithubProjectRequest { private String almSetting; private String repositoryKey; - private String organization; - /** * This is a mandatory parameter. */ @@ -57,16 +55,4 @@ public class ImportGithubProjectRequest { return this; } - public String getOrganization() { - return organization; - } - - /** - * This is a mandatory parameter. - */ - public ImportGithubProjectRequest setOrganization(String organization) { - this.organization = organization; - return this; - } - } -- 2.39.5