|
|
@ -39,12 +39,14 @@ public class CloudFoundryDiscoveryMvcEndpointTests {
|
|
|
|
|
|
|
|
|
|
|
|
private CloudFoundryDiscoveryMvcEndpoint endpoint;
|
|
|
|
private CloudFoundryDiscoveryMvcEndpoint endpoint;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Set<NamedMvcEndpoint> endpoints;
|
|
|
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
@Before
|
|
|
|
public void setup() {
|
|
|
|
public void setup() {
|
|
|
|
NamedMvcEndpoint testMvcEndpoint = new TestMvcEndpoint(new TestEndpoint("a"));
|
|
|
|
NamedMvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a"));
|
|
|
|
Set<NamedMvcEndpoint> endpoints = new LinkedHashSet<NamedMvcEndpoint>();
|
|
|
|
this.endpoints = new LinkedHashSet<NamedMvcEndpoint>();
|
|
|
|
endpoints.add(testMvcEndpoint);
|
|
|
|
this.endpoints.add(endpoint);
|
|
|
|
this.endpoint = new CloudFoundryDiscoveryMvcEndpoint(endpoints);
|
|
|
|
this.endpoint = new CloudFoundryDiscoveryMvcEndpoint(this.endpoints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -56,6 +58,7 @@ public class CloudFoundryDiscoveryMvcEndpointTests {
|
|
|
|
public void linksResponseWhenRequestUriHasNoTrailingSlash() throws Exception {
|
|
|
|
public void linksResponseWhenRequestUriHasNoTrailingSlash() throws Exception {
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
|
|
|
"/cloudfoundryapplication");
|
|
|
|
"/cloudfoundryapplication");
|
|
|
|
|
|
|
|
AccessLevel.FULL.put(request);
|
|
|
|
Map<String, CloudFoundryDiscoveryMvcEndpoint.Link> links = this.endpoint
|
|
|
|
Map<String, CloudFoundryDiscoveryMvcEndpoint.Link> links = this.endpoint
|
|
|
|
.links(request).get("_links");
|
|
|
|
.links(request).get("_links");
|
|
|
|
assertThat(links.get("self").getHref())
|
|
|
|
assertThat(links.get("self").getHref())
|
|
|
@ -68,6 +71,7 @@ public class CloudFoundryDiscoveryMvcEndpointTests {
|
|
|
|
public void linksResponseWhenRequestUriHasTrailingSlash() throws Exception {
|
|
|
|
public void linksResponseWhenRequestUriHasTrailingSlash() throws Exception {
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
|
|
|
"/cloudfoundryapplication/");
|
|
|
|
"/cloudfoundryapplication/");
|
|
|
|
|
|
|
|
AccessLevel.FULL.put(request);
|
|
|
|
Map<String, CloudFoundryDiscoveryMvcEndpoint.Link> links = this.endpoint
|
|
|
|
Map<String, CloudFoundryDiscoveryMvcEndpoint.Link> links = this.endpoint
|
|
|
|
.links(request).get("_links");
|
|
|
|
.links(request).get("_links");
|
|
|
|
assertThat(links.get("self").getHref())
|
|
|
|
assertThat(links.get("self").getHref())
|
|
|
@ -76,6 +80,23 @@ public class CloudFoundryDiscoveryMvcEndpointTests {
|
|
|
|
.isEqualTo("http://localhost/cloudfoundryapplication/a");
|
|
|
|
.isEqualTo("http://localhost/cloudfoundryapplication/a");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void linksResponseWhenRequestHasAccessLevelRestricted() throws Exception {
|
|
|
|
|
|
|
|
NamedMvcEndpoint testHealthMvcEndpoint = new TestMvcEndpoint(
|
|
|
|
|
|
|
|
new TestEndpoint("health"));
|
|
|
|
|
|
|
|
this.endpoints.add(testHealthMvcEndpoint);
|
|
|
|
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
|
|
|
|
|
|
|
"/cloudfoundryapplication/");
|
|
|
|
|
|
|
|
AccessLevel.RESTRICTED.put(request);
|
|
|
|
|
|
|
|
Map<String, CloudFoundryDiscoveryMvcEndpoint.Link> links = this.endpoint
|
|
|
|
|
|
|
|
.links(request).get("_links");
|
|
|
|
|
|
|
|
assertThat(links.get("self").getHref())
|
|
|
|
|
|
|
|
.isEqualTo("http://localhost/cloudfoundryapplication");
|
|
|
|
|
|
|
|
assertThat(links.get("health").getHref())
|
|
|
|
|
|
|
|
.isEqualTo("http://localhost/cloudfoundryapplication/health");
|
|
|
|
|
|
|
|
assertThat(links.get("a")).isNull();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static class TestEndpoint extends AbstractEndpoint<Object> {
|
|
|
|
private static class TestEndpoint extends AbstractEndpoint<Object> {
|
|
|
|
|
|
|
|
|
|
|
|
TestEndpoint(String id) {
|
|
|
|
TestEndpoint(String id) {
|
|
|
|