Update environment controller to specifically capture all profile names unless they are specific file extensions (#2059)
Fixes #2058
This commit is contained in:
@@ -104,12 +104,14 @@ public class EnvironmentController {
|
||||
this.acceptEmpty = acceptEmpty;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{name}/{profiles:[^-]+}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@GetMapping(path = "/{name}/{profiles:(?!.*\\b(?:ya?ml|properties|json)\\b).*}",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Environment defaultLabel(@PathVariable String name, @PathVariable String profiles) {
|
||||
return getEnvironment(name, profiles, null, false);
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{name}/{profiles:[^-]+}", produces = EnvironmentMediaType.V2_JSON)
|
||||
@GetMapping(path = "/{name}/{profiles:(?!.*\\b(?:ya?ml|properties|json)\\b).*}",
|
||||
produces = EnvironmentMediaType.V2_JSON)
|
||||
public Environment defaultLabelIncludeOrigin(@PathVariable String name, @PathVariable String profiles) {
|
||||
return getEnvironment(name, profiles, null, true);
|
||||
}
|
||||
|
||||
@@ -77,6 +77,16 @@ class EnvironmentControllerIntegrationTests {
|
||||
verify(this.repository).findOne("foo", "default", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void profileWithDash() throws Exception {
|
||||
Environment dashEnvironment = new Environment("foo", "dev-db");
|
||||
dashEnvironment.add(new PropertySource("foo", new HashMap<>()));
|
||||
when(this.repository.findOne("foo", "dev-db", null, false)).thenReturn(dashEnvironment);
|
||||
this.mvc.perform(MockMvcRequestBuilders.get("/foo/dev-db"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
verify(this.repository).findOne("foo", "dev-db", null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertiesNoLabel() throws Exception {
|
||||
when(this.repository.findOne("foo", "default", null, false)).thenReturn(this.environment);
|
||||
|
||||
Reference in New Issue
Block a user