1@RunWith(SpringRunner.class)
2@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
3public class SecuredControllerRestTemplateIntegrationTest {
4
5 @Autowired
6 private TestRestTemplate template;
7
8 // ... other methods
9
10 @Test
11 public void givenAuthRequestOnPrivateService_shouldSucceedWith200() throws Exception {
12 ResponseEntity<String> result = template.withBasicAuth("spring", "secret")
13 .getForEntity("/private/hello", String.class);
14 assertEquals(HttpStatus.OK, result.getStatusCode());
15 }
16}
17