use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class DismissAnalysisWarningActionTest method return_403_if_user_has_no_browse_permission_on_private_project.
@Test
public void return_403_if_user_has_no_browse_permission_on_private_project() {
ProjectDto project = db.components().insertPrivateProjectDto();
UserDto user = db.users().insertUser();
userSession.logIn(user);
TestRequest request = underTest.newRequest().setParam("component", project.getKee()).setParam("warning", "55c40b35-4145-4b78-bdf2-dfb242c25f15");
assertThrows("Insufficient privileges", ForbiddenException.class, request::execute);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class DismissAnalysisWarningActionTest method returns_400_if_warning_is_not_dismissable.
@Test
public void returns_400_if_warning_is_not_dismissable() {
UserDto user = db.users().insertUser();
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn(user).addProjectPermission(UserRole.USER, project);
SnapshotDto analysis = db.components().insertSnapshot(project);
CeActivityDto activity = insertActivity("task-uuid" + counter++, project, SUCCESS, analysis, REPORT);
CeTaskMessageDto taskMessage = createTaskMessage(activity, "generic warning");
TestRequest request = underTest.newRequest().setParam("component", project.getKey()).setParam("warning", taskMessage.getUuid());
assertThrows(format("Message '%s' cannot be dismissed.", taskMessage.getUuid()), IllegalArgumentException.class, request::execute);
assertThat(db.countRowsOfTable("USER_DISMISSED_MESSAGES")).isZero();
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class DismissAnalysisWarningActionTest method return_401_if_user_is_not_logged_in.
@Test
public void return_401_if_user_is_not_logged_in() {
userSession.anonymous();
TestRequest request = underTest.newRequest().setParam("component", "6653f062-7c03-4b55-bcd2-0dac67640c4d").setParam("warning", "55c40b35-4145-4b78-bdf2-dfb242c25f15");
assertThrows("Authentication is required", UnauthorizedException.class, request::execute);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class TreeActionTest method fail_if_branch_does_not_exist.
@Test
public void fail_if_branch_does_not_exist() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
TestRequest request = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).setParam(PARAM_BRANCH, "another_branch");
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage(format("Component '%s' on branch '%s' not found", project.getKey(), "another_branch"));
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class TreeActionTest method fail_when_using_branch_key.
@Test
public void fail_when_using_branch_key() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project);
TestRequest request = ws.newRequest().setParam(PARAM_COMPONENT, branch.getDbKey());
assertThatThrownBy(() -> request.executeProtobuf(Components.ShowWsResponse.class)).isInstanceOf(NotFoundException.class).hasMessage(format("Component key '%s' not found", branch.getDbKey()));
}
Aggregations