I am in the process of upgrading several apps from SpringBoot 1.3.2.RELEASE to 1.5.3, using springCloudVersion = 'Dalston.RELEASE'
As a part of this upgrade process, the annotations in my existing integration tests changed:
Old, deprecated way:
@RunWith(SpringJUnit4ClassRunner.class)
@Unroll
@WebAppConfiguration
@WebIntegrationTest(randomPort = true)
@SpringApplicationConfiguration(classes = TokenServerApplication)
New, upgraded way:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TokenServerApplication)
@EnableWebSecurity
@Unroll
This seems to compile just fine, but I noticed a variety of my tests began breaking, giving a 403 Forbidden response.
These tests that are failing should require sending a request with a valid 'x-auth-token' header. The response from my service should give a 403 "Not authenticated", but the message I am getting does not contain the "Not authenticated" message (it is more generic), and further, tests that should pass with valid tokens are also getting 403'd.
I am using the following to construct my requests:
@Autowired TestRestTemplate restTemplate
And the tests are all roughly set up the same:
@Test
void "test valid token"() {
HttpHeaders headers = new HttpHeaders()
headers.set("x-auth-token", tokenIngestExternal)
HttpEntity<String> entity = new HttpEntity<String>(headers)
ResponseEntity<Map> result = restTemplate.exchange("/authenticate", HttpMethod.GET, entity, Map.class)
assertTrue(result.getStatusCode() == HttpStatus.OK)
Map map = result.getBody()
assertTrue map.get('iss').equals("A")
assertTrue map.get('sub').equals("B")
assertTrue map.get('aud').equals("C")
assertTrue map.get('roles').equals("D")
}
This same basic methodology worked just fine before the upgrade to 1.5.3 and using the latest annotations for the integration test.
Am I missing an annotation or parameter or something? What's the dealio?