mirror of
https://github.com/SonarSource/sonarqube.git
synced 2024-08-06 15:05:57 +02:00
SONAR-5770 Improve api/ce/component
- renamed from api/ce/project - parameter componentId supports non-projects -> returns empty results instead of raising 403
This commit is contained in:
parent
96ab2f7679
commit
8d61942d05
@ -32,7 +32,7 @@ public class CeWsModule extends Module {
|
||||
CeWs.class,
|
||||
IsQueueEmptyWs.class,
|
||||
LogsWsAction.class,
|
||||
ProjectWsAction.class,
|
||||
ComponentWsAction.class,
|
||||
SubmitWsAction.class,
|
||||
TaskFormatter.class,
|
||||
TaskWsAction.class);
|
||||
|
@ -36,7 +36,7 @@ import org.sonar.server.ws.WsUtils;
|
||||
|
||||
import static org.sonarqube.ws.WsCe.ProjectResponse;
|
||||
|
||||
public class ProjectWsAction implements CeWsAction {
|
||||
public class ComponentWsAction implements CeWsAction {
|
||||
|
||||
public static final String PARAM_COMPONENT_UUID = "componentId";
|
||||
|
||||
@ -44,7 +44,7 @@ public class ProjectWsAction implements CeWsAction {
|
||||
private final DbClient dbClient;
|
||||
private final TaskFormatter formatter;
|
||||
|
||||
public ProjectWsAction(UserSession userSession, DbClient dbClient, TaskFormatter formatter) {
|
||||
public ComponentWsAction(UserSession userSession, DbClient dbClient, TaskFormatter formatter) {
|
||||
this.userSession = userSession;
|
||||
this.dbClient = dbClient;
|
||||
this.formatter = formatter;
|
||||
@ -52,10 +52,10 @@ public class ProjectWsAction implements CeWsAction {
|
||||
|
||||
@Override
|
||||
public void define(WebService.NewController controller) {
|
||||
WebService.NewAction action = controller.createAction("project")
|
||||
.setDescription("Get the pending and last executed tasks of a given project")
|
||||
WebService.NewAction action = controller.createAction("component")
|
||||
.setDescription("Get the pending and last executed tasks of a given component (usually a project)")
|
||||
.setInternal(true)
|
||||
.setResponseExample(getClass().getResource("project-example.json"))
|
||||
.setResponseExample(getClass().getResource("component-example.json"))
|
||||
.setHandler(this);
|
||||
|
||||
action.createParam(PARAM_COMPONENT_UUID)
|
||||
@ -66,7 +66,7 @@ public class ProjectWsAction implements CeWsAction {
|
||||
@Override
|
||||
public void handle(Request wsRequest, Response wsResponse) throws Exception {
|
||||
String componentUuid = wsRequest.mandatoryParam(PARAM_COMPONENT_UUID);
|
||||
userSession.checkProjectUuidPermission(UserRole.USER, componentUuid);
|
||||
userSession.checkComponentUuidPermission(UserRole.USER, componentUuid);
|
||||
|
||||
DbSession dbSession = dbClient.openSession(false);
|
||||
try {
|
@ -44,7 +44,7 @@ import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class ProjectWsActionTest {
|
||||
public class ComponentWsActionTest {
|
||||
|
||||
@Rule
|
||||
public UserSessionRule userSession = UserSessionRule.standalone();
|
||||
@ -54,7 +54,7 @@ public class ProjectWsActionTest {
|
||||
|
||||
CeLogging ceLogging = mock(CeLogging.class);
|
||||
TaskFormatter formatter = new TaskFormatter(dbTester.getDbClient(), ceLogging);
|
||||
ProjectWsAction underTest = new ProjectWsAction(userSession, dbTester.getDbClient(), formatter);
|
||||
ComponentWsAction underTest = new ComponentWsAction(userSession, dbTester.getDbClient(), formatter);
|
||||
WsActionTester tester = new WsActionTester(underTest);
|
||||
|
||||
@Before
|
||||
@ -64,7 +64,7 @@ public class ProjectWsActionTest {
|
||||
|
||||
@Test
|
||||
public void empty_queue_and_empty_activity() {
|
||||
userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1");
|
||||
userSession.addComponentUuidPermission(UserRole.USER, "PROJECT_1", "PROJECT_1");
|
||||
|
||||
TestResponse wsResponse = tester.newRequest()
|
||||
.setParam("componentId", "PROJECT_1")
|
||||
@ -78,7 +78,7 @@ public class ProjectWsActionTest {
|
||||
|
||||
@Test
|
||||
public void project_tasks() {
|
||||
userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1");
|
||||
userSession.addComponentUuidPermission(UserRole.USER, "PROJECT_1", "PROJECT_1");
|
||||
insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
|
||||
insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
|
||||
insertActivity("T3", "PROJECT_1", CeActivityDto.Status.FAILED);
|
@ -26,6 +26,6 @@ export function cancelAllTasks () {
|
||||
}
|
||||
|
||||
export function getTasksForComponent(componentId) {
|
||||
let url = baseUrl + '/api/ce/project';
|
||||
let url = baseUrl + '/api/ce/component';
|
||||
return $.get(url, { componentId });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user