]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20640 removed 'organization' parameter from api/alm_integrations/import_github_...
authorAurelien Poscia <aurelien.poscia@sonarsource.com>
Thu, 12 Oct 2023 14:12:01 +0000 (16:12 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 20 Oct 2023 20:02:40 +0000 (20:02 +0000)
server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/GitHubDevOpsPlatformServiceTest.java
sonar-core/src/main/java/org/sonar/core/ce/package-info.java
sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/AlmIntegrationsService.java
sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportGithubProjectRequest.java

index d4c0480940cb2c35886fb7823561ec752c377283..501c5bbc09a5e1bdce98610fc2211de2ae8e0492 100644 (file)
@@ -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));
index 7d2a4be977b956aa33f1e2a4dc9f747d46919f93..db7328ae4077399b5b7f758685b32b730dc83da9 100644 (file)
@@ -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);
   }
 
index 90dc6682f0472861fbfa0f7ba5f7ca24795c91e5..140cfc6fe779b305f6fedd6ff4a44acd2228145d 100644 (file)
@@ -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;
 
index 43120ad451bebe1c189e6d353bceeafaa63f23d0..eb7cdea3c7e389a1c2a1ea196b60af578bb2170b 100644 (file)
@@ -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());
index d6cfa80912bde709c4593892b1fc3d9929c1f374..6bf574f2dcfd25ed4b1bd924a41e20a477882cdd 100644 (file)
@@ -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;
-  }
-
 }