Reputation: 11307
Is it possible to disable password check in the test
environment? I cannot find a configuration item which would allow this, was thinking some meta programming in BootStrap.groovy
but haven't had any success...
import grails.util.Environment
switch (Environment.current) {
case Environment.TEST:
springSecurityService.metaClass.passwordOk = { true } // if it was only simple as this :)
...
Any ideas?
NOTE: I'm using the LDAP plugin for authentication
Upvotes: 0
Views: 97
Reputation: 171
Have you tried :
test {
grails.plugins.springsecurity.active = false
}
This will disable spring security plugin so none of your spring security stuff will work. You have to create a stub for getting the currentUser:
class StubSpringSecurityService {
def currentUser
Object getCurrentUser() {
return currentUser
}
String encodePassword(String password, salt = null) {
return password
}
}
Put in resources.groovy
if (GrailsUtil.environment == "test"){
springSecurityService(StubSpringSecurityService)
}
And then in your bootstrap file
if (GrailsUtil.environment == "test") {
def testUser = new User()
testUser.save(failOnError: true)
springSecurityService.currentUser = testUser;
}
Upvotes: 1