summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@gmail.com>2022-04-06 19:35:30 +0200
committerJon Marius Venstad <jonmv@gmail.com>2022-04-06 19:35:30 +0200
commit039589faf5f989d80b9fec2b28ed955ac6fd86f6 (patch)
tree45c314cc9ede2d5c26a5d6b4f030ad3db2246a91 /configserver
parentec92b5f8882e400f94b851dffcf0b3511373e890 (diff)
Use HttpURL.Path for Path.getRest()
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java20
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java21
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentHandler.java9
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java11
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java21
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/ApplicationContentRequest.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/SessionContentRequestV2.java15
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/serviceview/StateRequestHandler.java17
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java17
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java4
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/serviceview/StateRequestHandlerTest.java5
15 files changed, 89 insertions, 67 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index cb1c1a461e3..76d7ff2fc7f 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -31,6 +31,7 @@ import com.yahoo.docproc.jdisc.metric.NullMetric;
import com.yahoo.io.IOUtils;
import com.yahoo.jdisc.Metric;
import com.yahoo.path.Path;
+import com.yahoo.restapi.HttpURL;
import com.yahoo.slime.Slime;
import com.yahoo.transaction.NestedTransaction;
import com.yahoo.transaction.Transaction;
@@ -558,27 +559,24 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
}
- public HttpResponse serviceStatusPage(ApplicationId applicationId, String hostName, String serviceName, String pathSuffix) {
+ public HttpResponse serviceStatusPage(ApplicationId applicationId, String hostName, String serviceName, HttpURL.Path pathSuffix) {
// WARNING: pathSuffix may be given by the external user. Make sure no security issues arise...
// We should be OK here, because at most, pathSuffix may change the parent path, but cannot otherwise
// change the hostname and port. Exposing other paths on the cluster controller should be fine.
// TODO: It would be nice to have a simple check to verify pathSuffix doesn't contain /../ components.
- String pathPrefix;
+ HttpURL.Path pathPrefix = HttpURL.Path.empty();
switch (serviceName) {
- case "container-clustercontroller": {
- pathPrefix = "clustercontroller-status/v1/";
+ case "container-clustercontroller":
+ pathPrefix = pathPrefix.append("clustercontroller-status").append("v1");
break;
- }
case "distributor":
- case "storagenode": {
- pathPrefix = "";
+ case "storagenode":
break;
- }
default:
throw new NotFoundException("No status page for service: " + serviceName);
}
- return httpProxy.get(getApplication(applicationId), hostName, serviceName, pathPrefix + pathSuffix);
+ return httpProxy.get(getApplication(applicationId), hostName, serviceName, pathPrefix.append(pathSuffix));
}
public Map<String, ClusterReindexing> getClusterReindexingStatus(ApplicationId applicationId) {
@@ -659,9 +657,9 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return getOptionalApplication(applicationId).map(app -> app.getModel().fileReferences()).orElse(Set.of());
}
- public ApplicationFile getApplicationFileFromSession(TenantName tenantName, long sessionId, String path, Session.Mode mode) {
+ public ApplicationFile getApplicationFileFromSession(TenantName tenantName, long sessionId, HttpURL.Path path, Session.Mode mode) {
Tenant tenant = tenantRepository.getTenant(tenantName);
- return getLocalSession(tenant, sessionId).getApplicationFile(Path.fromString(path), mode);
+ return getLocalSession(tenant, sessionId).getApplicationFile(Path.from(path.segments()), mode);
}
public Tenant getTenant(ApplicationId applicationId) {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java
index a8915d187f3..14acd1b5630 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/HttpProxy.java
@@ -10,8 +10,14 @@ import com.yahoo.container.jdisc.HttpResponse;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
+
+import com.yahoo.net.DomainName;
+import com.yahoo.restapi.HttpURL;
+import com.yahoo.restapi.HttpURL.Path;
+import com.yahoo.restapi.HttpURL.Scheme;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.http.HttpFetcher;
+import com.yahoo.vespa.config.server.http.HttpFetcher.Params;
import com.yahoo.vespa.config.server.http.NotFoundException;
import com.yahoo.vespa.config.server.http.SimpleHttpFetcher;
@@ -33,7 +39,7 @@ public class HttpProxy {
this.fetcher = fetcher;
}
- public HttpResponse get(Application application, String hostName, String serviceType, String relativePath) {
+ public HttpResponse get(Application application, String hostName, String serviceType, Path relativePath) {
HostInfo host = application.getModel().getHosts().stream()
.filter(hostInfo -> hostInfo.getHostname().equals(hostName))
.findFirst()
@@ -54,18 +60,15 @@ public class HttpProxy {
return internalGet(host.getHostname(), port.getPort(), relativePath);
}
- private HttpResponse internalGet(String hostname, int port, String relativePath) {
- String urlString = "http://" + hostname + ":" + port + "/" + relativePath;
- URL url;
+ private HttpResponse internalGet(String hostname, int port, Path relativePath) {
+ HttpURL url = HttpURL.create(Scheme.http, DomainName.of(hostname), port, relativePath);
try {
- url = new URL(urlString);
+ return fetcher.get(new Params(2000), // 2_000 ms read timeout
+ url.asURI().toURL());
} catch (MalformedURLException e) {
- logger.log(Level.WARNING, "Badly formed url: " + urlString, e);
+ logger.log(Level.WARNING, "Badly formed url: " + url, e);
return HttpErrorResponse.internalServerError("Failed to construct URL for backend");
}
-
- HttpFetcher.Params params = new HttpFetcher.Params(2000); // 2_000 ms read timeout
- return fetcher.get(params, url);
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentHandler.java
index 13acc121fa0..0ceb459233b 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentHandler.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.config.server.http;
import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.container.jdisc.HttpResponse;
+import com.yahoo.restapi.HttpURL.Path;
import com.yahoo.restapi.SlimeJsonResponse;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.Slime;
@@ -32,7 +33,7 @@ public class ContentHandler {
public HttpResponse put(ContentRequest request) {
ApplicationFile file = request.getFile();
- if (request.getPath().endsWith("/")) {
+ if (request.getPath().hasTrailingSlash()) {
createDirectory(request, file);
} else {
createFile(request, file);
@@ -62,9 +63,9 @@ public class ContentHandler {
return new SessionContentStatusResponse(file, urlBase);
}
- private static List<ApplicationFile> listSortedFiles(ApplicationFile file, String path, boolean recursive) {
- if (!path.isEmpty() && !path.endsWith("/")) {
- return Arrays.asList(file);
+ private static List<ApplicationFile> listSortedFiles(ApplicationFile file, Path path, boolean recursive) {
+ if ( ! path.segments().isEmpty() && ! path.hasTrailingSlash()) {
+ return List.of(file);
}
List<ApplicationFile> files = file.listFiles(recursive);
Collections.sort(files);
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java
index 995c4b2dc56..f06e1dabf8c 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ContentRequest.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.config.server.http;
import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.container.jdisc.HttpRequest;
+import com.yahoo.restapi.HttpURL.Path;
import java.io.InputStream;
@@ -20,11 +21,11 @@ public abstract class ContentRequest {
enum ReturnType {CONTENT, STATUS}
private final long sessionId;
- private final String path;
+ private final Path path;
private final ApplicationFile file;
private final HttpRequest request;
- protected ContentRequest(HttpRequest request, long sessionId, String path, ApplicationFile applicationFile) {
+ protected ContentRequest(HttpRequest request, long sessionId, Path path, ApplicationFile applicationFile) {
this.request = request;
this.sessionId = sessionId;
this.path = path;
@@ -77,7 +78,7 @@ public abstract class ContentRequest {
}
- String getPath() {
+ Path getPath() {
return path;
}
@@ -86,8 +87,8 @@ public abstract class ContentRequest {
}
ApplicationFile getExistingFile() {
- if (!file.exists()) {
- throw new NotFoundException("Session " + sessionId + " does not contain a file '" + path + "'");
+ if ( ! file.exists()) {
+ throw new NotFoundException("Session " + sessionId + " does not contain a file at " + path);
}
return file;
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
index 0707261bb45..885456ff69c 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
@@ -16,6 +16,7 @@ import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.io.IOUtils;
import com.yahoo.jdisc.Response;
import com.yahoo.restapi.ErrorResponse;
+import com.yahoo.restapi.HttpURL;
import com.yahoo.restapi.MessageResponse;
import com.yahoo.restapi.Path;
import com.yahoo.slime.Cursor;
@@ -132,23 +133,23 @@ public class ApplicationHandler extends HttpHandler {
return HttpServiceResponse.createResponse(response, hostAndPort, request.getUri());
}
- private HttpResponse serviceStatusPage(ApplicationId applicationId, String service, String hostname, String pathSuffix) {
+ private HttpResponse serviceStatusPage(ApplicationId applicationId, String service, String hostname, HttpURL.Path pathSuffix) {
return applicationRepository.serviceStatusPage(applicationId, hostname, service, pathSuffix);
}
- private HttpResponse content(ApplicationId applicationId, String contentPath, HttpRequest request) {
+ private HttpResponse content(ApplicationId applicationId, HttpURL.Path contentPath, HttpRequest request) {
long sessionId = applicationRepository.getSessionIdForApplication(applicationId);
ApplicationFile applicationFile =
applicationRepository.getApplicationFileFromSession(applicationId.tenant(),
- sessionId,
- contentPath,
- ContentRequest.getApplicationFileMode(request.getMethod()));
+ sessionId,
+ contentPath,
+ ContentRequest.getApplicationFileMode(request.getMethod()));
ApplicationContentRequest contentRequest = new ApplicationContentRequest(request,
- sessionId,
- applicationId,
- zone,
- contentPath,
- applicationFile);
+ sessionId,
+ applicationId,
+ zone,
+ contentPath,
+ applicationFile);
return new ContentHandler().get(contentRequest);
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java
index 17a8e1449c4..f6af9e616a9 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java
@@ -6,6 +6,7 @@ import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.config.provision.TenantName;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
+import com.yahoo.restapi.HttpURL.Path;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.http.ContentRequest;
import com.yahoo.vespa.config.server.http.ContentHandler;
@@ -52,7 +53,7 @@ public class SessionContentHandler extends SessionHandler {
TenantName tenantName = Utils.getTenantNameFromSessionRequest(request);
validateRequest(tenantName);
long sessionId = getSessionIdV2(request);
- String contentPath = SessionContentRequestV2.getContentPath(request);
+ Path contentPath = SessionContentRequestV2.getContentPath(request);
ApplicationFile applicationFile =
applicationRepository.getApplicationFileFromSession(tenantName,
sessionId,
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/ApplicationContentRequest.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/ApplicationContentRequest.java
index 34c842eca44..15d6c5c18ff 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/ApplicationContentRequest.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/ApplicationContentRequest.java
@@ -5,6 +5,7 @@ import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Zone;
import com.yahoo.container.jdisc.HttpRequest;
+import com.yahoo.restapi.HttpURL.Path;
import com.yahoo.vespa.config.server.http.ContentRequest;
/**
@@ -22,7 +23,7 @@ public class ApplicationContentRequest extends ContentRequest {
long sessionId,
ApplicationId applicationId,
Zone zone,
- String contentPath,
+ Path contentPath,
ApplicationFile applicationFile) {
super(request, sessionId, contentPath, applicationFile);
this.applicationId = applicationId;
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/SessionContentRequestV2.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/SessionContentRequestV2.java
index da71fd89054..449058eb911 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/SessionContentRequestV2.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/request/SessionContentRequestV2.java
@@ -5,6 +5,8 @@ import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.config.provision.TenantName;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.jdisc.application.BindingMatch;
+import com.yahoo.restapi.HttpURL;
+import com.yahoo.restapi.Path;
import com.yahoo.vespa.config.server.http.ContentRequest;
import com.yahoo.vespa.config.server.http.Utils;
@@ -16,14 +18,14 @@ import com.yahoo.vespa.config.server.http.Utils;
* @since 5.3
*/
public class SessionContentRequestV2 extends ContentRequest {
- private static final String uriPattern = "http://*/application/v2/tenant/*/session/*/content/*";
+
private final TenantName tenantName;
private final long sessionId;
public SessionContentRequestV2(HttpRequest request,
long sessionId,
TenantName tenantName,
- String path,
+ HttpURL.Path path,
ApplicationFile applicationFile) {
super(request, sessionId, path, applicationFile);
this.tenantName = tenantName;
@@ -35,8 +37,11 @@ public class SessionContentRequestV2 extends ContentRequest {
return "/application/v2/tenant/" + tenantName.value() + "/session/" + sessionId;
}
- public static String getContentPath(HttpRequest request) {
- BindingMatch<?> bm = Utils.getBindingMatch(request, uriPattern);
- return bm.group(4);
+ public static HttpURL.Path getContentPath(HttpRequest request) {
+ Path path = new Path(request.getUri());
+ if ( ! path.matches("/application/v2/tenant/{tenant}/session/{session}/content/{*}"))
+ throw new IllegalStateException("error in request routing");
+ return path.getRest();
}
+
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/serviceview/StateRequestHandler.java b/configserver/src/main/java/com/yahoo/vespa/serviceview/StateRequestHandler.java
index 30975be61e2..8b9714c3bfb 100644
--- a/configserver/src/main/java/com/yahoo/vespa/serviceview/StateRequestHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/serviceview/StateRequestHandler.java
@@ -5,6 +5,11 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import com.google.inject.Inject;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
+import com.yahoo.net.DomainName;
+import com.yahoo.restapi.HttpURL;
+import com.yahoo.restapi.HttpURL.Path;
+import com.yahoo.restapi.HttpURL.Query;
+import com.yahoo.restapi.HttpURL.Scheme;
import com.yahoo.restapi.RestApi;
import com.yahoo.restapi.RestApiRequestHandler;
import com.yahoo.restapi.UriBuilder;
@@ -106,7 +111,7 @@ public class StateRequestHandler extends RestApiRequestHandler<StateRequestHandl
String regionName = context.pathParameters().getStringOrThrow("regionName");
String instanceName = context.pathParameters().getStringOrThrow("instanceName");
String identifier = context.pathParameters().getStringOrThrow("serviceIdentifier");
- String apiParams = context.pathParameters().getString("*").orElse("");
+ Path apiParams = context.pathParameters().getRest().orElse(Path.empty());
return singleService(context.uriBuilder(), context.request().getUri(), tenantName, applicationName, environmentName, regionName, instanceName, identifier, apiParams);
}
@@ -125,7 +130,7 @@ public class StateRequestHandler extends RestApiRequestHandler<StateRequestHandl
}
protected HashMap<?, ?> singleService(
- UriBuilder uriBuilder, URI requestUri, String tenantName, String applicationName, String environmentName, String regionName, String instanceName, String identifier, String apiParams) {
+ UriBuilder uriBuilder, URI requestUri, String tenantName, String applicationName, String environmentName, String regionName, String instanceName, String identifier, Path apiParams) {
ServiceModel model = new ServiceModel(getModelConfig(tenantName, applicationName, environmentName, regionName, instanceName));
Service s = model.getService(identifier);
int requestedPort = s.matchIdentifierWithPort(identifier);
@@ -135,11 +140,9 @@ public class StateRequestHandler extends RestApiRequestHandler<StateRequestHandl
return apiResult;
}
- protected HealthClient getHealthClient(String apiParams, Service s, int requestedPort, String uriQuery, Client client) {
- final StringBuilder uriBuffer = new StringBuilder("http://").append(s.host).append(':').append(requestedPort).append('/')
- .append(apiParams);
- addQuery(uriQuery, uriBuffer);
- WebTarget target = client.target(uriBuffer.toString());
+ protected HealthClient getHealthClient(Path apiParams, Service s, int requestedPort, String uriQuery, Client client) {
+ URI uri = HttpURL.create(Scheme.http, DomainName.of(s.host), requestedPort, apiParams, Query.parse(uriQuery)).asURI();
+ WebTarget target = client.target(uri);
return WebResourceFactory.newResource(HealthClient.class, target);
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java
index ac0a6491100..83cae04cbfd 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/HttpProxyTest.java
@@ -6,6 +6,7 @@ import com.yahoo.config.model.api.Model;
import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.container.jdisc.HttpResponse;
+import com.yahoo.restapi.HttpURL.Path;
import com.yahoo.vespa.config.server.http.HttpFetcher;
import com.yahoo.vespa.config.server.http.RequestTimeoutException;
import com.yahoo.vespa.config.server.http.StaticResponse;
@@ -48,7 +49,7 @@ public class HttpProxyTest {
when(fetcher.get(actualParams.capture(), actualUrl.capture())).thenReturn(response);
HttpResponse actualResponse = proxy.get(applicationMock, hostname, CLUSTERCONTROLLER_CONTAINER.serviceName,
- "clustercontroller-status/v1/clusterName");
+ Path.parse("clustercontroller-status/v1/clusterName"));
assertEquals(1, actualParams.getAllValues().size());
assertEquals(2000, actualParams.getValue().readTimeoutMs);
@@ -67,7 +68,7 @@ public class HttpProxyTest {
when(fetcher.get(any(), any())).thenThrow(new RequestTimeoutException("timed out"));
proxy.get(applicationMock, hostname, CLUSTERCONTROLLER_CONTAINER.serviceName,
- "clustercontroller-status/v1/clusterName");
+ Path.parse("clustercontroller-status/v1/clusterName"));
}
private static MockModel createClusterController() {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java
index 69caf86729f..0732379e0d9 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HandlerTest.java
@@ -34,7 +34,7 @@ public class HandlerTest {
if (contentType != null) {
assertEquals(renderedString, contentType, response.getContentType());
}
- assertTrue(renderedString.contains(message));
+ assertTrue("\n" + renderedString + "\n should contain \n" + message, renderedString.contains(message));
}
public static void assertHttpStatusCodeErrorCodeAndMessage(HttpResponse response, int statusCode, HttpErrorResponse.ErrorCode errorCode, String message) throws IOException {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
index 005dd715dd4..9f7e539a2e3 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
@@ -15,6 +15,7 @@ import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.http.HttpRequest.Method;
+import com.yahoo.restapi.HttpURL;
import com.yahoo.test.ManualClock;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.MockLogRetriever;
@@ -356,16 +357,20 @@ public class ApplicationHandlerTest {
.withHttpProxy(mockHttpProxy)
.build();
ApplicationHandler mockHandler = createApplicationHandler(applicationRepository);
- doAnswer(invoc -> new StaticResponse(200, "text/html", "<html>" +
- "host=" + invoc.getArgument(1, String.class) + "," +
- "service=" + invoc.getArgument(2, String.class) + "," +
- "path=" + invoc.getArgument(3, String.class) + "</html>")).when(mockHttpProxy).get(any(), any(), any(), any());
+ doAnswer(invoc -> new StaticResponse(200,
+ "text/html",
+ "<html>" +
+ "host=" + invoc.getArgument(1, String.class) + "," +
+ "service=" + invoc.getArgument(2, String.class) + "," +
+ "path=" + invoc.getArgument(3, HttpURL.Path.class) +
+ "</html>"))
+ .when(mockHttpProxy).get(any(), any(), any(), any());
HttpResponse response = mockHandler.handle(createTestRequest(toUrlPath(applicationId, Zone.defaultZone(), true) + "/service/container-clustercontroller/" + host + "/status/some/path/clusterName1", GET));
- assertHttpStatusCodeAndMessage(response, 200, "text/html", "<html>host=foo.yahoo.com,service=container-clustercontroller,path=clustercontroller-status/v1/some/path/clusterName1</html>");
+ assertHttpStatusCodeAndMessage(response, 200, "text/html", "<html>host=foo.yahoo.com,service=container-clustercontroller,path=path '/clustercontroller-status/v1/some/path/clusterName1'</html>");
response = mockHandler.handle(createTestRequest(toUrlPath(applicationId, Zone.defaultZone(), true) + "/service/distributor/" + host + "/status/something", GET));
- assertHttpStatusCodeAndMessage(response, 200, "text/html", "<html>host=foo.yahoo.com,service=distributor,path=something</html>");
+ assertHttpStatusCodeAndMessage(response, 200, "text/html", "<html>host=foo.yahoo.com,service=distributor,path=path '/something'</html>");
response = mockHandler.handle(createTestRequest(toUrlPath(applicationId, Zone.defaultZone(), true) + "/service/fake-service/" + host + "/status/something", GET));
assertHttpStatusCodeAndMessage(response, 404, "{\"error-code\":\"NOT_FOUND\",\"message\":\"No status page for service: fake-service\"}");
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
index 790be6d45ba..7c2e0be0c3a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
@@ -121,13 +121,13 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
@Test
public void require_that_nonexistent_file_returns_not_found_when_deleted() throws IOException {
- assertDeleteFile(Response.Status.NOT_FOUND, "/test2.txt", "{\"error-code\":\"NOT_FOUND\",\"message\":\"Session " + sessionId + " does not contain a file 'test2.txt'\"}");
+ assertDeleteFile(Response.Status.NOT_FOUND, "/test2.txt", "{\"error-code\":\"NOT_FOUND\",\"message\":\"Session " + sessionId + " does not contain a file at path '/test2.txt'\"}");
}
@Test
public void require_that_files_can_be_deleted() throws IOException {
assertDeleteFile(Response.Status.OK, "/test.txt");
- assertDeleteFile(Response.Status.NOT_FOUND, "/test.txt", "{\"error-code\":\"NOT_FOUND\",\"message\":\"Session " + sessionId + " does not contain a file 'test.txt'\"}");
+ assertDeleteFile(Response.Status.NOT_FOUND, "/test.txt", "{\"error-code\":\"NOT_FOUND\",\"message\":\"Session " + sessionId + " does not contain a file at path '/test.txt'\"}");
assertDeleteFile(Response.Status.BAD_REQUEST, "/newtest", "{\"error-code\":\"BAD_REQUEST\",\"message\":\"File 'newtest' is not an empty directory\"}");
assertDeleteFile(Response.Status.OK, "/newtest/testfile.txt");
assertDeleteFile(Response.Status.OK, "/newtest");
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
index 702dd2792da..f77c7611858 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java
@@ -7,6 +7,7 @@ import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.TenantName;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
+import com.yahoo.restapi.HttpURL.Path;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.application.CompressedApplicationInputStreamTest;
@@ -155,7 +156,7 @@ public class SessionCreateHandlerTest extends SessionHandlerTest {
public void require_that_handler_unpacks_application() throws IOException {
File outFile = CompressedApplicationInputStreamTest.createTarFile();
createHandler().handle(post(outFile));
- ApplicationFile applicationFile = applicationRepository.getApplicationFileFromSession(tenant, 2, "services.xml", Session.Mode.READ);
+ ApplicationFile applicationFile = applicationRepository.getApplicationFileFromSession(tenant, 2, Path.parse("services.xml"), Session.Mode.READ);
assertTrue(applicationFile.exists());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/serviceview/StateRequestHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/serviceview/StateRequestHandlerTest.java
index fe025c9e861..35e63c46bf8 100644
--- a/configserver/src/test/java/com/yahoo/vespa/serviceview/StateRequestHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/serviceview/StateRequestHandlerTest.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.serviceview;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.jdisc.test.MockMetric;
+import com.yahoo.restapi.HttpURL.Path;
import com.yahoo.restapi.UriBuilder;
import com.yahoo.vespa.serviceview.bindings.ApplicationView;
import com.yahoo.vespa.serviceview.bindings.HealthClient;
@@ -45,7 +46,7 @@ public class StateRequestHandlerTest {
}
@Override
- protected HealthClient getHealthClient(String apiParams, Service s, int requestedPort, String uriQuery, Client client) {
+ protected HealthClient getHealthClient(Path apiParams, Service s, int requestedPort, String uriQuery, Client client) {
HealthClient healthClient = Mockito.mock(HealthClient.class);
HashMap<Object, Object> dummyHealthData = new HashMap<>();
HashMap<String, String> dummyLink = new HashMap<>();
@@ -75,7 +76,7 @@ public class StateRequestHandlerTest {
public final void test() {
Service s = correspondingModel.resolve("vespa.yahoo.com", 8080, null);
String api = "/state/v1";
- HashMap<?, ?> boom = testHandler.singleService(new UriBuilder("http://someserver:8080"), URI.create(EXTERNAL_BASE_URI), "default", "default", "default", "default", "default", s.getIdentifier(8080), api);
+ HashMap<?, ?> boom = testHandler.singleService(new UriBuilder("http://someserver:8080"), URI.create(EXTERNAL_BASE_URI), "default", "default", "default", "default", "default", s.getIdentifier(8080), Path.parse(api));
assertEquals(EXTERNAL_BASE_URI + "tenant/default/application/default/environment/default/region/default/instance/default/service/" + s.getIdentifier(8080) + api,
((Map<?, ?>) ((List<?>) boom.get("resources")).get(0)).get("url"));
}