How to unit test controllers that use springSecurityService?

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

I have a user class like such:

class User {
    transient springSecurityService
    String displayName
    String password

    protected void encode         


        
4条回答
  •  没有蜡笔的小新
    2021-02-08 19:49

    In my case I tried to override SecUser's encodePassword() implementation -which calls springSecurityService.encodePassword().

    I was surprised because I needed to override the class and the instance (if I didn't override any, it fails):

    SecUser.metaClass.encodePassword = { 'a' }
    user.metaClass.encodePassword = { 'b' }
    

    any idea of why do I need this?

提交回复
热议问题