Test insecure, insensitive endpoint with property that's always available

The user property is only available on Unix-like platforms (due to
the USER environment variable). This commit updates the test to
explicitly set a specific property and then check that it's accessible
via the env endpoint rather than using one that is OS-specific.

See gh-7868
See gh-7881
This commit is contained in:
Andy Wilkinson
2017-01-17 13:17:32 +00:00
parent 8666248d27
commit 682d0f524f

View File

@@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
"endpoints.env.sensitive=false" })
"endpoints.env.sensitive=false", "foo=bar" })
public class SampleHypermediaUiSecureApplicationTests {
@Autowired
@@ -47,10 +47,10 @@ public class SampleHypermediaUiSecureApplicationTests {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/env",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
ResponseEntity<String> user = this.restTemplate.getForEntity("/env/user",
ResponseEntity<String> user = this.restTemplate.getForEntity("/env/foo",
String.class);
assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(user.getBody()).contains("{\"user\":");
assertThat(user.getBody()).contains("{\"foo\":");
}
@Test