77import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
88import org .springframework .boot .test .context .SpringBootTest ;
99import org .springframework .http .MediaType ;
10+ import org .springframework .security .crypto .password .PasswordEncoder ;
1011import org .springframework .test .web .servlet .MockMvc ;
1112import org .springframework .test .web .servlet .MvcResult ;
1213import org .springframework .util .StringUtils ;
1314
1415import java .nio .charset .StandardCharsets ;
1516
16- import static org .junit .jupiter .api .Assertions .assertEquals ;
17- import static org .junit .jupiter .api .Assertions .assertTrue ;
17+ import static org .junit .jupiter .api .Assertions .*;
1818import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
1919import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .post ;
2020import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
@@ -27,6 +27,20 @@ public class SecurityJwtApplicationTest {
2727 @ Autowired
2828 private MockMvc mockMvc ;
2929
30+
31+ @ Autowired
32+ private PasswordEncoder passwordEncoder ;
33+
34+
35+ @ Test
36+ void encode (){
37+ String pwd1 = passwordEncoder .encode ("123456" );
38+ String pwd2 = passwordEncoder .encode ("123456" );
39+ System .out .println (pwd1 );
40+ System .out .println (pwd2 );
41+ assertNotEquals (pwd1 ,pwd2 );
42+ }
43+
3044 @ Test
3145 void login () throws Exception {
3246 JSONObject json = new JSONObject ();
@@ -37,6 +51,7 @@ void login() throws Exception {
3751 .contentType (MediaType .APPLICATION_JSON )).andExpect (status ().isOk ());
3852 }
3953
54+
4055 @ Test
4156 void loginError () throws Exception {
4257 JSONObject json = new JSONObject ();
0 commit comments