Testing Spring Boot Security simply

后端 未结 2 1954
遥遥无期
遥遥无期 2021-02-07 16:10

I\'m struggling with testing access control on URLs protected by Spring Security.

The configuration looks like this:

    http
            .authorizeReque         


        
2条回答
  •  心在旅途
    2021-02-07 16:58

    Okay, figured it out.

    mockMvc.perform(get("/api/user/account")
          .with(user("user")))
          .andExpect(status().isOk());
    

    It works now.

提交回复
热议问题