0

私は次のようなことをしたい:

class MySpec extends Specification{
    def 'test'(){
        given: 'a user that has its password encoded by SpringSecurity'
            def user = new SecUser(username: 'blah', password: 'p').save(flush:true)
            MessageDigest md = MessageDigest.getInstance('MD5')
            md.update('p'.getBytes('UTF-8'))
        expect: 'the password should be encoded with MD5 algorithm'
            user.password == (new BASE64Encoder()).encode(md.digest())
    }
}

Config.groovy に次の行を追加しました。

grails.plugins.springsecurity.password.algorithm="MD5"

これは機能していません (アサーションが失敗します)。何か案は??

4

1 に答える 1

1

自分でエンコードする代わりに、

springSecurityService.encodePassword(user.password)

あなたの塩を忘れないでください!持っている場合(持っていない場合は検討する必要があります!)、それを2番目の引数として渡すことができます。

于 2012-09-09T16:18:29.317 に答える