Skip to content

Commit 2339ebe

Browse files
authored
Allow to query to index time endpoint without token (#4872)
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
1 parent a6b6ac3 commit 2339ebe

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/SystemController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
public class SystemController {
5050

5151
public static final String PATH = "system";
52+
public static final String INDEX_TIME = "indextime";
5253

5354
private final RuntimeEnvironment env = RuntimeEnvironment.getInstance();
5455

@@ -70,7 +71,7 @@ public void loadPathDescriptions(@Valid final PathDescription[] descriptions) th
7071
}
7172

7273
@GET
73-
@Path("/indextime")
74+
@Path("/" + INDEX_TIME)
7475
@Produces(MediaType.APPLICATION_JSON)
7576
public String getIndexTime() throws JsonProcessingException {
7677
Date date = new IndexTimestamp().getDateForLastIndexRun();

opengrok-web/src/main/java/org/opengrok/web/api/v1/filter/IncomingFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public class IncomingFilter implements ContainerRequestFilter, ConfigurationChan
7373
private static final Set<String> allowedPaths = new HashSet<>(Arrays.asList(
7474
SearchController.PATH, SuggesterController.PATH, SuggesterController.PATH + "/config",
7575
HistoryController.PATH, FileController.PATH, AnnotationController.PATH,
76-
SystemController.PATH + "/ping"));
76+
SystemController.PATH + "/ping", SystemController.PATH + "/" + SystemController.INDEX_TIME ));
7777

7878
@Context
7979
private HttpServletRequest request;

opengrok-web/src/test/java/org/opengrok/web/api/v1/controller/SystemControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void testIndexTime() throws IOException, ParseException {
159159
Files.setLastModifiedTime(indexTimeFile, FileTime.fromMillis(date.getTime()));
160160

161161
Response r = target("system")
162-
.path("indextime")
162+
.path(SystemController.INDEX_TIME)
163163
.request().get();
164164
String result = r.readEntity(String.class);
165165

opengrok-web/src/test/java/org/opengrok/web/api/v1/filter/IncomingFilterTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.mockito.ArgumentCaptor;
3333
import org.opengrok.indexer.configuration.CommandTimeoutType;
3434
import org.opengrok.indexer.configuration.RuntimeEnvironment;
35+
import org.opengrok.web.api.v1.controller.SystemController;
3536

3637
import java.lang.reflect.Field;
3738
import java.util.HashSet;
@@ -243,4 +244,9 @@ void systemPathDescWithoutTokenTest() throws Exception {
243244

244245
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), captor.getValue().getStatus());
245246
}
247+
248+
@Test
249+
void systemIndexTimeRemoteWithoutTokenTest() throws Exception {
250+
assertFilterDoesNotBlockAddress("10.0.0.1", SystemController.PATH + "/" + SystemController.INDEX_TIME);
251+
}
246252
}

0 commit comments

Comments
 (0)