From 7263e223c5c2cfd5f8c81be494eb47710098dbd2 Mon Sep 17 00:00:00 2001 From: "nnhai1991@gmail.com" Date: Tue, 21 Aug 2018 22:31:44 +0800 Subject: [PATCH] update examples --- .../baeldung/security/ApplicationConfig.java | 2 +- .../src/main/webapp/WEB-INF/views/home.jsp | 24 +++++++++++-------- .../baeldung/security/HomeControllerTest.java | 16 ++++++------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/spring-boot-security-taglibs/src/main/java/org/baeldung/security/ApplicationConfig.java b/spring-boot-security-taglibs/src/main/java/org/baeldung/security/ApplicationConfig.java index 6419da3bdd..e8a95af5ce 100644 --- a/spring-boot-security-taglibs/src/main/java/org/baeldung/security/ApplicationConfig.java +++ b/spring-boot-security-taglibs/src/main/java/org/baeldung/security/ApplicationConfig.java @@ -35,7 +35,7 @@ public class ApplicationConfig extends WebSecurityConfigurerAdapter { http.csrf() .and() .authorizeRequests() - .antMatchers("/adminOnlyURL").hasRole("ADMIN") + .antMatchers("/userManagement").hasRole("ADMIN") .anyRequest().permitAll().and().httpBasic(); // @formatter:on } diff --git a/spring-boot-security-taglibs/src/main/webapp/WEB-INF/views/home.jsp b/spring-boot-security-taglibs/src/main/webapp/WEB-INF/views/home.jsp index 9bb96fe5fd..70440e8dc9 100644 --- a/spring-boot-security-taglibs/src/main/webapp/WEB-INF/views/home.jsp +++ b/spring-boot-security-taglibs/src/main/webapp/WEB-INF/views/home.jsp @@ -9,24 +9,28 @@ Home Page - - - ANONYMOUS Content + + + Login + + + Logout + + - AUTHENTICATED Content - - Content for users who have the "ADMIN" role. -

Welcome back, -

+ + + Manage Users +
Text Field:
- - Go to Admin Only URL + + Manage Users diff --git a/spring-boot-security-taglibs/src/test/java/org/baeldung/security/HomeControllerTest.java b/spring-boot-security-taglibs/src/test/java/org/baeldung/security/HomeControllerTest.java index 189a691496..e085fb4083 100644 --- a/spring-boot-security-taglibs/src/test/java/org/baeldung/security/HomeControllerTest.java +++ b/spring-boot-security-taglibs/src/test/java/org/baeldung/security/HomeControllerTest.java @@ -24,20 +24,20 @@ public class HomeControllerTest { .getForEntity("/", String.class) .getBody(); - // test - assertFalse(body.contains("ANONYMOUS")); + // test + assertFalse(body.contains("Login")); // test - assertTrue(body.contains("AUTHENTICATED Content")); + assertTrue(body.contains("Logout")); // test - assertTrue(body.contains("Content for users who have the \"ADMIN\" role.")); + assertTrue(body.contains("Manage Users")); // test assertTrue(body.contains("testUser")); // test - assertTrue(body.contains("")); + assertTrue(body.contains("")); // test assertTrue(body.contains(" - assertTrue(body.contains("ANONYMOUS Content")); + // test + assertTrue(body.contains("Login")); // test - assertFalse(body.contains("AUTHENTICATED Content")); + assertFalse(body.contains("Logout")); } }