Merge branch '1.2.x'
This commit is contained in:
@@ -61,11 +61,11 @@ public class SampleMethodSecurityApplicationTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
||||
"http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(
|
||||
headers), String.class);
|
||||
"http://localhost:" + this.port, HttpMethod.GET,
|
||||
new HttpEntity<Void>(headers), String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity
|
||||
.getBody().contains("<title>Login"));
|
||||
assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
|
||||
entity.getBody().contains("<title>Login"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,8 +81,8 @@ public class SampleMethodSecurityApplicationTests {
|
||||
new HttpEntity<MultiValueMap<String, String>>(form, headers),
|
||||
String.class);
|
||||
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
|
||||
assertEquals("http://localhost:" + this.port + "/", entity.getHeaders()
|
||||
.getLocation().toString());
|
||||
assertEquals("http://localhost:" + this.port + "/",
|
||||
entity.getHeaders().getLocation().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,18 +100,18 @@ public class SampleMethodSecurityApplicationTests {
|
||||
assertEquals(HttpStatus.FOUND, entity.getStatusCode());
|
||||
String cookie = entity.getHeaders().getFirst("Set-Cookie");
|
||||
headers.set("Cookie", cookie);
|
||||
ResponseEntity<String> page = new TestRestTemplate().exchange(entity.getHeaders()
|
||||
.getLocation(), HttpMethod.GET, new HttpEntity<Void>(headers),
|
||||
String.class);
|
||||
ResponseEntity<String> page = new TestRestTemplate().exchange(
|
||||
entity.getHeaders().getLocation(), HttpMethod.GET,
|
||||
new HttpEntity<Void>(headers), String.class);
|
||||
assertEquals(HttpStatus.FORBIDDEN, page.getStatusCode());
|
||||
assertTrue("Wrong body (message doesn't match):\n" + entity.getBody(), page
|
||||
.getBody().contains("Access denied"));
|
||||
assertTrue("Wrong body (message doesn't match):\n" + entity.getBody(),
|
||||
page.getBody().contains("Access denied"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManagementProtected() throws Exception {
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.port + "/beans", String.class);
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.getForEntity("http://localhost:" + this.port + "/beans", String.class);
|
||||
assertEquals(HttpStatus.UNAUTHORIZED, entity.getStatusCode());
|
||||
}
|
||||
|
||||
@@ -130,8 +130,8 @@ public class SampleMethodSecurityApplicationTests {
|
||||
}
|
||||
|
||||
private void getCsrf(MultiValueMap<String, String> form, HttpHeaders headers) {
|
||||
ResponseEntity<String> page = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.port + "/login", String.class);
|
||||
ResponseEntity<String> page = new TestRestTemplate()
|
||||
.getForEntity("http://localhost:" + this.port + "/login", String.class);
|
||||
String cookie = page.getHeaders().getFirst("Set-Cookie");
|
||||
headers.set("Cookie", cookie);
|
||||
String body = page.getBody();
|
||||
|
||||
Reference in New Issue
Block a user