Skip to content
Merged
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
14 changes: 8 additions & 6 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,18 @@ dependencies {
implementation "org.nosphere.apache.rat:org.nosphere.apache.rat.gradle.plugin:${versions.get('ratVersion')}"
implementation "org.gradle.crypto.checksum:org.gradle.crypto.checksum.gradle.plugin:${versions.get('gradleCryptoChecksumVersion')}"

testImplementation 'org.spockframework:spock-core'
testImplementation 'org.spockframework:spock-core', {
exclude(group: 'org.codehaus.groovy') // Use Gradle provided version because: Could not resolve org.codehaus.groovy:groovy:3.0.12
}
testRuntimeOnly 'org.junit.platform:junit-platform-launcher', {
// In Gradle 9, this needs to be declared
// https://docs.gradle.org/8.3/userguide/upgrading_version_8.html#test_framework_implementation_dependencies
}
}

tasks.withType(Test).configureEach {
onlyIf {
![
'skipTests'
].find {
project.hasProperty(it)
}
!project.hasProperty('skipTests')
}

useJUnitPlatform()
Expand Down
5 changes: 1 addition & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
# under the License.
#
projectVersion=7.0.0-SNAPSHOT
grailsVersion=7.0.0-SNAPSHOT
grailsVersion=7.0.0-M5
javaVersion=17

# TODO: This is a work around since the bom does not support exclusions and spring forces groovy version 4.0.26
groovy.version=4.0.27

unboundidLdapSdk=7.0.2
apacheDsVersion=1.5.4
asciidoctorGradlePluginVersion=4.0.4
Expand Down
8 changes: 5 additions & 3 deletions gradle/plugin-config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
* under the License.
*/

import org.grails.gradle.plugin.core.GrailsExtension

// The plugins do not have an Application class and are not runnable by themselves
tasks.named('bootRun') { enabled = false }
tasks.named('findMainClass') { enabled = false }

grails {
// turn off dependency management so we *know* we're testing with the right versions and not from a remote repository
springDependencyManagement = false
extensions.configure(GrailsExtension) {
// Explicit `it` is required in extension configuration blocks
it.springDependencyManagement = false
}
29 changes: 17 additions & 12 deletions gradle/test-config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import org.grails.gradle.plugin.core.GrailsExtension

dependencies {
// In Gradle 9, this needs to be declared
// https://docs.gradle.org/8.3/userguide/upgrading_version_8.html#test_framework_implementation_dependencies
Expand All @@ -25,11 +27,7 @@ dependencies {

tasks.withType(Test).configureEach {
onlyIf {
![
'skipTests'
].find {
project.hasProperty(it)
}
!project.hasProperty('skipTests')
}

useJUnitPlatform()
Expand All @@ -42,20 +40,27 @@ tasks.withType(Test).configureEach {

tasks.named('integrationTest', Test) {
onlyIf {
![
'skipTests'
].find {
project.hasProperty(it)
}
!project.hasProperty('skipTests')
}

systemProperty 'geb.build.reportsDir', reporting.file("$project.projectDir/build/geb-reports")
systemProperties System.properties
systemProperty('geb.build.reportsDir', reporting.file("$projectDir/build/geb-reports"))
systemProperty('grails.geb.reporting.directory', reporting.file("$projectDir/build/geb-reports").canonicalFile.absolutePath)
// systemProperty('grails.geb.recording.mode', 'RECORD_ALL')
systemProperties(System.properties)

doFirst {
logger.quiet(
'\n - Running tests for configuration: {} and Grails: {}',
System.getProperty('TESTCONFIG', 'N/S'),
grailsVersion
)
}
}

extensions.configure(GrailsExtension) {
// Explicit `it` is required in extension configuration blocks

// turn off dependency management so we *know* we're testing with the right
// versions and not from a remote repository
it.springDependencyManagement = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LoginPage extends Page {

static url = 'login/auth'

static at = { waitFor { title == 'Login' } }
static at = { title == 'Login' }

static content = {
loginForm { $('form') }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LoginPage extends Page {

static url = 'login/auth'

static at = { waitFor { title == 'Login' } }
static at = { title == 'Login' }

static content = {
loginForm { $('form') }
Expand Down
3 changes: 0 additions & 3 deletions plugin-core/examples/integration-test-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ dependencies {
integrationTestImplementation 'org.apache.grails:grails-testing-support-web', {
// @Integration
}
integrationTestImplementation 'org.sitemesh:sitemesh', {
// SiteMeshFilter
}
integrationTestImplementation 'org.springframework:spring-test', {
// MockFilterChain, MockHttpServletRequest, MockHttpServletResponse
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package grails.plugin.springsecurity

import org.sitemesh.webapp.SiteMeshFilter
import org.springframework.web.filter.FormContentFilter

import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE
Expand Down Expand Up @@ -90,7 +89,7 @@ class SpringSecurityUtilsIntegrationSpec extends AbstractIntegrationSpec {
def map = SpringSecurityUtils.configuredOrderedFilters

expect:
11 == map.size()
10 == map.size()
map[Integer.MIN_VALUE + 10] instanceof SecurityRequestHolderFilter
map[SecurityFilterPosition.SECURITY_CONTEXT_FILTER.order] instanceof SecurityContextPersistenceFilter
map[SecurityFilterPosition.LOGOUT_FILTER.order] instanceof MutableLogoutFilter
Expand All @@ -99,7 +98,6 @@ class SpringSecurityUtilsIntegrationSpec extends AbstractIntegrationSpec {
map[SecurityFilterPosition.REMEMBER_ME_FILTER.order] instanceof GrailsRememberMeAuthenticationFilter
map[SecurityFilterPosition.ANONYMOUS_FILTER.order] instanceof GrailsAnonymousAuthenticationFilter
map[SecurityFilterPosition.EXCEPTION_TRANSLATION_FILTER.order-10] instanceof FormContentFilter
map[SecurityFilterPosition.EXCEPTION_TRANSLATION_FILTER.order-4] instanceof SiteMeshFilter
map[SecurityFilterPosition.EXCEPTION_TRANSLATION_FILTER.order] instanceof ExceptionTranslationFilter
map[SecurityFilterPosition.FILTER_SECURITY_INTERCEPTOR.order] instanceof FilterSecurityInterceptor

Expand Down Expand Up @@ -128,7 +126,7 @@ class SpringSecurityUtilsIntegrationSpec extends AbstractIntegrationSpec {
SpringSecurityUtils.clientRegisterFilter 'dummyFilter', SecurityFilterPosition.LOGOUT_FILTER.order + 10

then:
12 == map.size()
11 == map.size()
map[SecurityFilterPosition.LOGOUT_FILTER.order + 10] instanceof DummyFilter

when:
Expand All @@ -144,9 +142,8 @@ class SpringSecurityUtilsIntegrationSpec extends AbstractIntegrationSpec {
filters[6] instanceof GrailsRememberMeAuthenticationFilter
filters[7] instanceof GrailsAnonymousAuthenticationFilter
filters[8] instanceof FormContentFilter
filters[9] instanceof SiteMeshFilter
filters[10] instanceof ExceptionTranslationFilter
filters[11] instanceof FilterSecurityInterceptor
filters[9] instanceof ExceptionTranslationFilter
filters[10] instanceof FilterSecurityInterceptor
}

void 'reauthenticate'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import geb.Page
class LoginPage extends Page {
static url = "login/auth"

static at = { waitFor { title == 'Login' } }
static at = { title == 'Login' }

static content = {
loginButton { $("#submit", 0) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import geb.Page
class LoginPage extends Page {
static url = "login/auth"

static at = { waitFor { title == 'Login' } }
static at = { title == 'Login' }

static content = {
loginButton { $("#submit", 0) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LoginPage extends Page {

static url = 'login/auth'

static at = { waitFor { title == 'Login' } }
static at = { title == 'Login' }

static content = {
loginForm { $('form') }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LoginPage extends Page {

static url = 'login/auth'

static at = { waitFor { title == 'Login' } }
static at = { title == 'Login' }

static content = {
loginForm { $('form') }
Expand Down
3 changes: 3 additions & 0 deletions plugin-ldap/examples/retrieve-db-roles/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ dependencies {
implementation 'org.webjars:bootstrap:4.1.3'
implementation 'org.webjars:jquery:3.3.1'

// in-memory ldap server for testing
implementation "com.unboundid:unboundid-ldapsdk:$unboundidLdapSdk"

runtimeOnly 'cloud.wondrify:asset-pipeline-grails'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.zaxxer:HikariCP'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ grails {
authorityJoinClassName = 'com.test.UserRole'
}

// http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
ldap {
context {
managerDn = 'cn=read-only-admin,dc=example,dc=com'
managerPassword = 'password'
server = 'ldap://ldap.forumsys.com:389/' //'ldap://[ip]:[port]/'
managerDn = 'cn=admin,dc=example,dc=com'
managerPassword = 'secret'
server = System.getProperty('grails.test.ldap.url')
}
authorities {
ignorePartialResultException = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,135 @@

package com.test

import com.unboundid.ldap.listener.InMemoryDirectoryServer
import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig
import com.unboundid.ldap.listener.InMemoryListenerConfig
import com.unboundid.ldap.sdk.Attribute
import com.unboundid.ldap.sdk.Entry

import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration

import groovy.transform.CompileStatic

@CompileStatic
class Application extends GrailsAutoConfiguration {

static InMemoryDirectoryServer directoryServer
static private Entry scientistsUnit

static void main(String[] args) {
def config = new InMemoryDirectoryServerConfig('dc=example,dc=com')
config.addAdditionalBindCredentials('cn=admin,dc=example,dc=com', 'secret')
config.setListenerConfigs(
InMemoryListenerConfig.createLDAPConfig(
'default',
null,
0,
null,
false,
false
)
)

directoryServer = new InMemoryDirectoryServer(config)
def base = new Entry(
'dc=example,dc=com',
new Attribute('objectClass', 'top', 'domain'),
new Attribute('dc', 'example')
)
directoryServer.add(base)

def people = new Entry(
'ou=people,dc=example,dc=com',
new Attribute('objectClass', 'top', 'organizationalUnit'),
new Attribute('ou', 'people')
)
directoryServer.add(people)

def mathematiciansUnit = new Entry(
'ou=mathematicians,dc=example,dc=com',
new Attribute('objectClass', 'top', 'organizationalUnit'),
new Attribute('ou', 'mathematicians')
)
directoryServer.add(mathematiciansUnit)

scientistsUnit = new Entry(
'ou=scientists,dc=example,dc=com',
new Attribute('objectClass', 'top', 'organizationalUnit'),
new Attribute('ou', 'scientists')
)
directoryServer.add(scientistsUnit)

def jane = new Entry(
'uid=jane,ou=people,dc=example,dc=com',
new Attribute('objectClass', 'inetOrgPerson'),
new Attribute('uid', 'jane'),
new Attribute('cn', 'Jane Doe'),
new Attribute('sn', 'Doe'),
new Attribute('mail', '[email protected]'),
new Attribute('telephoneNumber', '+1 555 111 2222'),
new Attribute('userPassword', 'password')
)
directoryServer.add(jane)

['riemann', 'gauss', 'euler', 'euclid'].each { uid ->
directoryServer.add(new Entry(
"uid=$uid,ou=mathematicians,dc=example,dc=com" as String,
new Attribute('objectClass', 'inetOrgPerson'),
new Attribute('uid', uid),
new Attribute('cn', uid.capitalize()),
new Attribute('sn', uid.capitalize()),
new Attribute('userPassword', 'password')
))
}

def mathGroup = new Entry(
'cn=mathematicians,ou=mathematicians,dc=example,dc=com',
new Attribute('objectClass', 'top', 'groupOfUniqueNames'),
new Attribute('cn', 'mathematicians'),
new Attribute('uniqueMember',
'uid=riemann,ou=mathematicians,dc=example,dc=com',
'uid=gauss,ou=mathematicians,dc=example,dc=com',
'uid=euler,ou=mathematicians,dc=example,dc=com',
'uid=euclid,ou=mathematicians,dc=example,dc=com'
)
)
directoryServer.add(mathGroup)

['einstein', 'newton', 'galieleo', 'tesla'].each { uid ->
directoryServer.add(new Entry(
"uid=$uid,ou=scientists,dc=example,dc=com" as String,
new Attribute('objectClass', 'inetOrgPerson'),
new Attribute('uid', uid),
new Attribute('cn', uid.capitalize()),
new Attribute('sn', uid.capitalize()),
new Attribute('userPassword', 'password')
))
}
def scientistGroup = new Entry(
'cn=scientists,ou=scientists,dc=example,dc=com',
new Attribute('objectClass', 'top', 'groupOfUniqueNames'),
new Attribute('cn', 'scientists'),
new Attribute('uniqueMember',
'uid=einstein,ou=scientists,dc=example,dc=com',
'uid=newton,ou=scientists,dc=example,dc=com',
'uid=galieleo,ou=scientists,dc=example,dc=com',
'uid=tesla,ou=scientists,dc=example,dc=com'
)
)
directoryServer.add(scientistGroup)
directoryServer.startListening()
System.setProperty('grails.test.ldap.url', "ldap://localhost:$directoryServer.listenPort")

GrailsApp.run(Application, args)
}

@Override
void onShutdown(Map<String, Object> event) {
if (directoryServer) {
directoryServer.close()
directoryServer = null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LoginPage extends Page {

static url = 'login/auth'

static at = { waitFor { title == 'Login' } }
static at = { title == 'Login' }

static content = {
loginForm { $('form') }
Expand Down
Loading
Loading