From 14f6164b2a4e4043e057f29ef1a6ae5ea179e637 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Fri, 22 Nov 2024 15:48:46 -0800 Subject: [PATCH 01/25] Use grails-bom --- build.gradle | 5 ++ gradle/libs.versions.toml | 107 +++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 60 deletions(-) diff --git a/build.gradle b/build.gradle index 7107a581..95e6ce07 100644 --- a/build.gradle +++ b/build.gradle @@ -26,6 +26,8 @@ if (isReleaseVersion) { } } subprojects { + apply plugin: 'groovy' + version = rootProject.version repositories { mavenCentral() @@ -37,6 +39,9 @@ subprojects { } } } + dependencies { + implementation platform(libs.grails.bom) + } } // Do not generate extra load on Nexus with new staging repository if signing fails diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 079807df..29f3159a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,60 +1,47 @@ [versions] asset-pipeline = '5.0.1' -commons-text = '1.12.0' ehcache = '3.10.8' -geb = '7.0' -gorm-hibernate5 = '9.0.0-SNAPSHOT' grails = '7.0.0-SNAPSHOT' grails-async-and-events = '7.0.0-SNAPSHOT' -grails-datamapping = '9.0.0-SNAPSHOT' -grails-gsp = '7.0.0-SNAPSHOT' -grails-converters = '6.0.0-SNAPSHOT' grails-testing-support = '4.0.0-SNAPSHOT' groovy = '4.0.22' h2database = '2.3.232' -jakarta-annotation-api = '3.0.0' -jakarta-servlet-api = '6.0.0' micronaut = '4.5.3' selenium = '4.19.1' selenium-safari = '4.19.1' -slf4j = '2.0.16' -spock = '2.3-groovy-4.0' -spring = '6.1.12' -springboot = '3.3.3' -spring-security = '6.3.3' -tomcat = '10.1.29' [libraries] -commons-text = { module = 'org.apache.commons:commons-text', version.ref = 'commons-text' } +commons-text = { module = 'org.apache.commons:commons-text' } ehcache = { module = 'org.ehcache:ehcache', version.ref = 'ehcache' } -geb-core = { module = 'org.gebish:geb-core', version.ref = 'geb' } -geb-spock = { module = 'org.gebish:geb-spock', version.ref = 'geb' } -gorm-hibernate5 = { module = 'org.grails.plugins:hibernate5', version.ref = 'gorm-hibernate5' } +geb-core = { module = 'org.gebish:geb-core' } +geb-spock = { module = 'org.gebish:geb-spock' } +gorm-hibernate5 = { module = 'org.grails.plugins:hibernate5' } grails-asset-pipeline = { module = 'com.bertramlabs.plugins:asset-pipeline-grails', version.ref = 'asset-pipeline' } -grails-core = { module = 'org.grails:grails-core', version.ref = 'grails' } -grails-bootstrap = { module = 'org.grails:grails-bootstrap', version.ref = 'grails' } -grails-converters = { module = 'org.grails.plugins:converters', version.ref = 'grails-converters' } -grails-datastore-core = { module = 'org.grails:grails-datastore-core', version.ref = 'grails-datamapping' } -grails-datastore-gorm = { module = 'org.grails:grails-datastore-gorm', version.ref = 'grails-datamapping' } -grails-domain = { module = 'org.grails:grails-plugin-domain-class', version.ref = 'grails' } +grails-bom = { module = 'org.grails:grails-bom', version.ref = 'grails' } +grails-core = { module = 'org.grails:grails-core' } +grails-bootstrap = { module = 'org.grails:grails-bootstrap' } +grails-converters = { module = 'org.grails.plugins:converters' } +grails-datastore-core = { module = 'org.grails:grails-datastore-core'} +grails-datastore-gorm = { module = 'org.grails:grails-datastore-gorm'} +grails-domain = { module = 'org.grails:grails-plugin-domain-class' } grails-events-transform = { module = 'org.grails:grails-events-transform', version.ref = 'grails-async-and-events' } -grails-gsp = { module = 'org.grails.plugins:gsp', version.ref = 'grails-gsp' } -grails-i18n = { module = 'org.grails:grails-plugin-i18n', version.ref = 'grails' } -grails-interceptors = { module = 'org.grails:grails-plugin-interceptors', version.ref = 'grails' } -grails-mimetypes = { module = 'org.grails:grails-plugin-mimetypes', version.ref = 'grails' } +grails-gsp = { module = 'org.grails.plugins:gsp' } +grails-i18n = { module = 'org.grails:grails-plugin-i18n' } +grails-interceptors = { module = 'org.grails:grails-plugin-interceptors' } +grails-mimetypes = { module = 'org.grails:grails-plugin-mimetypes' } grails-plugin-async = { module = 'org.grails.plugins:async', version.ref = 'grails-async-and-events' } -grails-rest = { module = 'org.grails:grails-plugin-rest', version.ref = 'grails' } -grails-services = { module = 'org.grails:grails-plugin-services', version.ref = 'grails' } -grails-testing-support-gorm = { module = 'org.grails:grails-gorm-testing-support', version.ref = 'grails-testing-support' } -grails-testing-support-web = { module = 'org.grails:grails-web-testing-support', version.ref = 'grails-testing-support' } -grails-urlmappings = { module = 'org.grails:grails-plugin-url-mappings', version.ref = 'grails' } -grails-validation = { module = 'org.grails:grails-plugin-validation', version.ref = 'grails' } -grails-web-common = { module = 'org.grails:grails-web-common', version.ref = 'grails' } -grails-web-urlmappings = { module = 'org.grails:grails-web-url-mappings', version.ref = 'grails' } -groovy-core = { module = 'org.apache.groovy:groovy', version.ref = 'groovy' } -jakarta-annotation-api = { module = 'jakarta.annotation:jakarta.annotation-api', version.ref = 'jakarta-annotation-api' } -jakarta-servlet-api = { module = 'jakarta.servlet:jakarta.servlet-api', version.ref = 'jakarta-servlet-api' } -h2database = { module = 'com.h2database:h2', version.ref = 'h2database' } +grails-rest = { module = 'org.grails:grails-plugin-rest' } +grails-services = { module = 'org.grails:grails-plugin-services' } +grails-testing-support-gorm = { module = 'org.grails:grails-gorm-testing-support' } +grails-testing-support-web = { module = 'org.grails:grails-web-testing-support' } +grails-urlmappings = { module = 'org.grails:grails-plugin-url-mappings' } +grails-validation = { module = 'org.grails:grails-plugin-validation' } +grails-web-common = { module = 'org.grails:grails-web-common' } +grails-web-urlmappings = { module = 'org.grails:grails-web-url-mappings' } +groovy-core = { module = 'org.apache.groovy:groovy' } +jakarta-annotation-api = { module = 'jakarta.annotation:jakarta.annotation-api' } +jakarta-servlet-api = { module = 'jakarta.servlet:jakarta.servlet-api' } +h2database = { module = 'com.h2database:h2' } micronaut-httpclient = { module = 'io.micronaut:micronaut-http-client', version.ref = 'micronaut' } micronaut-inject-groovy = { module = 'io.micronaut:micronaut-inject-groovy', version.ref = 'micronaut' } micronaut-jackson-databind = { module = 'io.micronaut:micronaut-jackson-databind', version.ref = 'micronaut' } @@ -68,26 +55,26 @@ selenium-json = { module = 'org.seleniumhq.selenium:selenium-json', version.ref selenium-remote-driver = { module = 'org.seleniumhq.selenium:selenium-remote-driver', version.ref = 'selenium' } selenium-safari-driver = { module = 'org.seleniumhq.selenium:selenium-safari-driver', version.ref = 'selenium-safari' } selenium-support = { module = 'org.seleniumhq.selenium:selenium-support', version.ref = 'selenium' } -slf4j-nop = { module = 'org.slf4j:slf4j-nop', version.ref = 'slf4j' } -spock-core = { module = 'org.spockframework:spock-core', version.ref = 'spock' } -spring-beans = { module = 'org.springframework:spring-beans', version.ref = 'spring' } -spring-core = { module = 'org.springframework:spring-core', version.ref = 'spring' } -spring-context-core = { module = 'org.springframework:spring-context', version.ref = 'spring' } -spring-context-support = { module = 'org.springframework:spring-context-support', version.ref = 'spring' } -spring-expression = { module = 'org.springframework:spring-expression', version.ref = 'spring' } -spring-security-core = { module = 'org.springframework.security:spring-security-core', version.ref = 'spring-security' } -spring-security-config = { module = 'org.springframework.security:spring-security-config', version.ref = 'spring-security' } -spring-security-crypto = { module = 'org.springframework.security:spring-security-crypto', version.ref = 'spring-security' } -spring-security-web = { module = 'org.springframework.security:spring-security-web', version.ref = 'spring-security' } -spring-test = { module = 'org.springframework:spring-test', version.ref = 'spring' } -spring-tx = { module = 'org.springframework:spring-tx', version.ref = 'spring' } -spring-web = { module = 'org.springframework:spring-web', version.ref = 'spring' } -springboot-autoconfigure = { module = 'org.springframework.boot:spring-boot-autoconfigure', version.ref = 'springboot' } -springboot-core = { module = 'org.springframework.boot:spring-boot', version.ref = 'springboot' } -springboot-starter-logging = { module = 'org.springframework.boot:spring-boot-starter-logging', version.ref = 'springboot' } -springboot-starter-test = { module = 'org.springframework.boot:spring-boot-starter-test', version.ref = 'springboot' } -springboot-starter-tomcat = { module = 'org.springframework.boot:spring-boot-starter-tomcat', version.ref = 'springboot' } -tomcat-jdbc = { module = 'org.apache.tomcat:tomcat-jdbc', version.ref = 'tomcat' } +slf4j-nop = { module = 'org.slf4j:slf4j-nop' } +spock-core = { module = 'org.spockframework:spock-core' } +spring-beans = { module = 'org.springframework:spring-beans' } +spring-core = { module = 'org.springframework:spring-core' } +spring-context-core = { module = 'org.springframework:spring-context' } +spring-context-support = { module = 'org.springframework:spring-context-support' } +spring-expression = { module = 'org.springframework:spring-expression' } +spring-security-core = { module = 'org.springframework.security:spring-security-core' } +spring-security-config = { module = 'org.springframework.security:spring-security-config' } +spring-security-crypto = { module = 'org.springframework.security:spring-security-crypto' } +spring-security-web = { module = 'org.springframework.security:spring-security-web' } +spring-test = { module = 'org.springframework:spring-test' } +spring-tx = { module = 'org.springframework:spring-tx' } +spring-web = { module = 'org.springframework:spring-web' } +springboot-autoconfigure = { module = 'org.springframework.boot:spring-boot-autoconfigure' } +springboot-core = { module = 'org.springframework.boot:spring-boot' } +springboot-starter-logging = { module = 'org.springframework.boot:spring-boot-starter-logging' } +springboot-starter-test = { module = 'org.springframework.boot:spring-boot-starter-test' } +springboot-starter-tomcat = { module = 'org.springframework.boot:spring-boot-starter-tomcat' } +tomcat-jdbc = { module = 'org.apache.tomcat:tomcat-jdbc' } [bundles] geb = ['geb-core', 'geb-spock'] From 704bf817dae5b24222d125d4c26fcaf9a9a33dfc Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Fri, 22 Nov 2024 15:54:33 -0800 Subject: [PATCH 02/25] cleanup --- gradle/libs.versions.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 29f3159a..2ee401b0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,9 +3,7 @@ asset-pipeline = '5.0.1' ehcache = '3.10.8' grails = '7.0.0-SNAPSHOT' grails-async-and-events = '7.0.0-SNAPSHOT' -grails-testing-support = '4.0.0-SNAPSHOT' groovy = '4.0.22' -h2database = '2.3.232' micronaut = '4.5.3' selenium = '4.19.1' selenium-safari = '4.19.1' From ce3e10b51873ed5bdcf860d2d3b24378f44ab63c Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Fri, 22 Nov 2024 16:09:50 -0800 Subject: [PATCH 03/25] Update SecurityFilterPosition.java to match Spring Security 6.1 --- .../plugin/springsecurity/SecurityFilterPosition.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/groovy/grails/plugin/springsecurity/SecurityFilterPosition.java b/plugin/src/main/groovy/grails/plugin/springsecurity/SecurityFilterPosition.java index 9676edd6..8f5861b5 100644 --- a/plugin/src/main/groovy/grails/plugin/springsecurity/SecurityFilterPosition.java +++ b/plugin/src/main/groovy/grails/plugin/springsecurity/SecurityFilterPosition.java @@ -1,4 +1,4 @@ -/* Copyright 2006-2016 the original author or authors. +/* Copyright 2006-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,9 +20,8 @@ * Equivalent to org.springframework.security.config.http.SecurityFilters which * unfortunately is package-default. * - * @author Burt Beckwith */ -enum SecurityFilterPosition { +enum SecurityFilterPosition { FIRST(Integer.MIN_VALUE), @@ -68,6 +67,8 @@ enum SecurityFilterPosition { FORM_LOGIN_FILTER, + DEFAULT_RESOURCES_FILTER, + LOGIN_PAGE_FILTER, LOGOUT_PAGE_FILTER, From d586c818056c03672c06e98acaa067a3fe664272 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 10:55:09 -0500 Subject: [PATCH 04/25] Always run the tests --- .github/workflows/gradle.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a65d26f8..3ed7dc6b 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -15,7 +15,6 @@ env: jobs: core-tests: - if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -33,7 +32,6 @@ jobs: -Dgeb.env=chromeHeadless functional-test: - if: github.event_name == 'pull_request' runs-on: ubuntu-latest strategy: matrix: From bf3f0e32e77461c3e9c2a2ea97370ef46146e56c Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 11:36:38 -0500 Subject: [PATCH 05/25] Use `compileJava.options.release` to set the java version --- gradle/java-config.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle/java-config.gradle b/gradle/java-config.gradle index 3132d564..08e4f289 100644 --- a/gradle/java-config.gradle +++ b/gradle/java-config.gradle @@ -1,5 +1,6 @@ +compileJava.options.release = 17 + java { - sourceCompatibility = JavaVersion.VERSION_17 withJavadocJar() withSourcesJar() } \ No newline at end of file From 2fde71fd25afa63debc3769438bd0668e3cd49ab Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 11:37:04 -0500 Subject: [PATCH 06/25] Use asset plugin version 5.0.4 --- gradle/buildsrc.libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/buildsrc.libs.versions.toml b/gradle/buildsrc.libs.versions.toml index 71c3ce95..b6bdf538 100644 --- a/gradle/buildsrc.libs.versions.toml +++ b/gradle/buildsrc.libs.versions.toml @@ -1,6 +1,6 @@ [versions] asciidoctorj = '4.0.3' -asset-pipeline-gradle = '5.0.1' +asset-pipeline-gradle = '5.0.4' grails-gradle-plugin = '7.0.0-SNAPSHOT' webdriver-binaries = '3.2' spock = '2.3-groovy-3.0' From d4bb98b050bab542ba0c511a2d86c6ed4062ae5e Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 11:37:27 -0500 Subject: [PATCH 07/25] Switch to `ContainerGebSpec` --- buildSrc/build.gradle | 2 -- .../groovy/demo/SecuredControllerSpec.groovy | 4 ++-- .../groovy/demo/SecuredControllerSpec.groovy | 4 ++-- gradle/buildsrc.libs.versions.toml | 2 -- gradle/integrationTest.gradle | 8 +++---- gradle/libs.versions.toml | 21 +++---------------- 6 files changed, 10 insertions(+), 31 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 034a10fa..e288ecc2 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -12,8 +12,6 @@ dependencies { // which is causes a version conflict for Gradle exclude group: 'org.apache.groovy', module: 'groovy-xml' } - implementation buildsrcLibs.webdriver.binaries.gradle.plugin - testImplementation buildsrcLibs.spock.core } diff --git a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy index 79f38a18..165f8e9d 100644 --- a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy +++ b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy @@ -1,12 +1,12 @@ package demo -import geb.spock.GebSpec +import grails.plugin.geb.ContainerGebSpec import grails.testing.mixin.integration.Integration import grails.gorm.transactions.Rollback @Rollback @Integration(applicationClass = Application) -class SecuredControllerSpec extends GebSpec { +class SecuredControllerSpec extends ContainerGebSpec { def setup() { browser.baseUrl = "http://localhost:${serverPort}/" diff --git a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy index 1098d3a0..9ffb2494 100644 --- a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy +++ b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy @@ -1,10 +1,10 @@ package demo -import geb.spock.GebSpec +import grails.plugin.geb.ContainerGebSpec import grails.testing.mixin.integration.Integration @Integration(applicationClass = Application) -class SecuredControllerSpec extends GebSpec { +class SecuredControllerSpec extends ContainerGebSpec { def setup() { browser.baseUrl = "http://localhost:${serverPort}/" diff --git a/gradle/buildsrc.libs.versions.toml b/gradle/buildsrc.libs.versions.toml index b6bdf538..c218be70 100644 --- a/gradle/buildsrc.libs.versions.toml +++ b/gradle/buildsrc.libs.versions.toml @@ -2,12 +2,10 @@ asciidoctorj = '4.0.3' asset-pipeline-gradle = '5.0.4' grails-gradle-plugin = '7.0.0-SNAPSHOT' -webdriver-binaries = '3.2' spock = '2.3-groovy-3.0' [libraries] asciidoctorj = { module = 'org.asciidoctor:asciidoctor-gradle-jvm', version.ref = 'asciidoctorj' } asset-pipeline-gradle = { module = 'com.bertramlabs.plugins:asset-pipeline-gradle', version.ref = 'asset-pipeline-gradle' } grails-gradle-plugin = { module = 'org.grails:grails-gradle-plugin', version.ref = 'grails-gradle-plugin' } -webdriver-binaries-gradle-plugin = { module = 'com.github.erdi:webdriver-binaries-gradle-plugin', version.ref = 'webdriver-binaries' } spock-core = { module = 'org.spockframework:spock-core', version.ref = 'spock' } \ No newline at end of file diff --git a/gradle/integrationTest.gradle b/gradle/integrationTest.gradle index aba7fc52..6743afaf 100644 --- a/gradle/integrationTest.gradle +++ b/gradle/integrationTest.gradle @@ -1,18 +1,16 @@ -apply plugin: 'com.github.erdi.webdriver-binaries' - dependencies { add('testImplementation', libs.micronaut.httpclient) add('testImplementation', libs.micronaut.inject.groovy) add('testImplementation', libs.bundles.grails.testing.support) - add('integrationTestImplementation', libs.bundles.geb) - add('integrationTestRuntimeOnly', libs.bundles.selenium) + + integrationTestImplementation testFixtures(libs.geb.plugin) } tasks.named('integrationTest', Test) { systemProperty 'geb.build.reportsDir', reporting.file("$project.projectDir/build/geb-reports") systemProperties System.properties doFirst { - logger.quiet "\n - Running tests for configuration: ${System.getProperty('TESTCONFIG') ?: 'N/S'} with GEB env: ${System.getProperty('geb.env') ?: 'N/S'} and Grails: $grailsVersion" + logger.quiet "\n - Running tests for configuration: ${System.getProperty('TESTCONFIG') ?: 'N/S'} and Grails: $grailsVersion" } beforeTest { descriptor -> logger.quiet " -- $descriptor" } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 11ac2d2c..0f74692e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,19 +1,15 @@ [versions] -asset-pipeline = '5.0.1' +asset-pipeline = '5.0.4' ehcache = '3.10.8' grails = '7.0.0-SNAPSHOT' grails-async-and-events = '7.0.0-SNAPSHOT' -groovy = '4.0.22' +groovy = '4.0.24' micronaut = '4.5.3' -selenium = '4.19.1' -selenium-safari = '4.19.1' [libraries] commons-text = { module = 'org.apache.commons:commons-text' } ehcache = { module = 'org.ehcache:ehcache', version.ref = 'ehcache' } bytebuddy = { module = 'net.bytebuddy:byte-buddy' } -geb-core = { module = 'org.gebish:geb-core' } -geb-spock = { module = 'org.gebish:geb-spock' } gorm-hibernate5 = { module = 'org.grails.plugins:hibernate5' } grails-asset-pipeline = { module = 'com.bertramlabs.plugins:asset-pipeline-grails', version.ref = 'asset-pipeline' } grails-bom = { module = 'org.grails:grails-bom', version.ref = 'grails' } @@ -44,18 +40,9 @@ h2database = { module = 'com.h2database:h2' } micronaut-httpclient = { module = 'io.micronaut:micronaut-http-client', version.ref = 'micronaut' } micronaut-inject-groovy = { module = 'io.micronaut:micronaut-inject-groovy', version.ref = 'micronaut' } micronaut-jackson-databind = { module = 'io.micronaut:micronaut-jackson-databind', version.ref = 'micronaut' } -selenium-api = { module = 'org.seleniumhq.selenium:selenium-api', version.ref = 'selenium' } -selenium-chrome-driver = { module = 'org.seleniumhq.selenium:selenium-chrome-driver', version.ref = 'selenium' } -selenium-chromium-driver = { module = 'org.seleniumhq.selenium:selenium-chromium-driver', version.ref = 'selenium' } -selenium-devtools-v85 = { module = 'org.seleniumhq.selenium:selenium-devtools-v85', version.ref = 'selenium' } -selenium-firefox-driver = { module = 'org.seleniumhq.selenium:selenium-firefox-driver', version.ref = 'selenium' } -selenium-http = { module = 'org.seleniumhq.selenium:selenium-http', version.ref = 'selenium' } -selenium-json = { module = 'org.seleniumhq.selenium:selenium-json', version.ref = 'selenium' } -selenium-remote-driver = { module = 'org.seleniumhq.selenium:selenium-remote-driver', version.ref = 'selenium' } -selenium-safari-driver = { module = 'org.seleniumhq.selenium:selenium-safari-driver', version.ref = 'selenium-safari' } -selenium-support = { module = 'org.seleniumhq.selenium:selenium-support', version.ref = 'selenium' } slf4j-nop = { module = 'org.slf4j:slf4j-nop' } spock-core = { module = 'org.spockframework:spock-core' } +geb-plugin = { module = 'org.grails.plugins:geb' } spring-beans = { module = 'org.springframework:spring-beans' } spring-core = { module = 'org.springframework:spring-core' } spring-context-core = { module = 'org.springframework:spring-context' } @@ -76,6 +63,4 @@ springboot-starter-tomcat = { module = 'org.springframework.boot:spring-boot-sta tomcat-jdbc = { module = 'org.apache.tomcat:tomcat-jdbc' } [bundles] -geb = ['geb-core', 'geb-spock'] grails-testing-support = ['grails-testing-support-gorm', 'grails-testing-support-web', 'springboot-starter-test'] -selenium = ['selenium-api', 'selenium-chrome-driver', 'selenium-chromium-driver', 'selenium-devtools-v85', 'selenium-firefox-driver', 'selenium-http', 'selenium-json', 'selenium-remote-driver', 'selenium-safari-driver', 'selenium-support'] From a1da663ae44185faf613d3ee2fe8b01672699cd9 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 11:42:16 -0500 Subject: [PATCH 08/25] Remove GebConfig.groovy files --- .../resources/GebConfig.groovy | 74 ------------------- .../resources/GebConfig.groovy | 74 ------------------- .../resources/GebConfig.groovy | 74 ------------------- 3 files changed, 222 deletions(-) delete mode 100644 examples/functional-test-app/src/integration-test/resources/GebConfig.groovy delete mode 100644 examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/resources/GebConfig.groovy delete mode 100644 examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/resources/GebConfig.groovy diff --git a/examples/functional-test-app/src/integration-test/resources/GebConfig.groovy b/examples/functional-test-app/src/integration-test/resources/GebConfig.groovy deleted file mode 100644 index 9e41451a..00000000 --- a/examples/functional-test-app/src/integration-test/resources/GebConfig.groovy +++ /dev/null @@ -1,74 +0,0 @@ -import org.openqa.selenium.chrome.ChromeDriver -import org.openqa.selenium.chrome.ChromeOptions -import org.openqa.selenium.firefox.FirefoxDriver -import org.openqa.selenium.firefox.FirefoxOptions -import org.openqa.selenium.firefox.GeckoDriverService - -private static FirefoxDriver createFirefoxDriver(FirefoxOptions options = new FirefoxOptions()) { - def osName = System.getProperty('os.name').toLowerCase() - def profileRoot = osName.contains('linux') && new File('/snap/firefox').exists() ? createProfileRootInUserHome() : null - profileRoot ? new FirefoxDriver(createGeckoDriverService(profileRoot), options) : new FirefoxDriver(options) -} - -private static String createProfileRootInUserHome() { - def profileRoot = [System.getProperty('user.home'), 'snap/firefox/common/.firefox-profile-root'] as File - if ( ! profileRoot.exists()) { - if ( ! profileRoot.mkdirs()) { - return null - } - } - profileRoot.absolutePath -} - -private static GeckoDriverService createGeckoDriverService(String tmpProfileDir) { - new GeckoDriverService.Builder() { - @Override - protected List createArgs() { - def args = new ArrayList(super.createArgs()) - def idx = args.indexOf('--profile-root') - if (idx > -1) { - args.remove(idx + 1) - args.remove(idx) - } - args.add '--profile-root' - args.add tmpProfileDir - args - } - }.build() -} - -environments { - - // run via “./gradlew -Dgeb.env=chrome iT” - chrome { - driver = { new ChromeDriver() } - } - - // run via “./gradlew -Dgeb.env=chromeHeadless iT” - chromeHeadless { - driver = { - ChromeOptions o = new ChromeOptions() - o.addArguments '--headless=new' - o.addArguments '--remote-allow-origins=*' - new ChromeDriver(o) - } - } - - // run via “./gradlew -Dgeb.env=firefox iT” - firefox { - driver = { createFirefoxDriver() } - } - - firefoxHeadless { - driver = { - FirefoxOptions o = new FirefoxOptions() - o.addArguments '-headless' - createFirefoxDriver o - } - } -} - -waiting { - timeout = 10 - retryInterval = 0.5 -} \ No newline at end of file diff --git a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/resources/GebConfig.groovy b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/resources/GebConfig.groovy deleted file mode 100644 index 9e41451a..00000000 --- a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/resources/GebConfig.groovy +++ /dev/null @@ -1,74 +0,0 @@ -import org.openqa.selenium.chrome.ChromeDriver -import org.openqa.selenium.chrome.ChromeOptions -import org.openqa.selenium.firefox.FirefoxDriver -import org.openqa.selenium.firefox.FirefoxOptions -import org.openqa.selenium.firefox.GeckoDriverService - -private static FirefoxDriver createFirefoxDriver(FirefoxOptions options = new FirefoxOptions()) { - def osName = System.getProperty('os.name').toLowerCase() - def profileRoot = osName.contains('linux') && new File('/snap/firefox').exists() ? createProfileRootInUserHome() : null - profileRoot ? new FirefoxDriver(createGeckoDriverService(profileRoot), options) : new FirefoxDriver(options) -} - -private static String createProfileRootInUserHome() { - def profileRoot = [System.getProperty('user.home'), 'snap/firefox/common/.firefox-profile-root'] as File - if ( ! profileRoot.exists()) { - if ( ! profileRoot.mkdirs()) { - return null - } - } - profileRoot.absolutePath -} - -private static GeckoDriverService createGeckoDriverService(String tmpProfileDir) { - new GeckoDriverService.Builder() { - @Override - protected List createArgs() { - def args = new ArrayList(super.createArgs()) - def idx = args.indexOf('--profile-root') - if (idx > -1) { - args.remove(idx + 1) - args.remove(idx) - } - args.add '--profile-root' - args.add tmpProfileDir - args - } - }.build() -} - -environments { - - // run via “./gradlew -Dgeb.env=chrome iT” - chrome { - driver = { new ChromeDriver() } - } - - // run via “./gradlew -Dgeb.env=chromeHeadless iT” - chromeHeadless { - driver = { - ChromeOptions o = new ChromeOptions() - o.addArguments '--headless=new' - o.addArguments '--remote-allow-origins=*' - new ChromeDriver(o) - } - } - - // run via “./gradlew -Dgeb.env=firefox iT” - firefox { - driver = { createFirefoxDriver() } - } - - firefoxHeadless { - driver = { - FirefoxOptions o = new FirefoxOptions() - o.addArguments '-headless' - createFirefoxDriver o - } - } -} - -waiting { - timeout = 10 - retryInterval = 0.5 -} \ No newline at end of file diff --git a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/resources/GebConfig.groovy b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/resources/GebConfig.groovy deleted file mode 100644 index 9e41451a..00000000 --- a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/resources/GebConfig.groovy +++ /dev/null @@ -1,74 +0,0 @@ -import org.openqa.selenium.chrome.ChromeDriver -import org.openqa.selenium.chrome.ChromeOptions -import org.openqa.selenium.firefox.FirefoxDriver -import org.openqa.selenium.firefox.FirefoxOptions -import org.openqa.selenium.firefox.GeckoDriverService - -private static FirefoxDriver createFirefoxDriver(FirefoxOptions options = new FirefoxOptions()) { - def osName = System.getProperty('os.name').toLowerCase() - def profileRoot = osName.contains('linux') && new File('/snap/firefox').exists() ? createProfileRootInUserHome() : null - profileRoot ? new FirefoxDriver(createGeckoDriverService(profileRoot), options) : new FirefoxDriver(options) -} - -private static String createProfileRootInUserHome() { - def profileRoot = [System.getProperty('user.home'), 'snap/firefox/common/.firefox-profile-root'] as File - if ( ! profileRoot.exists()) { - if ( ! profileRoot.mkdirs()) { - return null - } - } - profileRoot.absolutePath -} - -private static GeckoDriverService createGeckoDriverService(String tmpProfileDir) { - new GeckoDriverService.Builder() { - @Override - protected List createArgs() { - def args = new ArrayList(super.createArgs()) - def idx = args.indexOf('--profile-root') - if (idx > -1) { - args.remove(idx + 1) - args.remove(idx) - } - args.add '--profile-root' - args.add tmpProfileDir - args - } - }.build() -} - -environments { - - // run via “./gradlew -Dgeb.env=chrome iT” - chrome { - driver = { new ChromeDriver() } - } - - // run via “./gradlew -Dgeb.env=chromeHeadless iT” - chromeHeadless { - driver = { - ChromeOptions o = new ChromeOptions() - o.addArguments '--headless=new' - o.addArguments '--remote-allow-origins=*' - new ChromeDriver(o) - } - } - - // run via “./gradlew -Dgeb.env=firefox iT” - firefox { - driver = { createFirefoxDriver() } - } - - firefoxHeadless { - driver = { - FirefoxOptions o = new FirefoxOptions() - o.addArguments '-headless' - createFirefoxDriver o - } - } -} - -waiting { - timeout = 10 - retryInterval = 0.5 -} \ No newline at end of file From 891308ef1512fd95e9755f42ca11c9ea3e6eeb96 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 12:02:44 -0500 Subject: [PATCH 09/25] Remove ReportingGebSpec --- .../specs/AbstractHyphenatedSecuritySpec.groovy | 3 +++ .../groovy/specs/AbstractSecuritySpec.groovy | 15 ++++----------- .../groovy/specs/AnnotationSecuritySpec.groovy | 2 ++ .../groovy/specs/BCryptSpec.groovy | 2 ++ .../specs/BasicAuthCacheUsersSecuritySpec.groovy | 2 ++ .../groovy/specs/BasicAuthSecuritySpec.groovy | 2 ++ .../groovy/specs/DisableSpec.groovy | 3 +++ .../groovy/specs/InheritanceSecuritySpec.groovy | 2 ++ .../integration-test/groovy/specs/MiscSpec.groovy | 2 ++ .../groovy/specs/NamespaceSecuritySpec.groovy | 2 ++ .../groovy/specs/RequestmapSecuritySpec.groovy | 2 ++ .../groovy/specs/RequestmapSpec.groovy | 2 ++ .../integration-test/groovy/specs/RoleSpec.groovy | 2 ++ .../groovy/specs/StaticSecuritySpec.groovy | 2 ++ .../integration-test/groovy/specs/UserSpec.groovy | 2 ++ 15 files changed, 34 insertions(+), 11 deletions(-) diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/AbstractHyphenatedSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/AbstractHyphenatedSecuritySpec.groovy index 1e82cad5..a8f1891b 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/AbstractHyphenatedSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/AbstractHyphenatedSecuritySpec.groovy @@ -1,5 +1,8 @@ package specs +import grails.testing.mixin.integration.Integration + +@Integration abstract class AbstractHyphenatedSecuritySpec extends AbstractSecuritySpec { protected void resetDatabase() { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/AbstractSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/AbstractSecuritySpec.groovy index 206fda77..e33099c8 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/AbstractSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/AbstractSecuritySpec.groovy @@ -1,8 +1,9 @@ package specs import com.testapp.TestDataService +import functional.test.app.Application import geb.driver.CachingDriverFactory -import geb.spock.GebReportingSpec +import grails.plugin.geb.ContainerGebSpec import grails.plugin.springsecurity.SpringSecurityCoreGrailsPlugin import grails.plugin.springsecurity.SpringSecurityUtils import grails.testing.mixin.integration.Integration @@ -10,11 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.security.crypto.password.MessageDigestPasswordEncoder import pages.LoginPage import spock.lang.Shared -import spock.lang.Stepwise -@Integration(applicationClass = functional.test.app.Application) -@Stepwise -abstract class AbstractSecuritySpec extends GebReportingSpec { +@Integration(applicationClass = Application) +abstract class AbstractSecuritySpec extends ContainerGebSpec { private @Shared boolean databaseReset = false @@ -22,12 +21,6 @@ abstract class AbstractSecuritySpec extends GebReportingSpec { TestDataService testDataService void setup() { - if ( hasProperty('serverPort') ) { - browser.baseUrl = "http://localhost:${getProperty('serverPort')}/" - } else { - browser.baseUrl = 'http://localhost:8080/' - } - logout() // call resetDatabase() once per suite, before the first test; would diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/AnnotationSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/AnnotationSecuritySpec.groovy index 12137d56..8caec1a6 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/AnnotationSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/AnnotationSecuritySpec.groovy @@ -1,5 +1,6 @@ package specs +import grails.testing.mixin.integration.Integration import pages.IndexPage import pages.LoginPage import pages.role.CreateRolePage @@ -10,6 +11,7 @@ import pages.user.ListUserPage import pages.user.ShowUserPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'annotation' }) class AnnotationSecuritySpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/BCryptSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/BCryptSpec.groovy index 308bf22b..adc5a7d8 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/BCryptSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/BCryptSpec.groovy @@ -1,10 +1,12 @@ package specs +import grails.testing.mixin.integration.Integration import pages.user.CreateUserPage import pages.user.ListUserPage import pages.user.ShowUserPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'bcrypt' }) class BCryptSpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy index 2be33d91..2e4d4e2d 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy @@ -1,5 +1,6 @@ package specs +import grails.testing.mixin.integration.Integration import org.springframework.security.core.userdetails.UserCache import pages.LoginPage import pages.role.CreateRolePage @@ -10,6 +11,7 @@ import pages.user.ListUserPage import pages.user.ShowUserPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'basicCacheUsers' }) class BasicAuthCacheUsersSecuritySpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy index da3ca4fd..f5627d8b 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy @@ -1,5 +1,6 @@ package specs +import grails.testing.mixin.integration.Integration import pages.LoginPage import pages.role.CreateRolePage import pages.role.ListRolePage @@ -9,6 +10,7 @@ import pages.user.ListUserPage import pages.user.ShowUserPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'basic' }) class BasicAuthSecuritySpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/DisableSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/DisableSpec.groovy index b7680135..dd58768d 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/DisableSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/DisableSpec.groovy @@ -1,8 +1,11 @@ package specs +import grails.testing.mixin.integration.Integration import pages.IndexPage import spock.lang.IgnoreIf + +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'misc' }) class DisableSpec extends AbstractHyphenatedSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/InheritanceSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/InheritanceSecuritySpec.groovy index fc8b08ee..6f288994 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/InheritanceSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/InheritanceSecuritySpec.groovy @@ -1,9 +1,11 @@ package specs +import grails.testing.mixin.integration.Integration import pages.IndexPage import pages.LoginPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'annotation' }) class InheritanceSecuritySpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/MiscSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/MiscSpec.groovy index 33934406..1a41bae9 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/MiscSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/MiscSpec.groovy @@ -1,11 +1,13 @@ package specs import geb.module.TextInput +import grails.testing.mixin.integration.Integration import org.springframework.security.crypto.password.PasswordEncoder import pages.IndexPage import spock.lang.IgnoreIf import spock.lang.Issue +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'misc' }) class MiscSpec extends AbstractHyphenatedSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/NamespaceSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/NamespaceSecuritySpec.groovy index 868991e5..123181b2 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/NamespaceSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/NamespaceSecuritySpec.groovy @@ -1,11 +1,13 @@ package specs +import grails.testing.mixin.integration.Integration import groovy.json.JsonSlurper import pages.IndexPage import pages.LoginPage import spock.lang.IgnoreIf import spock.lang.Unroll +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'annotation' }) class NamespaceSecuritySpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSecuritySpec.groovy index c7d1217f..fbe23f4e 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSecuritySpec.groovy @@ -1,6 +1,7 @@ package specs import com.testapp.TestDataService +import grails.testing.mixin.integration.Integration import pages.IndexPage import pages.LoginPage import pages.requestmap.CreateRequestmapPage @@ -14,6 +15,7 @@ import pages.user.ListUserPage import pages.user.ShowUserPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'requestmap' }) class RequestmapSecuritySpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSpec.groovy index bf8c5550..099c3fb0 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSpec.groovy @@ -1,12 +1,14 @@ package specs import com.testapp.TestDataService +import grails.testing.mixin.integration.Integration import pages.requestmap.CreateRequestmapPage import pages.requestmap.EditRequestmapPage import pages.requestmap.ListRequestmapPage import pages.requestmap.ShowRequestmapPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'requestmap' }) class RequestmapSpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/RoleSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/RoleSpec.groovy index 950c1385..569ba783 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/RoleSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/RoleSpec.groovy @@ -1,11 +1,13 @@ package specs +import grails.testing.mixin.integration.Integration import pages.role.CreateRolePage import pages.role.EditRolePage import pages.role.ListRolePage import pages.role.ShowRolePage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ !( System.getProperty('TESTCONFIG') == 'annotation' || System.getProperty('TESTCONFIG') == 'basic' || diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/StaticSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/StaticSecuritySpec.groovy index 592ab7c9..39a9dcdd 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/StaticSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/StaticSecuritySpec.groovy @@ -1,5 +1,6 @@ package specs +import grails.testing.mixin.integration.Integration import pages.IndexPage import pages.role.CreateRolePage import pages.role.ListRolePage @@ -9,6 +10,7 @@ import pages.user.ListUserPage import pages.user.ShowUserPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ System.getProperty('TESTCONFIG') != 'static' }) class StaticSecuritySpec extends AbstractSecuritySpec { diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/UserSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/UserSpec.groovy index 77729618..4efebf67 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/UserSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/UserSpec.groovy @@ -1,11 +1,13 @@ package specs +import grails.testing.mixin.integration.Integration import pages.user.CreateUserPage import pages.user.EditUserPage import pages.user.ListUserPage import pages.user.ShowUserPage import spock.lang.IgnoreIf +@Integration @IgnoreIf({ !( System.getProperty('TESTCONFIG') == 'annotation' || System.getProperty('TESTCONFIG') == 'basic' || From dc24f9461211ef0ffda0e8f3d79dbb8191e5cbab Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 12:19:06 -0500 Subject: [PATCH 10/25] add `--continue` so test runs don't immediately fail. --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 3ed7dc6b..aa08d6e7 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -29,7 +29,7 @@ jobs: arguments: | check --refresh-dependencies - -Dgeb.env=chromeHeadless + --continue functional-test: runs-on: ubuntu-latest From ea3efe30d9e6b1ee9ec9afcfde4a0e8790a35a47 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 12:19:57 -0500 Subject: [PATCH 11/25] Do not fail-fast if one of the gradle checks fails --- .github/workflows/gradle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index aa08d6e7..9037b2b7 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -34,6 +34,7 @@ jobs: functional-test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: test-config: [ 'static', 'annotation', 'requestmap', 'basic', 'basicCacheUsers', 'misc', 'putWithParams', 'bcrypt', 'issue503' ] steps: From b6de3cb0fc14253bae1e6f5fbd00ae56d755cc0f Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 14:37:28 -0500 Subject: [PATCH 12/25] Fix layout name --- .../grails-app/views/layouts/{application.gsp => main.gsp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/functional-test-app/grails-app/views/layouts/{application.gsp => main.gsp} (100%) diff --git a/examples/functional-test-app/grails-app/views/layouts/application.gsp b/examples/functional-test-app/grails-app/views/layouts/main.gsp similarity index 100% rename from examples/functional-test-app/grails-app/views/layouts/application.gsp rename to examples/functional-test-app/grails-app/views/layouts/main.gsp From 1d1ec55aae0de0110449e9b2c30aeb4735427be7 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 14:37:57 -0500 Subject: [PATCH 13/25] Adding missing events plugin --- gradle/libs.versions.toml | 1 + plugin/build.gradle | 1 + 2 files changed, 2 insertions(+) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0f74692e..e3888c01 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -25,6 +25,7 @@ grails-i18n = { module = 'org.grails:grails-plugin-i18n' } grails-interceptors = { module = 'org.grails:grails-plugin-interceptors' } grails-mimetypes = { module = 'org.grails:grails-plugin-mimetypes' } grails-plugin-async = { module = 'org.grails.plugins:async', version.ref = 'grails-async-and-events' } +grails-plugin-events = { module = 'org.grails.plugins:events', version.ref = 'grails-async-and-events' } grails-rest = { module = 'org.grails:grails-plugin-rest' } grails-services = { module = 'org.grails:grails-plugin-services' } grails-testing-support-gorm = { module = 'org.grails:grails-gorm-testing-support' } diff --git a/plugin/build.gradle b/plugin/build.gradle index e02e8cba..41433195 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -17,6 +17,7 @@ dependencies { api libs.grails.events.transform // API because used in templates api libs.grails.mimetypes api libs.grails.plugin.async // AsyncGrailsWebRequest is used in public API + implementation libs.grails.plugin.events // Events Plugin is required to implement EventBus api libs.grails.web.common api libs.grails.web.urlmappings api libs.spring.beans From 212dd3a0e43922dcbe0304769d540f55bea80c44 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 14:38:14 -0500 Subject: [PATCH 14/25] Test reset cleanup --- .../groovy/specs/AbstractHyphenatedSecuritySpec.groovy | 4 ---- .../groovy/specs/AbstractSecuritySpec.groovy | 5 +++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/AbstractHyphenatedSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/AbstractHyphenatedSecuritySpec.groovy index a8f1891b..4b527401 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/AbstractHyphenatedSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/AbstractHyphenatedSecuritySpec.groovy @@ -14,10 +14,6 @@ abstract class AbstractHyphenatedSecuritySpec extends AbstractSecuritySpec { getContent 'hack/get-session-value?name=' + name } - protected void login(String username) { - super.login username, 'password' - } - protected String getUserProperty(String user, String propertyName) { getContent "hack/get-user-property?user=$user&propName=$propertyName" } diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/AbstractSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/AbstractSecuritySpec.groovy index e33099c8..fe15019d 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/AbstractSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/AbstractSecuritySpec.groovy @@ -20,7 +20,7 @@ abstract class AbstractSecuritySpec extends ContainerGebSpec { @Autowired TestDataService testDataService - void setup() { + def setup() { logout() // call resetDatabase() once per suite, before the first test; would @@ -56,7 +56,7 @@ abstract class AbstractSecuritySpec extends ContainerGebSpec { browser.driver.pageSource } - protected void login(String user, String pwd, boolean remember = false) { + protected void login(String user, String pwd = 'password', boolean remember = false) { to LoginPage username = user password = pwd @@ -69,6 +69,7 @@ abstract class AbstractSecuritySpec extends ContainerGebSpec { protected void logout() { go SpringSecurityUtils.securityConfig.logout.filterProcessesUrl browser.clearCookies() + browser.go("/") } protected void assertContentContains(String expected) { From 4ae969c365a7eedf8d7f183388b3408bc0199c09 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 20:20:49 -0500 Subject: [PATCH 15/25] Change connection init to download() --- .../groovy/specs/BasicAuthSecuritySpec.groovy | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy index f5627d8b..d0ea7225 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy @@ -331,8 +331,6 @@ class BasicAuthSecuritySpec extends AbstractSecuritySpec { } private void getWithoutAuth(String uri) { - def url = new URI(getBaseUrlRequired()).resolve(new URI(uri)).toURL() - connection = url.openConnection() - connection.instanceFollowRedirects = false + connection = download("/${uri}") } } From 720d9c381513c3ceb023a42cbab3429050c7a4c4 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 20:38:02 -0500 Subject: [PATCH 16/25] remove geb.env --- .github/workflows/gradle.yml | 2 -- .../integration-test/groovy/specs/AnnotationSecuritySpec.groovy | 2 -- .../groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy | 1 - .../integration-test/groovy/specs/BasicAuthSecuritySpec.groovy | 2 -- .../src/integration-test/groovy/specs/RequestmapSpec.groovy | 1 - .../src/integration-test/groovy/specs/RoleSpec.groovy | 1 - .../src/integration-test/groovy/specs/UserSpec.groovy | 1 - 7 files changed, 10 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 9037b2b7..6b209657 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -48,7 +48,6 @@ jobs: with: arguments: | examples-functional-test-app:check - -Dgeb.env=chromeHeadless -DTESTCONFIG=${{ matrix.test-config }} build: @@ -68,7 +67,6 @@ jobs: arguments: | spring-security-core:build --refresh-dependencies - -Dgeb.env=chromeHeadless -x javadoc - name: Publish Snapshot artifacts to Artifactory (repo.grails.org) diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/AnnotationSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/AnnotationSecuritySpec.groovy index 8caec1a6..d087553e 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/AnnotationSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/AnnotationSecuritySpec.groovy @@ -356,7 +356,6 @@ class AnnotationSecuritySpec extends AbstractSecuritySpec { action << ['thing', 'thing/index', 'thing/show/1', 'thing/create', 'thing/edit', 'thing/delete'] } - @IgnoreIf({ !System.getProperty('geb.env') }) void 'authenticated user can access secured restful domain'() { given: login 'admin1', 'password1' @@ -368,7 +367,6 @@ class AnnotationSecuritySpec extends AbstractSecuritySpec { $().text() == '[]' } - @IgnoreIf({ !System.getProperty('geb.env') }) void 'generated Resource controllers can have inherited secured actions'() { when: go 'customer/index' diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy index 2e4d4e2d..7d80f0a4 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthCacheUsersSecuritySpec.groovy @@ -117,7 +117,6 @@ class BasicAuthCacheUsersSecuritySpec extends AbstractSecuritySpec { userRows.size() == 2 } - @IgnoreIf({ !System.getProperty('geb.env') }) void 'check userDetails caching'() { when: diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy index d0ea7225..be87b3aa 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/BasicAuthSecuritySpec.groovy @@ -174,7 +174,6 @@ class BasicAuthSecuritySpec extends AbstractSecuritySpec { 401 == connection.responseCode } - @IgnoreIf({ !System.getProperty('geb.env') }) void 'check allowed for admin1'() { // Check with admin1 auth, some @Secure actions are accessible @@ -246,7 +245,6 @@ class BasicAuthSecuritySpec extends AbstractSecuritySpec { assertContentContains 'Error 403 Forbidden' } - @IgnoreIf({ System.getProperty('geb.env') == "htmlUnit" }) void 'check allowed for admin2'() { // Check that with admin2 auth, some @Secure actions are accessible diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSpec.groovy index 099c3fb0..806b2173 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/RequestmapSpec.groovy @@ -77,7 +77,6 @@ class RequestmapSpec extends AbstractSecuritySpec { configAttribute == 'ROLE_ADMINX' } - @IgnoreIf({ !System.getProperty('geb.env') }) void 'delete requestmap'() { when: go 'testRequestmap/list?max=100' diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/RoleSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/RoleSpec.groovy index 569ba783..89fa0d5b 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/RoleSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/RoleSpec.groovy @@ -82,7 +82,6 @@ class RoleSpec extends AbstractSecuritySpec { at ShowRolePage } - @IgnoreIf({ !System.getProperty('geb.env') }) void 'delete role'() { when: to ListRolePage diff --git a/examples/functional-test-app/src/integration-test/groovy/specs/UserSpec.groovy b/examples/functional-test-app/src/integration-test/groovy/specs/UserSpec.groovy index 4efebf67..a9af3bb2 100644 --- a/examples/functional-test-app/src/integration-test/groovy/specs/UserSpec.groovy +++ b/examples/functional-test-app/src/integration-test/groovy/specs/UserSpec.groovy @@ -89,7 +89,6 @@ class UserSpec extends AbstractSecuritySpec { at ShowUserPage } - @IgnoreIf({ !System.getProperty('geb.env') }) void 'delete user'() { when: to ListUserPage From 5c69edc635e7e92c323f0950e6f5a935dc5926ee Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 20:53:11 -0500 Subject: [PATCH 17/25] Update url for ContainerGebSpec --- .../integration-test/groovy/demo/SecuredControllerSpec.groovy | 2 +- .../integration-test/groovy/demo/SecuredControllerSpec.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy index 165f8e9d..918e477f 100644 --- a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy +++ b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy @@ -9,7 +9,7 @@ import grails.gorm.transactions.Rollback class SecuredControllerSpec extends ContainerGebSpec { def setup() { - browser.baseUrl = "http://localhost:${serverPort}/" + browser.go('/') if ( !User.findByUsername('sherlock') ) { final boolean flush = true final boolean failOnError = true diff --git a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy index 9ffb2494..a9e4247c 100644 --- a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy +++ b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy @@ -7,7 +7,7 @@ import grails.testing.mixin.integration.Integration class SecuredControllerSpec extends ContainerGebSpec { def setup() { - browser.baseUrl = "http://localhost:${serverPort}/" + browser.go('/') } def "test RoleHierarchyEntry lifecycle"() { From 624e84bd377e615b28d2f1f1da5b106041d97935 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 21:11:01 -0500 Subject: [PATCH 18/25] Apply sitemesh filter after the FormContentFilter --- .../SpringSecurityUtilsIntegrationSpec.groovy | 11 +++++++---- .../SpringSecurityCoreGrailsPlugin.groovy | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/integration-test-app/src/integration-test/groovy/grails/plugin/springsecurity/SpringSecurityUtilsIntegrationSpec.groovy b/examples/integration-test-app/src/integration-test/groovy/grails/plugin/springsecurity/SpringSecurityUtilsIntegrationSpec.groovy index 71882107..738d96db 100644 --- a/examples/integration-test-app/src/integration-test/groovy/grails/plugin/springsecurity/SpringSecurityUtilsIntegrationSpec.groovy +++ b/examples/integration-test-app/src/integration-test/groovy/grails/plugin/springsecurity/SpringSecurityUtilsIntegrationSpec.groovy @@ -14,6 +14,7 @@ */ 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 @@ -85,7 +86,7 @@ class SpringSecurityUtilsIntegrationSpec extends AbstractIntegrationSpec { def map = SpringSecurityUtils.configuredOrderedFilters expect: - 10 == map.size() + 11 == map.size() map[Integer.MIN_VALUE + 10] instanceof SecurityRequestHolderFilter map[SecurityFilterPosition.SECURITY_CONTEXT_FILTER.order] instanceof SecurityContextPersistenceFilter map[SecurityFilterPosition.LOGOUT_FILTER.order] instanceof MutableLogoutFilter @@ -94,6 +95,7 @@ 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-5] instanceof SiteMeshFilter map[SecurityFilterPosition.EXCEPTION_TRANSLATION_FILTER.order] instanceof ExceptionTranslationFilter map[SecurityFilterPosition.FILTER_SECURITY_INTERCEPTOR.order] instanceof FilterSecurityInterceptor @@ -122,7 +124,7 @@ class SpringSecurityUtilsIntegrationSpec extends AbstractIntegrationSpec { SpringSecurityUtils.clientRegisterFilter 'dummyFilter', SecurityFilterPosition.LOGOUT_FILTER.order + 10 then: - 11 == map.size() + 12 == map.size() map[SecurityFilterPosition.LOGOUT_FILTER.order + 10] instanceof DummyFilter when: @@ -138,8 +140,9 @@ class SpringSecurityUtilsIntegrationSpec extends AbstractIntegrationSpec { filters[6] instanceof GrailsRememberMeAuthenticationFilter filters[7] instanceof GrailsAnonymousAuthenticationFilter filters[8] instanceof FormContentFilter - filters[9] instanceof ExceptionTranslationFilter - filters[10] instanceof FilterSecurityInterceptor + filters[9] instanceof SiteMeshFilter + filters[10] instanceof ExceptionTranslationFilter + filters[11] instanceof FilterSecurityInterceptor } void 'reauthenticate'() { diff --git a/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityCoreGrailsPlugin.groovy b/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityCoreGrailsPlugin.groovy index 0c1f90f7..a38e85a3 100644 --- a/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityCoreGrailsPlugin.groovy +++ b/plugin/src/main/groovy/grails/plugin/springsecurity/SpringSecurityCoreGrailsPlugin.groovy @@ -668,7 +668,7 @@ to default to 'Annotation'; setting value to 'Annotation' // if sitemesh 3 is installed, the filter should be applied a second time // as part of the security filter chain so that pages are decorated using the security context if (applicationContext.containsBean('sitemesh')) { - filterNames[SecurityFilterPosition.EXCEPTION_TRANSLATION_FILTER.order - 10] = 'sitemesh' + filterNames[SecurityFilterPosition.EXCEPTION_TRANSLATION_FILTER.order - 5] = 'sitemesh' } SpringSecurityUtils.buildFilterChains filterNames, conf.filterChain.chainMap ?: [], securityFilterChains, applicationContext From 360eaf280d5e067984139864feffe2fb3422dec8 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 21:47:32 -0500 Subject: [PATCH 19/25] Ensure data is built and not rolled back --- .../groovy/demo/SecuredControllerSpec.groovy | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy index 918e477f..d61b081c 100644 --- a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy +++ b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy @@ -8,8 +8,7 @@ import grails.gorm.transactions.Rollback @Integration(applicationClass = Application) class SecuredControllerSpec extends ContainerGebSpec { - def setup() { - browser.go('/') + void setupData() { if ( !User.findByUsername('sherlock') ) { final boolean flush = true final boolean failOnError = true @@ -34,6 +33,9 @@ class SecuredControllerSpec extends ContainerGebSpec { } def "test login as sherlock, sherlock belongs to detective groups. All detectives have the role ADMIN"() { + given: + setupData() + when: to SecuredPage @@ -51,6 +53,9 @@ class SecuredControllerSpec extends ContainerGebSpec { } def "test login as watson, watson belongs to detective groups. All detectives have the role ADMIN"() { + given: + setupData() + when: to SecuredPage From 9c90a445beb0d9dfdcf6eaf04a7cd81e50ff10af Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 16 Dec 2024 21:47:44 -0500 Subject: [PATCH 20/25] Remove going to index --- .../integration-test/groovy/demo/SecuredControllerSpec.groovy | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy index a9e4247c..2be143b6 100644 --- a/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy +++ b/examples/misc-functional-test-app/grails-spring-security-hierarchical-roles/src/integration-test/groovy/demo/SecuredControllerSpec.groovy @@ -6,10 +6,6 @@ import grails.testing.mixin.integration.Integration @Integration(applicationClass = Application) class SecuredControllerSpec extends ContainerGebSpec { - def setup() { - browser.go('/') - } - def "test RoleHierarchyEntry lifecycle"() { when: to SecuredPage From 62c063af231a967dd9bdc67898da6a55c34e1906 Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Tue, 17 Dec 2024 08:56:45 +0100 Subject: [PATCH 21/25] fix(deps): remove all `micronaut-inject-groovy dependencies` Micronaut is removed from Grails 7. --- examples/functional-test-app/build.gradle | 6 ------ examples/integration-test-app/build.gradle | 3 --- .../grails-spring-security-group/build.gradle | 2 -- gradle/integrationTest.gradle | 1 - gradle/libs.versions.toml | 1 - plugin/src/docs/code/s2-quickstart/build.gradle | 2 -- 6 files changed, 15 deletions(-) diff --git a/examples/functional-test-app/build.gradle b/examples/functional-test-app/build.gradle index 8185ded7..056ed2a5 100644 --- a/examples/functional-test-app/build.gradle +++ b/examples/functional-test-app/build.gradle @@ -8,12 +8,6 @@ plugins { group = 'examples.test' -configurations { - all { - exclude group: 'io.micronaut', module:'micronaut-inject-groovy' - } -} - dependencies { implementation project(':spring-security-core') diff --git a/examples/integration-test-app/build.gradle b/examples/integration-test-app/build.gradle index 4c7dac80..080b998c 100644 --- a/examples/integration-test-app/build.gradle +++ b/examples/integration-test-app/build.gradle @@ -32,15 +32,12 @@ dependencies { runtimeOnly libs.springboot.starter.tomcat runtimeOnly libs.tomcat.jdbc - compileOnly libs.micronaut.inject.groovy compileOnly libs.jakarta.servlet.api compileOnly libs.slf4j.nop testImplementation libs.spock.core testImplementation libs.spring.tx testImplementation libs.bundles.grails.testing.support - - testCompileOnly libs.micronaut.inject.groovy } apply from: rootProject.layout.projectDirectory.file('gradle/java-config.gradle') diff --git a/examples/misc-functional-test-app/grails-spring-security-group/build.gradle b/examples/misc-functional-test-app/grails-spring-security-group/build.gradle index 6d17ceb4..ba1a064c 100644 --- a/examples/misc-functional-test-app/grails-spring-security-group/build.gradle +++ b/examples/misc-functional-test-app/grails-spring-security-group/build.gradle @@ -28,8 +28,6 @@ dependencies { runtimeOnly libs.springboot.starter.tomcat runtimeOnly libs.h2database runtimeOnly libs.tomcat.jdbc - - compileOnly libs.micronaut.inject.groovy } apply from: rootProject.layout.projectDirectory.file('gradle/java-config.gradle') diff --git a/gradle/integrationTest.gradle b/gradle/integrationTest.gradle index 6743afaf..b2b6f141 100644 --- a/gradle/integrationTest.gradle +++ b/gradle/integrationTest.gradle @@ -1,6 +1,5 @@ dependencies { add('testImplementation', libs.micronaut.httpclient) - add('testImplementation', libs.micronaut.inject.groovy) add('testImplementation', libs.bundles.grails.testing.support) integrationTestImplementation testFixtures(libs.geb.plugin) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e3888c01..e39a8ab8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -39,7 +39,6 @@ jakarta-annotation-api = { module = 'jakarta.annotation:jakarta.annotation-api' jakarta-servlet-api = { module = 'jakarta.servlet:jakarta.servlet-api' } h2database = { module = 'com.h2database:h2' } micronaut-httpclient = { module = 'io.micronaut:micronaut-http-client', version.ref = 'micronaut' } -micronaut-inject-groovy = { module = 'io.micronaut:micronaut-inject-groovy', version.ref = 'micronaut' } micronaut-jackson-databind = { module = 'io.micronaut:micronaut-jackson-databind', version.ref = 'micronaut' } slf4j-nop = { module = 'org.slf4j:slf4j-nop' } spock-core = { module = 'org.spockframework:spock-core' } diff --git a/plugin/src/docs/code/s2-quickstart/build.gradle b/plugin/src/docs/code/s2-quickstart/build.gradle index c0d00190..a42f5d06 100644 --- a/plugin/src/docs/code/s2-quickstart/build.gradle +++ b/plugin/src/docs/code/s2-quickstart/build.gradle @@ -24,7 +24,6 @@ repositories { } dependencies { - compileOnly "io.micronaut:micronaut-inject-groovy" console "org.grails:grails-console" implementation "org.springframework.boot:spring-boot-starter-logging" implementation "org.springframework.boot:spring-boot-starter-validation" @@ -54,7 +53,6 @@ dependencies { runtimeOnly "org.apache.tomcat:tomcat-jdbc" runtimeOnly "javax.xml.bind:jaxb-api:2.3.1" runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:4.3.0" - testImplementation "io.micronaut:micronaut-inject-groovy" testImplementation "org.grails:grails-gorm-testing-support" testImplementation "org.mockito:mockito-core" testImplementation "org.grails:grails-web-testing-support" From 2b6313d0393c1eeebd0a83c17b9e260439a97e26 Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Tue, 17 Dec 2024 08:57:44 +0100 Subject: [PATCH 22/25] fix(deps): add `gsp` dependency to test app --- .../grails-spring-security-group/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/misc-functional-test-app/grails-spring-security-group/build.gradle b/examples/misc-functional-test-app/grails-spring-security-group/build.gradle index ba1a064c..868816d4 100644 --- a/examples/misc-functional-test-app/grails-spring-security-group/build.gradle +++ b/examples/misc-functional-test-app/grails-spring-security-group/build.gradle @@ -19,6 +19,7 @@ dependencies { implementation libs.spring.beans runtimeOnly libs.gorm.hibernate5 + runtimeOnly libs.grails.gsp runtimeOnly libs.grails.i18n runtimeOnly libs.grails.interceptors runtimeOnly libs.grails.services From 8129ef1a74586fcf0315d6e1e388a89aef119720 Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Tue, 17 Dec 2024 09:16:41 +0100 Subject: [PATCH 23/25] fix: add default 'main' layout to plugin The default `main` layout is referenced in `login/auth.gsp` and `login/denied.gsp` but it is not included in the plugin. This commit adds the `main` layout to the plugin so it can be found even if there is not such layout in the application. --- plugin/grails-app/views/layouts/main.gsp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 plugin/grails-app/views/layouts/main.gsp diff --git a/plugin/grails-app/views/layouts/main.gsp b/plugin/grails-app/views/layouts/main.gsp new file mode 100644 index 00000000..e40d8978 --- /dev/null +++ b/plugin/grails-app/views/layouts/main.gsp @@ -0,0 +1,15 @@ + + + + + + + <g:layoutTitle default="Grails"/> + + + + + + + + From d3ce67412acebaf05bd3f81ca94a465e7aabde54 Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Tue, 17 Dec 2024 10:16:54 +0100 Subject: [PATCH 24/25] test: use `setup()` fixture method in test --- .../groovy/demo/SecuredControllerSpec.groovy | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy index d61b081c..4e84f43d 100644 --- a/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy +++ b/examples/misc-functional-test-app/grails-spring-security-group/src/integration-test/groovy/demo/SecuredControllerSpec.groovy @@ -8,7 +8,7 @@ import grails.gorm.transactions.Rollback @Integration(applicationClass = Application) class SecuredControllerSpec extends ContainerGebSpec { - void setupData() { + def setup() { if ( !User.findByUsername('sherlock') ) { final boolean flush = true final boolean failOnError = true @@ -33,8 +33,6 @@ class SecuredControllerSpec extends ContainerGebSpec { } def "test login as sherlock, sherlock belongs to detective groups. All detectives have the role ADMIN"() { - given: - setupData() when: to SecuredPage @@ -53,8 +51,6 @@ class SecuredControllerSpec extends ContainerGebSpec { } def "test login as watson, watson belongs to detective groups. All detectives have the role ADMIN"() { - given: - setupData() when: to SecuredPage From 04c5c872a2c6847455fb3b27b7defbab4e93c43a Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Tue, 17 Dec 2024 10:17:58 +0100 Subject: [PATCH 25/25] test: add views in test app These views are referenced in the `UrlMappings`. --- .../grails-app/views/error.gsp | 22 +++++++++++++++++++ .../grails-app/views/index.gsp | 9 ++++++++ .../grails-app/views/notFound.gsp | 12 ++++++++++ 3 files changed, 43 insertions(+) create mode 100644 examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/error.gsp create mode 100644 examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/index.gsp create mode 100644 examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/notFound.gsp diff --git a/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/error.gsp b/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/error.gsp new file mode 100644 index 00000000..6f033243 --- /dev/null +++ b/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/error.gsp @@ -0,0 +1,22 @@ + + + + Grails Runtime Exception + + + + + + + + + +
    +
  • An error has occurred
  • +
  • Exception: ${exception}
  • +
  • Message: ${message}
  • +
  • Path: ${path}
  • +
+
+ + diff --git a/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/index.gsp b/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/index.gsp new file mode 100644 index 00000000..11f08b2a --- /dev/null +++ b/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/index.gsp @@ -0,0 +1,9 @@ + + + + Welcome to Grails + + +

Welcome to Grails

+ + diff --git a/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/notFound.gsp b/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/notFound.gsp new file mode 100644 index 00000000..cf84e412 --- /dev/null +++ b/examples/misc-functional-test-app/grails-spring-security-group/grails-app/views/notFound.gsp @@ -0,0 +1,12 @@ + + + + Page Not Found + + +
    +
  • Error: Page Not Found (404)
  • +
  • Path: ${request.forwardURI}
  • +
+ +