Browse Source

SONAR-20640 removed 'organization' parameter from api/alm_integrations/import_github_project

tags/10.3.0.82913
Aurelien Poscia 7 months ago
parent
commit
b9ee3198bb

+ 0
- 16
server/sonar-webserver-webapi/src/it/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionIT.java View 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));

+ 1
- 1
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/GitHubDevOpsPlatformServiceTest.java View 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);
}


+ 19
- 0
sonar-core/src/main/java/org/sonar/core/ce/package-info.java View 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;


+ 0
- 1
sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/AlmIntegrationsService.java View 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());

+ 0
- 14
sonar-ws/src/main/java/org/sonarqube/ws/client/almintegrations/ImportGithubProjectRequest.java View 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;
}

}

Loading…
Cancel
Save