Add Spring Boot Hello World guide
Add Spring Boot Hello World Guide Fixes gh-3866
This commit is contained in:
+4
-4
@@ -76,7 +76,7 @@ public class HelloWorldApplicationTests {
|
||||
|
||||
@Test
|
||||
public void loginUser() throws Exception {
|
||||
this.mockMvc.perform(formLogin().user("user1").password("password1"))
|
||||
this.mockMvc.perform(formLogin().user("user").password("password"))
|
||||
.andExpect(authenticated());
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class HelloWorldApplicationTests {
|
||||
|
||||
@Test
|
||||
public void loginUserAccessProtected() throws Exception {
|
||||
MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user1").password("password1"))
|
||||
MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user").password("password"))
|
||||
.andExpect(authenticated())
|
||||
.andReturn();
|
||||
|
||||
@@ -102,7 +102,7 @@ public class HelloWorldApplicationTests {
|
||||
|
||||
@Test
|
||||
public void loginUserValidateLogout() throws Exception {
|
||||
MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user1").password("password1"))
|
||||
MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user").password("password"))
|
||||
.andExpect(authenticated())
|
||||
.andReturn();
|
||||
|
||||
@@ -117,4 +117,4 @@ public class HelloWorldApplicationTests {
|
||||
.andExpect(unauthenticated())
|
||||
.andExpect(status().is3xxRedirection());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
.withUser("user1").password("password1").roles("USER");
|
||||
.withUser("user").password("password").roles("USER");
|
||||
}
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ logging:
|
||||
|
||||
spring:
|
||||
thymeleaf:
|
||||
cache: true
|
||||
cache: false
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
Logged in user: <span sec:authentication="name"></span> |
|
||||
Roles: <span sec:authentication="principal.authorities"></span>
|
||||
<div>
|
||||
<form action="/logout" method="post">
|
||||
<form action="#" th:action="@{/logout}" method="post">
|
||||
<input type="submit" value="Logout" />
|
||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -22,4 +21,4 @@
|
||||
<li>Go to the <a href="/user/index" th:href="@{/user/index}">secured pages</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1>Login page</h1>
|
||||
<p>Example user: user1 / password1</p>
|
||||
<p>Example user: user / password</p>
|
||||
<p th:if="${loginError}" class="error">Wrong user or password</p>
|
||||
<form th:action="@{/login}" method="post">
|
||||
<label for="username">Username</label>:
|
||||
|
||||
Reference in New Issue
Block a user