|
16 | 16 |
|
17 | 17 | package sample.ui.method;
|
18 | 18 |
|
| 19 | +import static org.junit.Assert.assertEquals; |
| 20 | +import static org.junit.Assert.assertTrue; |
| 21 | + |
19 | 22 | import java.util.Arrays;
|
20 | 23 | import java.util.regex.Matcher;
|
21 | 24 | import java.util.regex.Pattern;
|
22 | 25 |
|
23 |
| -import org.junit.Ignore; |
24 | 26 | import org.junit.Test;
|
25 | 27 | import org.junit.runner.RunWith;
|
26 | 28 | import org.springframework.beans.factory.annotation.Value;
|
27 | 29 | import org.springframework.boot.test.IntegrationTest;
|
28 |
| -import org.springframework.boot.test.TestRestTemplate; |
29 | 30 | import org.springframework.boot.test.SpringApplicationConfiguration;
|
| 31 | +import org.springframework.boot.test.TestRestTemplate; |
30 | 32 | import org.springframework.http.HttpEntity;
|
31 | 33 | import org.springframework.http.HttpHeaders;
|
32 | 34 | import org.springframework.http.HttpMethod;
|
|
39 | 41 | import org.springframework.util.LinkedMultiValueMap;
|
40 | 42 | import org.springframework.util.MultiValueMap;
|
41 | 43 |
|
42 |
| -import static org.junit.Assert.assertEquals; |
43 |
| -import static org.junit.Assert.assertTrue; |
44 |
| - |
45 | 44 | /**
|
46 | 45 | * Basic integration tests for demo application.
|
47 | 46 | *
|
@@ -117,13 +116,19 @@ public void testManagementProtected() throws Exception {
|
117 | 116 | }
|
118 | 117 |
|
119 | 118 | @Test
|
120 |
| - @Ignore("https://github.com/spring-projects/spring-boot/issues/699") |
121 | 119 | public void testManagementAuthorizedAccess() throws Exception {
|
122 |
| - ResponseEntity<String> entity = new TestRestTemplate("user", "user") |
| 120 | + ResponseEntity<String> entity = new TestRestTemplate("admin", "admin") |
123 | 121 | .getForEntity("http://localhost:" + port + "/beans", String.class);
|
124 | 122 | assertEquals(HttpStatus.OK, entity.getStatusCode());
|
125 | 123 | }
|
126 | 124 |
|
| 125 | + @Test |
| 126 | + public void testManagementUnauthorizedAccess() throws Exception { |
| 127 | + ResponseEntity<String> entity = new TestRestTemplate("user", "user") |
| 128 | + .getForEntity("http://localhost:" + port + "/beans", String.class); |
| 129 | + assertEquals(HttpStatus.FORBIDDEN, entity.getStatusCode()); |
| 130 | + } |
| 131 | + |
127 | 132 | private void getCsrf(MultiValueMap<String, String> form, HttpHeaders headers) {
|
128 | 133 | ResponseEntity<String> page = new TestRestTemplate().getForEntity(
|
129 | 134 | "http://localhost:" + port + "/login", String.class);
|
|
0 commit comments