@RunWith(DataProviderRunner.class)
public class SearchActionIT {
- private static final String PARAM_PROJECT_KEY = "projectKey";
+ private static final String PARAM_PROJECT = "project";
private static final String PARAM_STATUS = "status";
private static final String PARAM_RESOLUTION = "resolution";
private static final String PARAM_HOTSPOTS = "hotspots";
}
@Test
- public void fails_with_IAE_if_parameters_projectKey_and_hotspots_are_missing() {
+ public void fails_with_IAE_if_parameters_project_and_hotspots_are_missing() {
TestRequest request = actionTester.newRequest();
assertThatThrownBy(request::execute)
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("A value must be provided for either parameter 'projectKey' or parameter 'hotspots'");
+ .hasMessage("A value must be provided for either parameter 'project' or parameter 'hotspots'");
}
@Test
- public void fail_with_IAE_if_parameter_branch_is_used_without_parameter_projectKey() {
+ public void fail_with_IAE_if_parameter_branch_is_used_without_parameter_project() {
TestRequest request = actionTester.newRequest()
.setParam(PARAM_HOTSPOTS, randomAlphabetic(2))
.setParam(PARAM_BRANCH, randomAlphabetic(1));
assertThatThrownBy(request::execute)
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Parameter 'branch' must be used with parameter 'projectKey'");
+ .hasMessage("Parameter 'branch' must be used with parameter 'project'");
}
@Test
- public void fail_with_IAE_if_parameter_pullRequest_is_used_without_parameter_projectKey() {
+ public void fail_with_IAE_if_parameter_pullRequest_is_used_without_parameter_project() {
TestRequest request = actionTester.newRequest()
.setParam(PARAM_HOTSPOTS, randomAlphabetic(2))
.setParam(PARAM_PULL_REQUEST, randomAlphabetic(1));
assertThatThrownBy(request::execute)
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Parameter 'pullRequest' must be used with parameter 'projectKey'");
+ .hasMessage("Parameter 'pullRequest' must be used with parameter 'project'");
}
@Test
public void fail_with_IAE_if_both_parameters_pullRequest_and_branch_are_provided() {
TestRequest request = actionTester.newRequest()
- .setParam(PARAM_PROJECT_KEY, randomAlphabetic(2))
+ .setParam(PARAM_PROJECT, randomAlphabetic(2))
.setParam(PARAM_BRANCH, randomAlphabetic(1))
.setParam(PARAM_PULL_REQUEST, randomAlphabetic(1));
@UseDataProvider("badStatuses")
public void fails_with_IAE_if_status_parameter_is_neither_TO_REVIEW_or_REVIEWED(String badStatus) {
TestRequest request = actionTester.newRequest()
- .setParam(PARAM_PROJECT_KEY, randomAlphabetic(13))
+ .setParam(PARAM_PROJECT, randomAlphabetic(13))
.setParam(PARAM_STATUS, badStatus);
assertThatThrownBy(request::execute)
@UseDataProvider("badResolutions")
public void fails_with_IAE_if_resolution_parameter_is_neither_FIXED_nor_SAFE(String badResolution) {
TestRequest request = actionTester.newRequest()
- .setParam(PARAM_PROJECT_KEY, randomAlphabetic(13))
+ .setParam(PARAM_PROJECT, randomAlphabetic(13))
.setParam(PARAM_STATUS, STATUS_TO_REVIEW)
.setParam(PARAM_RESOLUTION, badResolution);
@UseDataProvider("fixedOrSafeResolution")
public void fails_with_IAE_if_resolution_is_provided_with_status_TO_REVIEW(String resolution) {
TestRequest request = actionTester.newRequest()
- .setParam(PARAM_PROJECT_KEY, randomAlphabetic(13))
+ .setParam(PARAM_PROJECT, randomAlphabetic(13))
.setParam(PARAM_STATUS, STATUS_TO_REVIEW)
.setParam(PARAM_RESOLUTION, resolution);
public void fails_with_NotFoundException_if_project_does_not_exist() {
String key = randomAlphabetic(12);
TestRequest request = actionTester.newRequest()
- .setParam(PARAM_PROJECT_KEY, key);
+ .setParam(PARAM_PROJECT, key);
assertThatThrownBy(request::execute)
.isInstanceOf(NotFoundException.class)
TestRequest request = actionTester.newRequest();
for (ComponentDto component : Arrays.asList(directory, file, portfolio)) {
- request.setParam(PARAM_PROJECT_KEY, component.getKey());
+ request.setParam(PARAM_PROJECT, component.getKey());
assertThatThrownBy(request::execute)
.isInstanceOf(NotFoundException.class)
.setParam(PARAM_ONLY_MINE, "true");
assertThatThrownBy(request::execute)
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Parameter 'onlyMine' can be used with parameter 'projectKey' only");
+ .hasMessage("Parameter 'onlyMine' can be used with parameter 'project' only");
}
@Test
userSessionRule.anonymous();
TestRequest request = actionTester.newRequest()
- .setParam(PARAM_PROJECT_KEY, project.getKey())
+ .setParam(PARAM_PROJECT, project.getKey())
.setParam(PARAM_ONLY_MINE, "true");
assertThatThrownBy(request::execute)
.isInstanceOf(IllegalArgumentException.class)
private TestRequest newRequest(ComponentDto project, @Nullable String status, @Nullable String resolution,
@Nullable String branch, @Nullable String pullRequest, Consumer<TestRequest> consumer) {
TestRequest res = actionTester.newRequest()
- .setParam(PARAM_PROJECT_KEY, project.getKey());
+ .setParam(PARAM_PROJECT, project.getKey());
if (branch != null) {
res.setParam(PARAM_BRANCH, branch);
}
public class SearchAction implements HotspotsWsAction {
private static final Set<String> SUPPORTED_QUALIFIERS = Set.of(Qualifiers.PROJECT, Qualifiers.APP);
+ private static final String PARAM_PROJECT = "project";
private static final String PARAM_PROJECT_KEY = "projectKey";
private static final String PARAM_STATUS = "status";
private static final String PARAM_RESOLUTION = "resolution";
Set<String> files = setFromList(request.paramAsStrings(PARAM_FILES));
return new WsRequest(
- request.mandatoryParamAsInt(PAGE), request.mandatoryParamAsInt(PAGE_SIZE), request.param(PARAM_PROJECT_KEY), request.param(PARAM_BRANCH),
+ request.mandatoryParamAsInt(PAGE), request.mandatoryParamAsInt(PAGE_SIZE), request.param(PARAM_PROJECT), request.param(PARAM_BRANCH),
request.param(PARAM_PULL_REQUEST), hotspotKeys, request.param(PARAM_STATUS), request.param(PARAM_RESOLUTION),
request.paramAsBoolean(PARAM_IN_NEW_CODE_PERIOD), request.paramAsBoolean(PARAM_ONLY_MINE), request.paramAsInt(PARAM_OWASP_ASVS_LEVEL),
pciDss32, pciDss40, owaspAsvs40, owasp2017Top10, owasp2021Top10, sansTop25, sonarsourceSecurity, cwes, files);
+ "When issue indexation is in progress returns 503 service unavailable HTTP code.")
.setSince("8.1")
.setChangelog(
+ new Change("10.2", format("Parameter '%s' renamed to '%s'", PARAM_PROJECT_KEY, PARAM_PROJECT)),
new Change("10.0", "Parameter 'sansTop25' is deprecated"),
new Change("9.6", "Added parameters 'pciDss-3.2' and 'pciDss-4.0"),
new Change("9.7", "Hotspot flows in the response may contain a description and a type"),
new Change("9.8", "Add message formatting to issue and locations response"));
action.addPagingParams(100);
- action.createParam(PARAM_PROJECT_KEY)
+ action.createParam(PARAM_PROJECT)
+ .setDeprecatedKey(PARAM_PROJECT_KEY, "10.2")
.setDescription(format(
"Key of the project or application. This parameter is required unless %s is provided.",
PARAM_HOTSPOTS))
action.createParam(PARAM_HOTSPOTS)
.setDescription(format(
"Comma-separated list of Security Hotspot keys. This parameter is required unless %s is provided.",
- PARAM_PROJECT_KEY))
+ PARAM_PROJECT))
.setExampleValue("AWhXpLoInp4On-Y3xc8x");
action.createParam(PARAM_STATUS)
- .setDescription("If '%s' is provided, only Security Hotspots with the specified status are returned.", PARAM_PROJECT_KEY)
+ .setDescription("If '%s' is provided, only Security Hotspots with the specified status are returned.", PARAM_PROJECT)
.setPossibleValues(STATUSES)
.setRequired(false);
action.createParam(PARAM_RESOLUTION)
.setDescription(format(
"If '%s' is provided and if status is '%s', only Security Hotspots with the specified resolution are returned.",
- PARAM_PROJECT_KEY, STATUS_REVIEWED))
+ PARAM_PROJECT, STATUS_REVIEWED))
.setPossibleValues(RESOLUTION_FIXED, RESOLUTION_SAFE, RESOLUTION_ACKNOWLEDGED)
.setRequired(false);
action.createParam(PARAM_IN_NEW_CODE_PERIOD)
Set<String> hotspotKeys = wsRequest.getHotspotKeys();
checkArgument(
projectKey.isPresent() || !hotspotKeys.isEmpty(),
- "A value must be provided for either parameter '%s' or parameter '%s'", PARAM_PROJECT_KEY, PARAM_HOTSPOTS);
+ "A value must be provided for either parameter '%s' or parameter '%s'", PARAM_PROJECT, PARAM_HOTSPOTS);
checkArgument(
branch.isEmpty() || projectKey.isPresent(),
- "Parameter '%s' must be used with parameter '%s'", PARAM_BRANCH, PARAM_PROJECT_KEY);
+ "Parameter '%s' must be used with parameter '%s'", PARAM_BRANCH, PARAM_PROJECT);
checkArgument(
pullRequest.isEmpty() || projectKey.isPresent(),
- "Parameter '%s' must be used with parameter '%s'", PARAM_PULL_REQUEST, PARAM_PROJECT_KEY);
+ "Parameter '%s' must be used with parameter '%s'", PARAM_PULL_REQUEST, PARAM_PROJECT);
checkArgument(
!(branch.isPresent() && pullRequest.isPresent()),
"Only one of parameters '%s' and '%s' can be provided", PARAM_BRANCH, PARAM_PULL_REQUEST);
checkArgument(userSession.isLoggedIn(),
"Parameter '%s' requires user to be logged in", PARAM_ONLY_MINE);
checkArgument(wsRequest.getProjectKey().isPresent(),
- "Parameter '%s' can be used with parameter '%s' only", PARAM_ONLY_MINE, PARAM_PROJECT_KEY);
+ "Parameter '%s' can be used with parameter '%s' only", PARAM_ONLY_MINE, PARAM_PROJECT);
}
}