From c5a7f1feaea7fb445fdb5aecd1422d987463866f Mon Sep 17 00:00:00 2001 From: HMS-Victory <90852625+HMS-Victory@users.noreply.github.com> Date: Tue, 3 Feb 2026 08:52:56 -0700 Subject: [PATCH 1/6] feat: add ability to pass custom email into createUserFromFaker method --- build.gradle.kts | 2 +- .../groovy/org/justserve/JustServeSpec.groovy | 20 ++++++++++++------- .../cli/command/GetTempPasswordSpec.groovy | 5 +---- .../justserve/client/UserClientSpec.groovy | 14 ++++++++++++- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 69182a2..b589ec9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,6 +35,7 @@ dependencies { implementation("org.simplejavamail:simple-java-mail:8.12.6") implementation("org.jsoup:jsoup:1.21.2") testImplementation("net.datafaker:datafaker:2.5.1") + testImplementation("org.apache.commons:commons-lang3:3.20.0") compileOnly("org.projectlombok:lombok") runtimeOnly("ch.qos.logback:logback-classic") runtimeOnly("org.yaml:snakeyaml") @@ -83,7 +84,6 @@ graalvmNative.binaries { named("main") { imageName.set("justserve") buildArgs.add("--color=always") - buildArgs.add("-march=native") } } diff --git a/src/test/groovy/org/justserve/JustServeSpec.groovy b/src/test/groovy/org/justserve/JustServeSpec.groovy index 277ddad..b82c51b 100644 --- a/src/test/groovy/org/justserve/JustServeSpec.groovy +++ b/src/test/groovy/org/justserve/JustServeSpec.groovy @@ -7,6 +7,7 @@ import io.micronaut.http.HttpStatus import io.micronaut.http.client.exceptions.HttpClientResponseException import io.micronaut.test.extensions.spock.annotation.MicronautTest import net.datafaker.Faker +import org.apache.commons.lang3.RandomStringUtils import org.justserve.client.* import org.justserve.model.* import spock.lang.Shared @@ -87,7 +88,10 @@ class JustServeSpec extends Specification { userClient = ctx.getBean(UserClient) readOnlyUser = new TestUser(new Faker(Locale.of("en-us"))) projectClient = ctx.getBean(ProjectClient) - readOnlyUser.uuid = createUser(noAuthUserClient, readOnlyUser).body().getId() + + // TODO: validate the user does not already exist (use the admin client user search) + String customRandomEmail=RandomStringUtils.insecure().nextAlphanumeric(20)+ "@fake.com" + readOnlyUser.uuid = createUserFromFaker(noAuthUserClient, readOnlyUser, customRandomEmail).body().getId() searchResults = getProjectsByLocation(faker.location().toString()) } @@ -96,24 +100,26 @@ class JustServeSpec extends Specification { ctx.stop() } - def createUser() { - def response - while (null == response) { + def createUser(UserClient client = noAuthUserClient) { + HttpResponse response = null + def tries = 0 + while ((null == response || HttpStatus.OK != response.status()) && tries < 5) { try { // A new user is generated on each loop iteration to avoid collisions - response = createUser(noAuthUserClient, new TestUser(new Faker(Locale.of("en-us")))) + response = createUserFromFaker(client, new TestUser(new Faker(Locale.of("en-us")))) } catch (HttpClientResponseException ignored) { + tries++ // This user likely already exists, so we'll loop and try a new one. } } return response } - def createUser(UserClient client = noAuthUserClient, TestUser user) { + private def createUserFromFaker(UserClient client, TestUser user, String uniqueEmailInput=null) { return client.createUser( user.firstName, user.lastName, - user.email, + (uniqueEmailInput ?: user.email) as String, //in the case that we provide our own custom email, to avoid the same email being repeated user.password, user.zipcode, user.locale, diff --git a/src/test/groovy/org/justserve/cli/command/GetTempPasswordSpec.groovy b/src/test/groovy/org/justserve/cli/command/GetTempPasswordSpec.groovy index 41d9ead..2e38004 100644 --- a/src/test/groovy/org/justserve/cli/command/GetTempPasswordSpec.groovy +++ b/src/test/groovy/org/justserve/cli/command/GetTempPasswordSpec.groovy @@ -5,7 +5,6 @@ import net.datafaker.Faker import org.justserve.TestUser import spock.lang.Execution import spock.lang.Retry -import spock.lang.Shared import spock.lang.Unroll import static org.spockframework.runtime.model.parallel.ExecutionMode.SAME_THREAD @@ -13,12 +12,10 @@ import static org.spockframework.runtime.model.parallel.ExecutionMode.SAME_THREA @Execution(SAME_THREAD) @Retry class GetTempPasswordSpec extends BaseCommandSpec { - @Shared - TestUser readOnlyUser def setupSpec() { readOnlyUser = new TestUser(new Faker(Locale.of("en-us"))) - readOnlyUser.uuid = createUser(readOnlyUser).body().getId() + readOnlyUser.uuid = createUser().body().getId() } @Unroll("getting temp password with '#flag' and '#email' returns ") diff --git a/src/test/groovy/org/justserve/client/UserClientSpec.groovy b/src/test/groovy/org/justserve/client/UserClientSpec.groovy index f8f36bd..a5eec60 100644 --- a/src/test/groovy/org/justserve/client/UserClientSpec.groovy +++ b/src/test/groovy/org/justserve/client/UserClientSpec.groovy @@ -2,6 +2,7 @@ package org.justserve.client import io.micronaut.http.client.exceptions.HttpClientResponseException import net.datafaker.Faker +import org.apache.commons.lang3.RandomStringUtils import org.justserve.JustServeSpec import org.justserve.TestUser import org.justserve.model.UserHashRequestByEmail @@ -13,8 +14,19 @@ class UserClientSpec extends JustServeSpec { def "create user #{user.firstname} #{user.lastname} #{user.email} #{user.password} #{user.postal} #{user.locale} #{user.country} #{user.countryCode}"() { when: TestUser user = new TestUser(new Faker(Locale.of("en-us"))) + then: - createUser(client, user) +// TODO: validate the user does not already exist (use the admin client user search) + client.createUser( + user.firstName, + user.lastName, + RandomStringUtils.insecure().nextAlphanumeric(20)+ "@fake.com", + user.password, + user.zipcode, + user.locale, + user.country, + user.countryCode + ) where: client | _ From fe853631c3bac37c2994ba0e1e377a508ede8b5e Mon Sep 17 00:00:00 2001 From: HMS-Victory <90852625+HMS-Victory@users.noreply.github.com> Date: Tue, 3 Feb 2026 08:55:27 -0700 Subject: [PATCH 2/6] fix: make createUserFromFaker static --- src/test/groovy/org/justserve/JustServeSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/org/justserve/JustServeSpec.groovy b/src/test/groovy/org/justserve/JustServeSpec.groovy index b82c51b..7f2d660 100644 --- a/src/test/groovy/org/justserve/JustServeSpec.groovy +++ b/src/test/groovy/org/justserve/JustServeSpec.groovy @@ -115,7 +115,7 @@ class JustServeSpec extends Specification { return response } - private def createUserFromFaker(UserClient client, TestUser user, String uniqueEmailInput=null) { + private static def createUserFromFaker(UserClient client, TestUser user, String uniqueEmailInput=null) { return client.createUser( user.firstName, user.lastName, From 0bee709fb79b79f80def6621976d6c8564ea85d5 Mon Sep 17 00:00:00 2001 From: HMS-Victory <90852625+HMS-Victory@users.noreply.github.com> Date: Tue, 3 Feb 2026 12:07:50 -0700 Subject: [PATCH 3/6] fix: undo accidental changes --- build.gradle.kts | 1 + .../org/justserve/cli/command/GetTempPasswordSpec.groovy | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b589ec9..18b6a61 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -84,6 +84,7 @@ graalvmNative.binaries { named("main") { imageName.set("justserve") buildArgs.add("--color=always") + buildArgs.add("-march=native") } } diff --git a/src/test/groovy/org/justserve/cli/command/GetTempPasswordSpec.groovy b/src/test/groovy/org/justserve/cli/command/GetTempPasswordSpec.groovy index 2e38004..a4bf523 100644 --- a/src/test/groovy/org/justserve/cli/command/GetTempPasswordSpec.groovy +++ b/src/test/groovy/org/justserve/cli/command/GetTempPasswordSpec.groovy @@ -5,17 +5,21 @@ import net.datafaker.Faker import org.justserve.TestUser import spock.lang.Execution import spock.lang.Retry +import spock.lang.Shared import spock.lang.Unroll import static org.spockframework.runtime.model.parallel.ExecutionMode.SAME_THREAD @Execution(SAME_THREAD) @Retry + class GetTempPasswordSpec extends BaseCommandSpec { + @Shared + TestUser readOnlyUser def setupSpec() { readOnlyUser = new TestUser(new Faker(Locale.of("en-us"))) - readOnlyUser.uuid = createUser().body().getId() + readOnlyUser.uuid = createUser(readOnlyUser).body().getId() } @Unroll("getting temp password with '#flag' and '#email' returns ") From 6da986bd3bd6e574b2883cf682e011b38dbac794 Mon Sep 17 00:00:00 2001 From: Jonathan Zollinger <62955101+Jonathan-Zollinger@users.noreply.github.com> Date: Wed, 4 Feb 2026 17:52:40 +0000 Subject: [PATCH 4/6] ci: test if I can use local graal install --- .github/workflows/TestAndCompile.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/TestAndCompile.yml b/.github/workflows/TestAndCompile.yml index bf687e5..8fdc9ea 100644 --- a/.github/workflows/TestAndCompile.yml +++ b/.github/workflows/TestAndCompile.yml @@ -10,14 +10,16 @@ jobs: # os: [macos-latest, windows-latest, ubuntu-latest] env: TEST_TOKEN: ${{ secrets.MICRONAUT_HTTP_SERVICES_JUSTSERVE_TOKEN }} + JAVA_HOME: C:\Users\jonathanzollinger\.jdks\graalvm-ce-21.0.2 + steps: - uses: actions/checkout@v4 - - uses: graalvm/setup-graalvm@v1 - with: - java-version: '21' - distribution: 'graalvm' - github-token: ${{ secrets.GITHUB_TOKEN }} - native-image-job-reports: 'true' + # - uses: graalvm/setup-graalvm@v1 + # with: + # java-version: '21' + # distribution: 'graalvm' + # github-token: ${{ secrets.GITHUB_TOKEN }} + # native-image-job-reports: 'true' - name: call gradle to run tests and then compile run: ./gradlew test nativeCompile - name: upload binary From 779b4cb1ee4d77ed650ea6e711166ab9f28e5d7c Mon Sep 17 00:00:00 2001 From: Jonathan Zollinger <62955101+Jonathan-Zollinger@users.noreply.github.com> Date: Wed, 4 Feb 2026 18:01:47 +0000 Subject: [PATCH 5/6] test: remove useless env assertion --- src/test/groovy/org/justserve/JustServeSpec.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/org/justserve/JustServeSpec.groovy b/src/test/groovy/org/justserve/JustServeSpec.groovy index 7f2d660..9561968 100644 --- a/src/test/groovy/org/justserve/JustServeSpec.groovy +++ b/src/test/groovy/org/justserve/JustServeSpec.groovy @@ -63,9 +63,9 @@ class JustServeSpec extends Specification { def setupSpec() { faker = new Faker() - if (null != System.getenv("JUSTSERVE_TOKEN")) { - throw new IllegalStateException("JUSTSERVE_TOKEN is set. Do not define this variable in testing.") - } + // if (null != System.getenv("JUSTSERVE_TOKEN")) { + // throw new IllegalStateException("JUSTSERVE_TOKEN is set. Do not define this variable in testing.") + // } ctx = ApplicationContext.builder() .environments(Environment.CLI, Environment.TEST) .properties([ From 7a570fd0c3725e8321444b4b59ec510316411080 Mon Sep 17 00:00:00 2001 From: Jonathan Zollinger <62955101+Jonathan-Zollinger@users.noreply.github.com> Date: Wed, 4 Feb 2026 18:14:42 +0000 Subject: [PATCH 6/6] test: print more output from tests --- build.gradle.kts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 18b6a61..67fc9c7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -59,6 +59,16 @@ tasks.withType { } } +tasks.withType { + testLogging { + events("passed", "skipped", "failed") + showStandardStreams = true + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL + } + // Exclude EmailParserSpec until we can provide test .eml files without PII data + exclude("**/EmailParserSpec.class") +} + micronaut { testRuntime("spock2") openapi {