Grails 3.3.8 Spring Security UI插件的RegisterController.verifyRegistration使帐户处于锁定状态

时间:2018-12-03 16:00:00

标签: grails spring-security registration

我用一个集成测试创建了一个简单的Grails应用(https://github.com/spierepf/demo):

    void "test something"() {
        given:"a user account is created and given a registration code"
            def user = new User(username:"username", password:"password", accountLocked:true, accountExpired:false, enabled:true).save()
            def registrationCode = new RegistrationCode(username:user.username).save()

        when:"that user engages the verify registration action with their registration code's token"
            RestResponse resp = rest.get("http://localhost:${serverPort}/verifyRegistration?t=${registrationCode.token}")

        then:"that user account should be unlocked, not expired, and enabled"
            resp.status == 200
            def updatedUser = User.findByUsername(user.username)
            updatedUser.accountLocked == false
            updatedUser.accountExpired == false
            updatedUser.enabled == true
    }

我希望测试会创建一个新的“锁定的”用户对象,并带有一个关联的RegistrationCode对象。

然后,该应用程序将发送一封电子邮件,其中包含指向RegistrationCode令牌的verifyRegistration链接。测试触发了该链接,我希望该链接会导致User对象变为“解锁”状态。但是,这不会发生。

0 个答案:

没有答案