From 10344ed7a4bb13bc5c58e7a9ca7fb90c3bad9365 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 1 Feb 2017 10:52:31 +0100 Subject: [PATCH] SONAR-8719 batch/file WS return 404 instead of 400 on unknown file --- .../org/sonar/server/batch/BatchIndex.java | 4 +- .../java/org/sonar/server/batch/BatchWs.java | 53 +--------- .../org/sonar/server/batch/BatchWsModule.java | 2 + .../org/sonar/server/batch/FileAction.java | 63 +++++++++++ .../org/sonar/server/batch/IndexAction.java | 60 +++++++++++ ...ch-index-example.txt => index-example.txt} | 0 .../sonar/server/batch/BatchIndexTest.java | 5 +- .../sonar/server/batch/BatchWsModuleTest.java | 2 +- .../org/sonar/server/batch/BatchWsTest.java | 85 --------------- .../sonar/server/batch/FileActionTest.java | 100 ++++++++++++++++++ .../sonar/server/batch/IndexActionTest.java | 86 +++++++++++++++ .../sonar/server/batch/IssuesActionTest.java | 2 +- .../sonar/server/batch/UsersActionTest.java | 4 +- 13 files changed, 323 insertions(+), 143 deletions(-) create mode 100644 server/sonar-server/src/main/java/org/sonar/server/batch/FileAction.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/batch/IndexAction.java rename server/sonar-server/src/main/resources/org/sonar/server/batch/{batch-index-example.txt => index-example.txt} (100%) delete mode 100644 server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/batch/FileActionTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/batch/IndexActionTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java index 9fbf1e9e0af..613149170ec 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java @@ -31,6 +31,7 @@ import org.apache.commons.lang.CharUtils; import org.apache.commons.lang.StringUtils; import org.picocontainer.Startable; import org.sonar.api.server.ServerSide; +import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.platform.ServerFileSystem; /** @@ -81,10 +82,9 @@ public class BatchIndex implements Startable { try { File input = new File(batchDir, filename); if (!input.exists() || !FileUtils.directoryContains(batchDir, input)) { - throw new IllegalArgumentException("Bad filename: " + filename); + throw new NotFoundException("Bad filename: " + filename); } return input; - } catch (IOException e) { throw new IllegalStateException("Can get file " + filename, e); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWs.java b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWs.java index 8218c8e57fc..747ab87273e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWs.java @@ -19,20 +19,17 @@ */ package org.sonar.server.batch; -import java.io.IOException; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.sonar.api.server.ws.WebService; +import static java.util.Arrays.stream; + public class BatchWs implements WebService { public static final String API_ENDPOINT = "batch"; - private final BatchIndex batchIndex; private final BatchWsAction[] actions; - public BatchWs(BatchIndex batchIndex, BatchWsAction... actions) { - this.batchIndex = batchIndex; + public BatchWs(BatchWsAction... actions) { this.actions = actions; } @@ -41,50 +38,8 @@ public class BatchWs implements WebService { NewController controller = context.createController(API_ENDPOINT) .setSince("4.4") .setDescription("Get JAR files and referentials for batch"); - - defineIndexAction(controller); - defineFileAction(controller); - for (BatchWsAction action : actions) { - action.define(controller); - } - + stream(actions).forEach(action -> action.define(controller)); controller.done(); } - private void defineIndexAction(NewController controller) { - controller.createAction("index") - .setInternal(true) - .setSince("4.4") - .setDescription("List the JAR files to be downloaded by scanners") - .setHandler((request, response) -> { - try { - response.stream().setMediaType("text/plain"); - IOUtils.write(batchIndex.getIndex(), response.stream().output()); - } catch (IOException e) { - throw new IllegalStateException(e); - } - }) - .setResponseExample(getClass().getResource("batch-index-example.txt")); - } - - private void defineFileAction(NewController controller) { - NewAction action = controller.createAction("file") - .setInternal(true) - .setSince("4.4") - .setDescription("Download a JAR file listed in the index (see batch/index)") - .setResponseExample(getClass().getResource("batch-file-example.txt")) - .setHandler((request, response) -> { - String filename = request.mandatoryParam("name"); - try { - response.stream().setMediaType("application/java-archive"); - FileUtils.copyFile(batchIndex.getFile(filename), response.stream().output()); - } catch (IOException e) { - throw new IllegalStateException(e); - } - }); - action - .createParam("name") - .setDescription("File name") - .setExampleValue("batch-library-2.3.jar"); - } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java index cce8355b900..7508ca8b198 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java @@ -30,6 +30,8 @@ public class BatchWsModule extends Module { ProjectDataLoader.class, IssuesAction.class, UsersAction.class, + IndexAction.class, + FileAction.class, BatchWs.class); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/FileAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/FileAction.java new file mode 100644 index 00000000000..d40fc01e91a --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/FileAction.java @@ -0,0 +1,63 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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. + */ + +package org.sonar.server.batch; + +import java.io.File; +import java.io.IOException; +import org.apache.commons.io.FileUtils; +import org.sonar.api.server.ws.Request; +import org.sonar.api.server.ws.Response; +import org.sonar.api.server.ws.WebService; + +public class FileAction implements BatchWsAction { + + private final BatchIndex batchIndex; + + public FileAction(BatchIndex batchIndex) { + this.batchIndex = batchIndex; + } + + @Override + public void define(WebService.NewController context) { + WebService.NewAction action = context.createAction("file") + .setInternal(true) + .setSince("4.4") + .setDescription("Download a JAR file listed in the index (see batch/index)") + .setResponseExample(getClass().getResource("batch-file-example.txt")) + .setHandler(this); + action + .createParam("name") + .setDescription("File name") + .setExampleValue("batch-library-2.3.jar"); + } + + @Override + public void handle(Request request, Response response) throws Exception { + String filename = request.mandatoryParam("name"); + try { + response.stream().setMediaType("application/java-archive"); + File file = batchIndex.getFile(filename); + FileUtils.copyFile(file, response.stream().output()); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/IndexAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/IndexAction.java new file mode 100644 index 00000000000..f5b36db5b7c --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/IndexAction.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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. + */ + +package org.sonar.server.batch; + +import java.io.IOException; +import org.apache.commons.io.IOUtils; +import org.sonar.api.server.ws.Request; +import org.sonar.api.server.ws.Response; +import org.sonar.api.server.ws.WebService; + +import static com.google.common.base.Preconditions.checkState; + +public class IndexAction implements BatchWsAction { + + private final BatchIndex batchIndex; + + public IndexAction(BatchIndex batchIndex) { + this.batchIndex = batchIndex; + } + + @Override + public void define(WebService.NewController context) { + context.createAction("index") + .setInternal(true) + .setSince("4.4") + .setDescription("List the JAR files to be downloaded by scanners") + .setHandler(this) + .setResponseExample(getClass().getResource("index-example.txt")); + } + + @Override + public void handle(Request request, Response response) throws Exception { + try { + response.stream().setMediaType("text/plain"); + String index = batchIndex.getIndex(); + checkState(index != null, "No available files"); + IOUtils.write(index, response.stream().output()); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } +} diff --git a/server/sonar-server/src/main/resources/org/sonar/server/batch/batch-index-example.txt b/server/sonar-server/src/main/resources/org/sonar/server/batch/index-example.txt similarity index 100% rename from server/sonar-server/src/main/resources/org/sonar/server/batch/batch-index-example.txt rename to server/sonar-server/src/main/resources/org/sonar/server/batch/index-example.txt diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/BatchIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/BatchIndexTest.java index b935d979875..33b06b1cc57 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/BatchIndexTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/BatchIndexTest.java @@ -28,6 +28,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; +import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.platform.ServerFileSystem; import static org.assertj.core.api.Assertions.assertThat; @@ -83,7 +84,7 @@ public class BatchIndexTest { */ @Test public void check_location_of_file() { - thrown.expect(IllegalArgumentException.class); + thrown.expect(NotFoundException.class); thrown.expectMessage("Bad filename: ../sonar-batch.jar"); BatchIndex batchIndex = new BatchIndex(fs); @@ -94,7 +95,7 @@ public class BatchIndexTest { @Test public void file_does_not_exist() { - thrown.expect(IllegalArgumentException.class); + thrown.expect(NotFoundException.class); thrown.expectMessage("Bad filename: other.jar"); BatchIndex batchIndex = new BatchIndex(fs); diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java index 131d8888371..09112e33ea7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java @@ -29,7 +29,7 @@ public class BatchWsModuleTest { public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); new BatchWsModule().configure(container); - assertThat(container.size()).isEqualTo(8); + assertThat(container.size()).isEqualTo(10); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsTest.java deleted file mode 100644 index 8adf4715eed..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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. - */ -package org.sonar.server.batch; - -import java.io.File; -import org.apache.commons.io.FileUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.sonar.db.DbClient; -import org.sonar.server.component.ComponentFinder; -import org.sonar.server.issue.index.IssueIndex; -import org.sonar.server.tester.UserSessionRule; -import org.sonar.server.ws.WsTester; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class BatchWsTest { - @Rule - public UserSessionRule userSessionRule = UserSessionRule.standalone(); - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Mock - BatchIndex batchIndex; - - WsTester tester; - - @Before - public void before() { - tester = new WsTester(new BatchWs(batchIndex, - new ProjectAction(mock(ProjectDataLoader.class)), - new IssuesAction(mock(DbClient.class), mock(IssueIndex.class), userSessionRule, mock(ComponentFinder.class)))); - } - - @Test - public void download_index() throws Exception { - when(batchIndex.getIndex()).thenReturn("sonar-batch.jar|acbd18db4cc2f85cedef654fccc4a4d8"); - - String index = tester.newGetRequest("batch", "index").execute().outputAsString(); - assertThat(index).isEqualTo("sonar-batch.jar|acbd18db4cc2f85cedef654fccc4a4d8"); - } - - @Test - public void download_file() throws Exception { - String filename = "sonar-batch.jar"; - - File file = temp.newFile(filename); - FileUtils.writeStringToFile(file, "foo"); - when(batchIndex.getFile(filename)).thenReturn(file); - - String jar = tester.newGetRequest("batch", "file").setParam("name", filename).execute().outputAsString(); - assertThat(jar).isEqualTo("foo"); - } - -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/FileActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/FileActionTest.java new file mode 100644 index 00000000000..5b8fd354049 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/FileActionTest.java @@ -0,0 +1,100 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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. + */ + +package org.sonar.server.batch; + +import java.io.File; +import org.apache.commons.io.FileUtils; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.exceptions.NotFoundException; +import org.sonar.server.platform.ServerFileSystem; +import org.sonar.server.ws.WsActionTester; + +import static org.apache.commons.io.FileUtils.writeStringToFile; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class FileActionTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + private ServerFileSystem serverFileSystem = mock(ServerFileSystem.class); + private BatchIndex batchIndex = new BatchIndex(serverFileSystem); + + private File batchDir; + + private WsActionTester tester = new WsActionTester(new FileAction(batchIndex)); + + @Before + public void setUp() throws Exception { + File homeDir = temp.newFolder(); + when(serverFileSystem.getHomeDir()).thenReturn(homeDir); + batchDir = new File(homeDir, "lib/scanner"); + FileUtils.forceMkdir(batchDir); + } + + @Test + public void download_file() throws Exception { + writeStringToFile(new File(batchDir, "sonar-batch.jar"), "foo"); + writeStringToFile(new File(batchDir, "other.jar"), "bar"); + batchIndex.start(); + + String jar = tester.newRequest().setParam("name", "sonar-batch.jar").execute().getInput(); + + assertThat(jar).isEqualTo("foo"); + } + + @Test + public void throw_NotFoundException_when_file_does_not_exist() throws Exception { + writeStringToFile(new File(batchDir, "sonar-batch.jar"), "foo"); + batchIndex.start(); + + thrown.expect(NotFoundException.class); + thrown.expectMessage("Bad filename: unknown"); + tester.newRequest().setParam("name", "unknown").execute(); + } + + @Test + public void throw_IAE_when_no_name_parameter() throws Exception { + thrown.expect(IllegalArgumentException.class); + thrown.expectMessage("The 'name' parameter is missing"); + tester.newRequest().execute(); + } + + @Test + public void test_definition() throws Exception { + WebService.Action definition = tester.getDef(); + assertThat(definition.isInternal()).isTrue(); + assertThat(definition.isPost()).isFalse(); + assertThat(definition.responseExampleAsString()).isNotEmpty(); + assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("name"); + } + +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/IndexActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/IndexActionTest.java new file mode 100644 index 00000000000..7745dcdbb37 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/IndexActionTest.java @@ -0,0 +1,86 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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. + */ + +package org.sonar.server.batch; + +import java.io.File; +import org.apache.commons.io.FileUtils; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; +import org.sonar.api.server.ws.WebService; +import org.sonar.server.platform.ServerFileSystem; +import org.sonar.server.ws.WsActionTester; + +import static org.apache.commons.io.FileUtils.writeStringToFile; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class IndexActionTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + private ServerFileSystem serverFileSystem = mock(ServerFileSystem.class); + private BatchIndex batchIndex = new BatchIndex(serverFileSystem); + + private File batchDir; + + private WsActionTester tester = new WsActionTester(new IndexAction(batchIndex)); + + @Before + public void setUp() throws Exception { + File homeDir = temp.newFolder(); + when(serverFileSystem.getHomeDir()).thenReturn(homeDir); + batchDir = new File(homeDir, "lib/scanner"); + FileUtils.forceMkdir(batchDir); + } + + @Test + public void get_index() throws Exception { + writeStringToFile(new File(batchDir, "sonar-batch.jar"), "something"); + batchIndex.start(); + + String index = tester.newRequest().execute().getInput(); + + assertThat(index).startsWith("sonar-batch.jar|"); + } + + @Test + public void throw_ISE_when_no_file() throws Exception { + thrown.expect(IllegalStateException.class); + tester.newRequest().execute(); + } + + @Test + public void test_definition() throws Exception { + WebService.Action definition = tester.getDef(); + assertThat(definition.isInternal()).isTrue(); + assertThat(definition.isPost()).isFalse(); + assertThat(definition.responseExampleAsString()).isNotEmpty(); + assertThat(definition.params()).isEmpty(); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java index a25f4948c74..2d083710918 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java @@ -85,7 +85,7 @@ public class IssuesActionTest { public void before() { IssueIndex issueIndex = new IssueIndex(es.client(), system2, userSessionRule, new AuthorizationTypeSupport(userSessionRule)); IssuesAction issuesAction = new IssuesAction(db.getDbClient(), issueIndex, userSessionRule, new ComponentFinder(db.getDbClient())); - tester = new WsTester(new BatchWs(new BatchIndex(fs), issuesAction)); + tester = new WsTester(new BatchWs(issuesAction)); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java index 3a12fdd82e3..aba3938d156 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java @@ -30,7 +30,6 @@ import org.sonar.api.config.MapSettings; import org.sonar.scanner.protocol.input.ScannerInput.User; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.UnauthorizedException; -import org.sonar.server.platform.ServerFileSystem; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.user.index.UserDoc; import org.sonar.server.user.index.UserIndex; @@ -38,7 +37,6 @@ import org.sonar.server.user.index.UserIndexDefinition; import org.sonar.server.ws.WsTester; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; public class UsersActionTest { @@ -61,7 +59,7 @@ public class UsersActionTest { public void before() { userIndex = new UserIndex(es.client()); usersAction = new UsersAction(userIndex, userSessionRule); - tester = new WsTester(new BatchWs(new BatchIndex(mock(ServerFileSystem.class)), usersAction)); + tester = new WsTester(new BatchWs(usersAction)); } @Test -- 2.39.5