Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 108: Verifying a new user account does not unlock that account #112

Open
wants to merge 4 commits into
base: 4.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ classes
cobertura.ser
kindlegen
/plugin/src/main/templates/views
.java-version
.java-version
1 change: 1 addition & 0 deletions examples/extended/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dependencies {
testCompile "org.seleniumhq.selenium:selenium-support:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0"
testCompile "org.grails:grails-datastore-rest-client:6.1.10.RELEASE"

compile 'dumbster:dumbster:1.6', { transitive = false }
compile "org.grails.plugins:mail:$mailVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package spec

import grails.plugin.springsecurity.ui.RegistrationCode
import grails.plugins.rest.client.RestBuilder
import grails.plugins.rest.client.RestResponse
import grails.testing.mixin.integration.Integration
import spock.lang.Shared
import spock.lang.Specification
import test.User


@Integration
class VerifyRegistrationSpec extends Specification {

@Shared RestBuilder rest = new RestBuilder()

void "verify a call to the register/verifyRegistration endpoint properly updates the verified"() {
given: "a username"
String username = "username"

when: "a user account is created and given a registration code"
User user
RegistrationCode registrationCode

User.withNewTransaction {
user = new User(username: username, password: "password", accountLocked: true).save()
registrationCode = new RegistrationCode(username: username).save()
}


then: 'registration code token is populated'
registrationCode.token
user.accountLocked == true
user.accountExpired == false
user.enabled == true
user.username == username

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

then: "that user account should be unlocked, not expired, and enabled"
resp.status == 200

when:
User updatedUser = User.withNewTransaction(readOnly: true) {
User.findByUsername(username)
}

then:
updatedUser.username == username
updatedUser.accountExpired == false
updatedUser.enabled == true
updatedUser.accountLocked == false

}
}
2 changes: 1 addition & 1 deletion examples/simple/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
testCompile "org.seleniumhq.selenium:selenium-support:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0"

testCompile "org.grails:grails-datastore-rest-client:6.1.10.RELEASE"

compile 'dumbster:dumbster:1.6', { transitive = false }
compile "org.grails.plugins:mail:$mailVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package spec

import grails.plugin.springsecurity.ui.RegistrationCode
import grails.plugins.rest.client.RestBuilder
import grails.plugins.rest.client.RestResponse
import grails.testing.mixin.integration.Integration
import spock.lang.Shared
import spock.lang.Specification
import test.User

@Integration
class VerifyRegistrationSpec extends Specification {

@Shared RestBuilder rest = new RestBuilder()

void "verify a call to the register/verifyRegistration endpoint properly updates the verified"() {
given: "a username"
String username = "username"

when: "a user account is created and given a registration code"
User user
RegistrationCode registrationCode

User.withNewTransaction {
user = new User(username: username, password: "password", accountLocked: true).save()
registrationCode = new RegistrationCode(username: username).save()
}


then: 'registration code token is populated'
registrationCode.token
user.accountLocked == true
user.accountExpired == false
user.enabled == true
user.username == username

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

then: "that user account should be unlocked, not expired, and enabled"
resp.status == 200

when:
User updatedUser = User.withNewTransaction(readOnly: true) {
User.findByUsername(username)
}

then:
updatedUser.username == username
updatedUser.accountExpired == false
updatedUser.enabled == true
updatedUser.accountLocked == false

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ class SpringSecurityUiService implements AclStrategy, ErrorsStrategy, Persistent
callback instance
}

instance.save()
instance.save(flush: true)
if (instance.hasErrors()) {
uiErrorsStrategy.handleValidationErrors instance, this, methodName, transactionStatus
}
Expand Down