Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
public class SystemController {

public static final String PATH = "system";
public static final String INDEX_TIME = "indextime";

private final RuntimeEnvironment env = RuntimeEnvironment.getInstance();

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

@GET
@Path("/indextime")
@Path("/" + INDEX_TIME)
@Produces(MediaType.APPLICATION_JSON)
public String getIndexTime() throws JsonProcessingException {
Date date = new IndexTimestamp().getDateForLastIndexRun();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class IncomingFilter implements ContainerRequestFilter, ConfigurationChan
private static final Set<String> allowedPaths = new HashSet<>(Arrays.asList(
SearchController.PATH, SuggesterController.PATH, SuggesterController.PATH + "/config",
HistoryController.PATH, FileController.PATH, AnnotationController.PATH,
SystemController.PATH + "/ping"));
SystemController.PATH + "/ping", SystemController.PATH + "/" + SystemController.INDEX_TIME ));

@Context
private HttpServletRequest request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void testIndexTime() throws IOException, ParseException {
Files.setLastModifiedTime(indexTimeFile, FileTime.fromMillis(date.getTime()));

Response r = target("system")
.path("indextime")
.path(SystemController.INDEX_TIME)
.request().get();
String result = r.readEntity(String.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.mockito.ArgumentCaptor;
import org.opengrok.indexer.configuration.CommandTimeoutType;
import org.opengrok.indexer.configuration.RuntimeEnvironment;
import org.opengrok.web.api.v1.controller.SystemController;

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

assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), captor.getValue().getStatus());
}

@Test
void systemIndexTimeRemoteWithoutTokenTest() throws Exception {
assertFilterDoesNotBlockAddress("10.0.0.1", SystemController.PATH + "/" + SystemController.INDEX_TIME);
}
}