additional tests and content
This commit is contained in:
parent
0d684eed97
commit
3f8eddad33
@ -35,6 +35,7 @@ public class ApplicationConfig extends WebSecurityConfigurerAdapter {
|
||||
http.csrf()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/adminOnlyURL").hasRole("ADMIN")
|
||||
.anyRequest().permitAll().and().httpBasic();
|
||||
// @formatter:on
|
||||
}
|
||||
|
@ -14,9 +14,9 @@
|
||||
ANONYMOUS
|
||||
</sec:authorize>
|
||||
<sec:authorize access="isAuthenticated()">
|
||||
AUTHENTICATED
|
||||
AUTHENTICATED Content
|
||||
<sec:authorize access="hasRole('ADMIN')">
|
||||
ADMIN ROLE
|
||||
Content for users who have the "ADMIN" role.
|
||||
</sec:authorize>
|
||||
<h2>
|
||||
principal.username:
|
||||
@ -26,6 +26,9 @@
|
||||
<sec:csrfInput />
|
||||
Text Field: <br /> <input type="text" name="textField" />
|
||||
</form>
|
||||
<sec:authorize url="/adminOnlyURL">
|
||||
<a href="/adminOnlyURL">Go to Admin Only URL</a>
|
||||
</sec:authorize>
|
||||
</sec:authorize>
|
||||
</body>
|
||||
</html>
|
@ -31,11 +31,14 @@ public class HomeControllerTest {
|
||||
assertTrue(body.contains("AUTHENTICATED"));
|
||||
|
||||
// test <sec:authorize access="hasRole('ADMIN')">
|
||||
assertTrue(body.contains("ADMIN ROLE"));
|
||||
assertTrue(body.contains("Content for users who have the \"ADMIN\" role."));
|
||||
|
||||
// test <sec:authentication property="principal.username" />
|
||||
assertTrue(body.contains("testUser"));
|
||||
|
||||
// test <sec:authorize url="/adminOnlyURL">
|
||||
assertTrue(body.contains("<a href=\"/adminOnlyURL\">"));
|
||||
|
||||
// test <sec:csrfInput />
|
||||
assertTrue(body.contains("<input type=\"hidden\" name=\"_csrf\" value=\""));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user