How to unit test controllers that use springSecurityService?

后端 未结 4 1350
傲寒
傲寒 2021-02-08 19:05

I have a user class like such:

class User {
    transient springSecurityService
    String displayName
    String password

    protected void encode         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-08 19:48

    I've done that like this:

        protected void encodePassword() {
            // SpringSecutiryService is not injected in tests.
            if (springSecurityService)
                password = springSecurityService.encodePassword(formPassword)
        }
    

提交回复
热议问题