From 9a7ff26210f901fbe70019b1cf793063077d3cfe Mon Sep 17 00:00:00 2001 From: samirgarg Date: Thu, 8 Jan 2026 15:16:42 +0000 Subject: [PATCH 1/4] AMP-187 Add api test as a separate module in project which can be invoked from commandline and intellij --- apiTest/apiTest_README.md | 245 +++++++++++++++++ apiTest/build.gradle | 99 +++++++ .../docker-compose.yml | 1 + apiTest/gradlew | 251 ++++++++++++++++++ apiTest/gradlew.bat | 94 +++++++ .../cp/subscription/http/ActuatorApiTest.java | 1 + .../cp/subscription/http/RootApiTest.java | 0 .../http/SubscriptionApiTest.java | 0 .../resources/__files/material-content.pdf | Bin 0 -> 8682 bytes .../resources/__files/material-response.json | 7 + .../mappings/material-content-mapping.json | 14 + .../mappings/material-metadata-mapping.json | 13 + build.gradle | 2 - gradle/github/jar.gradle | 4 - gradle/tasks/apitest.gradle | 54 ---- 15 files changed, 725 insertions(+), 60 deletions(-) create mode 100644 apiTest/apiTest_README.md create mode 100644 apiTest/build.gradle rename docker-compose.yml => apiTest/docker-compose.yml (97%) create mode 100755 apiTest/gradlew create mode 100644 apiTest/gradlew.bat rename {src/apiTest => apiTest/src/test}/java/uk/gov/hmcts/cp/subscription/http/ActuatorApiTest.java (94%) rename {src/apiTest => apiTest/src/test}/java/uk/gov/hmcts/cp/subscription/http/RootApiTest.java (100%) rename {src/apiTest => apiTest/src/test}/java/uk/gov/hmcts/cp/subscription/http/SubscriptionApiTest.java (100%) create mode 100644 apiTest/src/test/resources/__files/material-content.pdf create mode 100644 apiTest/src/test/resources/__files/material-response.json create mode 100644 apiTest/src/test/resources/mappings/material-content-mapping.json create mode 100644 apiTest/src/test/resources/mappings/material-metadata-mapping.json delete mode 100644 gradle/tasks/apitest.gradle diff --git a/apiTest/apiTest_README.md b/apiTest/apiTest_README.md new file mode 100644 index 00000000..fbfd8a46 --- /dev/null +++ b/apiTest/apiTest_README.md @@ -0,0 +1,245 @@ +# API Test Module + +This module contains api tests that run against a Docker containerized version of the application. +The tests make HTTP calls to verify the API endpoints are working correctly. + +## Overview + +The `apiTest` module is a standalone Gradle project that: +- Runs api tests against the application running in Docker containers +- Automatically manages Docker containers (starts before tests, stops after) +- Generates HTML and XML test reports + +## Prerequisites + +Before running the tests, ensure you have the following installed and configured: + +### Required Software + +1. **Java 21** (or higher) + - Verify installation: `java -version` + - Should show version 21 or higher + +2. **Docker Desktop** (or Docker Engine) + - Verify installation: `docker --version` + - Docker must be running (check with `docker ps`) + - Docker Compose V2 must be available: `docker compose version` + +3. **Gradle** (or use the Gradle wrapper) + - The project includes `gradlew` wrapper, so Gradle installation is optional + - Verify wrapper: `./gradlew --version` + +### System Requirements + +- At least 4GB of free RAM (Docker containers need memory) +- Ports available: `8082` (application), `5432` (PostgreSQL), `9999` (WireMock) +- Sufficient disk space for Docker images + +## Running Tests + +### From the Root Directory + +```bash +# Navigate to the apiTest directory +cd apiTest + +# Run all tests +../gradlew test + +# Run tests with more verbose output +../gradlew test --info + +# Run tests with debug output +../gradlew test --debug +``` + +### From the apiTest Directory + +```bash +# If you're already in the apiTest directory +../gradlew test +``` + +### What Happens When You Run Tests + +1. **Builds the root project's bootJar** - The application JAR is built first +2. **Builds Docker images** - Creates the application Docker image +3. **Starts Docker containers**: + - PostgreSQL database (port 5432) + - Application server (port 8082) + - WireMock server (port 9999) +4. **Runs tests** - Executes all test classes +5. **Stops and removes containers** - Cleanup after tests complete + +### Running Specific Tests + +```bash +# Run a specific test class +../gradlew test --tests "RootApiTest" + +# Run a specific test method +../gradlew test --tests "RootApiTest.root_endpoint_should_be_ok" +``` + +## Test Reports + +After running tests, you can view the results in several formats: + +### HTML Test Report (Recommended) + +**Location:** `apiTest/build/reports/tests/test/index.html` + +The HTML report includes: +- Test summary (total, passed, failed, skipped) +- Individual test results with execution times +- Stack traces for failed tests +- Package and class-level summaries + +### JUnit XML Reports + +**Location:** `apiTest/build/test-results/test/` + +These XML reports are useful for CI/CD integration. + +## Troubleshooting + +### Issue: "Could not start Gradle Test Executor 1: Failed to load JUnit Platform" + +**Solution:** This should be resolved with the current configuration. If you see this error: +1. Clean the build: `../gradlew clean` +2. Rebuild: `../gradlew build` + +### Issue: "no main manifest attribute, in /app/apiTest-0.0.999.jar" + +**Solution:** This means the Docker build context is wrong. Ensure: +1. The `docker-compose.yml` has `context: ..` (builds from root directory) +2. The root project's `bootJar` is built before Docker build +3. Run: `../gradlew buildRootBootJar` manually if needed + +### Issue: Container exits with code 1 + +**Check application logs:** +```bash +# View app container logs +docker logs apitest-app-1 + +# Or using docker-compose +docker-compose -f docker-compose.yml logs app + +# View all container logs +docker-compose -f docker-compose.yml logs +``` + +**Common causes:** +- Application configuration errors +- Database connection issues +- Missing environment variables +- Port conflicts + +### Issue: Port already in use + +**Solution:** Stop any services using the required ports: +```bash +# Check what's using port 8082 +lsof -i :8082 + +# Check what's using port 5432 +lsof -i :5432 + +# Stop conflicting services or change ports in docker-compose.yml +``` + +### Issue: Cannot connect to database + +**Solution:** +- Ensure the database container is healthy: `docker ps` should show "Healthy" +- Check database logs: `docker-compose -f docker-compose.yml logs db` +- Verify connection string in `docker-compose.yml` matches database configuration + +### Issue: IntelliJ not recognizing Java code + +Change .idea/gradle.xml to add apiTest module + +```.idea/gradle.xml + + + + + + + +``` + +**Solution:** +1. **Refresh Gradle Project:** + - Open Gradle tool window (View → Tool Windows → Gradle) + - Click the refresh button (circular arrow icon) + - Or: File → Reload Gradle Project + +2. **Mark Directory as Test Source:** + - Right-click on `apiTest/src/test/java` + - Mark Directory as → Test Sources Root + +3. **Reimport Project:** + - File → Invalidate Caches... → Invalidate and Restart + +4. **Verify Module Recognition:** + - File → Project Structure (⌘; on Mac) + - Check that `apiTest` module appears under Modules + +## Manual Container Management + +If you need to manually manage containers: + +```bash +# Start containers without running tests +docker-compose -f docker-compose.yml up -d + +# Stop containers +docker-compose -f docker-compose.yml down + +# View container logs +docker-compose -f docker-compose.yml logs -f app + +# Check container status +docker-compose -f docker-compose.yml ps + +# Rebuild containers +docker-compose -f docker-compose.yml build --no-cache +``` + +## Test Configuration + +### Environment Variables + +Tests use the following default configuration: +- Application base URL: `http://localhost:8082` (can be overridden with `app.baseUrl` system property) +- Database: PostgreSQL on port 5432 +- WireMock: Port 9999 + +### Customizing Test Execution + +You can override the application URL: +```bash +../gradlew test -Dapp.baseUrl=http://localhost:8080 +``` + diff --git a/apiTest/build.gradle b/apiTest/build.gradle new file mode 100644 index 00000000..4d47c69b --- /dev/null +++ b/apiTest/build.gradle @@ -0,0 +1,99 @@ +// TODO need to delete duplicate code +plugins { + id 'java' + id 'com.avast.gradle.docker-compose' version '0.17.20' + id 'io.spring.dependency-management' version '1.1.7' +} + +group = 'uk.gov.hmcts.cp' +version = System.getProperty('ARTEFACT_VERSION') ?: '0.0.999' + +// Disable main source set since this module only has tests +sourceSets { + main { + java.srcDirs = [] + resources.srcDirs = [] + } +} + +// Disable unnecessary tasks for test-only module +tasks.named('jar') { + enabled = false +} + +tasks.named('compileJava') { + enabled = false +} + +tasks.named('processResources') { + enabled = false +} + +dependencyManagement { + imports { + mavenBom "org.springframework.boot:spring-boot-dependencies:4.0.1" + } +} + +tasks.named('test') { + description = "Runs api tests against docker-compose stack" + group = "Verification" + useJUnitPlatform() + dependsOn tasks.composeUp + finalizedBy tasks.composeDown + + testLogging { + events "passed", "skipped", "failed" + exceptionFormat = 'full' + showStandardStreams = true + } + + reports { + junitXml.required.set(true) + html.required.set(true) + } +} + +tasks.named('build') { + dependsOn tasks.named('test') +} + +dockerCompose { + useComposeFiles = ['docker-compose.yml'] + startedServices = ['db', 'app'] + + buildBeforeUp = true + waitForTcpPorts = true + upAdditionalArgs = ['--wait', '--wait-timeout', '120'] + + captureContainersOutput = true + removeOrphans = true + stopContainers = true + removeContainers = true + + useDockerComposeV2 = true + dockerExecutable = 'docker' +} + +// Build the root project's bootJar before building Docker image +tasks.register('buildRootBootJar', Exec) { + description = "Builds the root project's bootJar" + workingDir = projectDir.parent + executable = "${projectDir.parent}/gradlew" + args = ['bootJar'] +} + +tasks.named('composeBuild') { + dependsOn tasks.named('buildRootBootJar') +} + +dependencies { + testImplementation "org.springframework:spring-web" + testImplementation "org.springframework.boot:spring-boot-starter-test" + testRuntimeOnly "org.junit.platform:junit-platform-launcher" +} + +repositories { + mavenLocal() + mavenCentral() +} \ No newline at end of file diff --git a/docker-compose.yml b/apiTest/docker-compose.yml similarity index 97% rename from docker-compose.yml rename to apiTest/docker-compose.yml index 099b87f8..5bb3522f 100644 --- a/docker-compose.yml +++ b/apiTest/docker-compose.yml @@ -10,6 +10,7 @@ services: app: build: + context: .. dockerfile: Dockerfile environment: SERVER_PORT: 8082 diff --git a/apiTest/gradlew b/apiTest/gradlew new file mode 100755 index 00000000..ef07e016 --- /dev/null +++ b/apiTest/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/apiTest/gradlew.bat b/apiTest/gradlew.bat new file mode 100644 index 00000000..db3a6ac2 --- /dev/null +++ b/apiTest/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/apiTest/java/uk/gov/hmcts/cp/subscription/http/ActuatorApiTest.java b/apiTest/src/test/java/uk/gov/hmcts/cp/subscription/http/ActuatorApiTest.java similarity index 94% rename from src/apiTest/java/uk/gov/hmcts/cp/subscription/http/ActuatorApiTest.java rename to apiTest/src/test/java/uk/gov/hmcts/cp/subscription/http/ActuatorApiTest.java index 44f6d797..e3725918 100644 --- a/src/apiTest/java/uk/gov/hmcts/cp/subscription/http/ActuatorApiTest.java +++ b/apiTest/src/test/java/uk/gov/hmcts/cp/subscription/http/ActuatorApiTest.java @@ -13,6 +13,7 @@ class ActuatorApiTest { private final String baseUrl = System.getProperty("app.baseUrl", "http://localhost:8082"); + // TODO remove this client and use FeignClient/RestClient private final RestTemplate http = new RestTemplate(); @Test diff --git a/src/apiTest/java/uk/gov/hmcts/cp/subscription/http/RootApiTest.java b/apiTest/src/test/java/uk/gov/hmcts/cp/subscription/http/RootApiTest.java similarity index 100% rename from src/apiTest/java/uk/gov/hmcts/cp/subscription/http/RootApiTest.java rename to apiTest/src/test/java/uk/gov/hmcts/cp/subscription/http/RootApiTest.java diff --git a/src/apiTest/java/uk/gov/hmcts/cp/subscription/http/SubscriptionApiTest.java b/apiTest/src/test/java/uk/gov/hmcts/cp/subscription/http/SubscriptionApiTest.java similarity index 100% rename from src/apiTest/java/uk/gov/hmcts/cp/subscription/http/SubscriptionApiTest.java rename to apiTest/src/test/java/uk/gov/hmcts/cp/subscription/http/SubscriptionApiTest.java diff --git a/apiTest/src/test/resources/__files/material-content.pdf b/apiTest/src/test/resources/__files/material-content.pdf new file mode 100644 index 0000000000000000000000000000000000000000..94e3be392efef104e18d421ad10f13c11aafe301 GIT binary patch literal 8682 zcmai41ys~qx2Kd=L|TxcL8K;tp;J=2dw`*PXaqzFLAoWSq(i#9K|-X<5fG4Wl<*CD z?|1Ka?|bW=HEU+hKKq<~cKp}+?Y;j@DpF54csN0LOxfTO7m zo{$iL>xs3UE8GS3YX@_MOTonXAR*SJlP`BFNwsDUehJW z@^P+1t!S(daWEs(Ql!k=(JeAPm>t=4*YO{!fcRuF?;6l)+tLl%Z zo~{5x0GFhrouiAo6U+<_xG}sWf(HQkB|}66Wqy>{Ut|ppAb{_Nj5__s_|j3hr)g23M1j_>bd&ygb1F-L-#rXL_QChWad7$Y={+%NQ{|fa#dZ z8yE0VP?i)+HB|1o3Px}sv%A!-CnWdSw9GZy(PcvD&7?{2U%oJ%#yuob>FrRJl3rU3 zx5eEng&ZxVT=nTL&#u=^&sy&JPB)^dT)x2Sbk#wB4$jgc+1=_eAih7;eTG3ngnmZ{ zy&Y*`fhBV;h4JaKMflB|0@>cG(_PNz=1udD+fN!Px1=+F_W)h z#H&~JPy&Bq4IU@30fTvfWLdb`CG;!Z<#wm}U)h@ml9QNMv#4}OD4W3<;Y}(_DNM+m zaI7qYWTwxSInS`+EgEtuXlrMz6BFlYifG&(Z=N~w2tbf>;reQ%pxe(0xuCEV|Qp?Sc(J(?jNo}s&Jw_U>3LWXwAsFzAp z)taD*R&9Swm*v=@n`wIaJ{_E{+I|O>BEhqa1-$mvN$HBH> z=-Hd0-3u+jcjTf0405C(xb)h){C5gc!@~r3l19z1&WL`lv_q{w40JtC%WNk<2-?t8 z-H68x47F+s5(?0X<}}9(^q)lfQ}D82Q~IUbl32MJqxl9wRqExi`yGYRBpEOn9Ynn` ze7E$8c<}mLo2^P?$`MgO@9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1}diyaLqMrwZ$!as+C@ah7a(h@cHUeio;k-Hc;OV-Mh2Ir4eT?duPYF=BB2m z`SG3hJ^4$0w}aa%m?I;)xM@|z5hgVyJ+aecc*p#Uv9QW_M-j_g-$I|YSSgIo3JWU# zs4gjkZZ?J{_UT^ z`|lUDX40-(YiYG2?(AEtzOmr+FFt}sSk!FAwm{Efoec-`CgDS)>HJFXWccf9;wU^VoN6T%pQEDs2Lb82WQqk ztoq=b?2$NRG`yxc3@0lIxoBDH=*$VK7WEg(Je}{gcjaEUx+5GTH}WQQM9A#j4_6m8 zWwmp4p|t~+8h9j4x9vKCv{w=^C2zeZSza-BPGNCFo8CW^(eJzK=OOw1YHm~DN@NR_=^QSDQ(;6q4k(QxG?Vj>kW2x}bSG(d%kGhT`EqsDC?J6rH`w(}0U0aq~0$Y@b z%OQxMpIsgcMGx%-yaQ~!4CTwLM&Bni2%mDr+CoyRCaSl5CwFT$x2Eu|sUn@aC})1M z1;?j-jPyy$ly?VuJbH5m+HLn{$X9-fR6oe)L|5K^$J>8JbB-KsF?3K*DRfTo$w?JZ z+(#XT_~yUfhf917R9}mBV#ZG5z*7g%bsu@|8d%yDm!sf z_qO-C~-GSDLHjkH#t)C$_b!GNQSw41*7j9y8-x9A)zw`d@@U9949e9i!bk z8CsJI^Lfr^r3+jX7d+KO@!vgrfS^laGc)GwX@VEgyU_9>s3;-_#0)hZ60Dsa@VgSEZ0Scr|?fcApgH< z{QUox3jzJ>eqbI{CGH>R@pJQ|{B|>LbaQoqp~@;Qzh0nFxAumkY=wH2z|j#^$N60i zlyk6fL=}Dhm`I^2eM06S9x%`XWCr4c0YNa-RZJmZD6a(=3^N6RpkSy7-v7_?yB>&e VMa97{C-DQp5IiO(Y2_z){{tT(mKy*7 literal 0 HcmV?d00001 diff --git a/apiTest/src/test/resources/__files/material-response.json b/apiTest/src/test/resources/__files/material-response.json new file mode 100644 index 00000000..30f20a05 --- /dev/null +++ b/apiTest/src/test/resources/__files/material-response.json @@ -0,0 +1,7 @@ +{ + "materialId": "6c198796-08bb-4803-b456-fa0c29ca6021", + "alfrescoAssetId": "82257b1b-571d-432e-8871-b0c5b4bd18b1", + "fileName": "PrisonCourtRegister_20251219083322.pdf", + "mimeType": "application/pdf", + "materialAddedDate": "2025-12-19T08:33:29.866Z" +} \ No newline at end of file diff --git a/apiTest/src/test/resources/mappings/material-content-mapping.json b/apiTest/src/test/resources/mappings/material-content-mapping.json new file mode 100644 index 00000000..89d431bb --- /dev/null +++ b/apiTest/src/test/resources/mappings/material-content-mapping.json @@ -0,0 +1,14 @@ +{ + "request": { + "method": "GET", + "url": "/material-query-api/query/api/rest/material/material/7c198796-08bb-4803-b456-fa0c29ca6021/content" + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/pdf", + "Content-Disposition": "inline; filename=\"material-content.pdf\"" + }, + "bodyFileName": "material-content.pdf" + } +} diff --git a/apiTest/src/test/resources/mappings/material-metadata-mapping.json b/apiTest/src/test/resources/mappings/material-metadata-mapping.json new file mode 100644 index 00000000..083403ea --- /dev/null +++ b/apiTest/src/test/resources/mappings/material-metadata-mapping.json @@ -0,0 +1,13 @@ +{ + "request": { + "method": "GET", + "url": "/material-query-api/query/api/rest/material/material/6c198796-08bb-4803-b456-fa0c29ca6021/metadata" + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json" + }, + "bodyFileName": "material-response.json" + } +} diff --git a/build.gradle b/build.gradle index f2baf3d7..0a2f3e2b 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,6 @@ plugins { id 'com.github.ben-manes.versions' version '0.53.0' id 'org.cyclonedx.bom' version '3.1.0' id 'com.gorylenko.gradle-git-properties' version '2.5.4' - id 'com.avast.gradle.docker-compose' version '0.17.20' } group = 'uk.gov.hmcts.cp' @@ -27,7 +26,6 @@ apply { from("$rootDir/gradle/github/test.gradle") from("$rootDir/gradle/github/jar.gradle") - from("$rootDir/gradle/tasks/apitest.gradle") from("$rootDir/gradle/dependencies/spring-cloud.gradle") } diff --git a/gradle/github/jar.gradle b/gradle/github/jar.gradle index ab1810db..1ab3c102 100644 --- a/gradle/github/jar.gradle +++ b/gradle/github/jar.gradle @@ -24,10 +24,6 @@ bootJar { } } -tasks.named('composeBuild') { - dependsOn tasks.named('bootJar') -} - tasks.withType(AbstractArchiveTask).configureEach { preserveFileTimestamps = false reproducibleFileOrder = true diff --git a/gradle/tasks/apitest.gradle b/gradle/tasks/apitest.gradle deleted file mode 100644 index ba17df22..00000000 --- a/gradle/tasks/apitest.gradle +++ /dev/null @@ -1,54 +0,0 @@ -tasks.register('apiTest', Test) { - description = "Runs api tests against docker-compose stack" - group = "Verification" - - mustRunAfter tasks.named('test') - - testClassesDirs = sourceSets.apiTest.output.classesDirs - classpath = sourceSets.apiTest.runtimeClasspath - useJUnitPlatform() - - dependsOn tasks.composeUp - finalizedBy tasks.composeDown -} - -tasks.named('check') { - dependsOn tasks.named('apiTest') -} - -tasks.named('build') { - dependsOn tasks.named('test') - dependsOn tasks.named('apiTest') -} - -sourceSets { - apiTest { - java { - compileClasspath += sourceSets.main.output - runtimeClasspath += sourceSets.main.output - - } - } -} - -configurations { - apiTestImplementation.extendsFrom testImplementation - apiTestRuntimeOnly.extendsFrom testRuntimeOnly -} - -dockerCompose { - useComposeFiles = ['docker-compose.yml'] - startedServices = ['db', 'app'] - - buildBeforeUp = true - waitForTcpPorts = true - upAdditionalArgs = ['--wait', '--wait-timeout', '120'] - - captureContainersOutput = true - removeOrphans = true - stopContainers = true - removeContainers = true - - useDockerComposeV2 = true - dockerExecutable = 'docker' -} \ No newline at end of file From 884812b77afccc930bf29244db01a152a17c16c9 Mon Sep 17 00:00:00 2001 From: samirgarg Date: Fri, 9 Jan 2026 09:39:23 +0000 Subject: [PATCH 2/4] AMP-187 Remove the gradle wrapper as it is not present elsewhere --- apiTest/apiTest_README.md | 6 +- apiTest/gradlew | 251 -------------------------------------- apiTest/gradlew.bat | 94 -------------- 3 files changed, 1 insertion(+), 350 deletions(-) delete mode 100755 apiTest/gradlew delete mode 100644 apiTest/gradlew.bat diff --git a/apiTest/apiTest_README.md b/apiTest/apiTest_README.md index fbfd8a46..1ead5d5b 100644 --- a/apiTest/apiTest_README.md +++ b/apiTest/apiTest_README.md @@ -25,10 +25,6 @@ Before running the tests, ensure you have the following installed and configured - Docker must be running (check with `docker ps`) - Docker Compose V2 must be available: `docker compose version` -3. **Gradle** (or use the Gradle wrapper) - - The project includes `gradlew` wrapper, so Gradle installation is optional - - Verify wrapper: `./gradlew --version` - ### System Requirements - At least 4GB of free RAM (Docker containers need memory) @@ -240,6 +236,6 @@ Tests use the following default configuration: You can override the application URL: ```bash -../gradlew test -Dapp.baseUrl=http://localhost:8080 +gradle test -Dapp.baseUrl=http://localhost:8080 ``` diff --git a/apiTest/gradlew b/apiTest/gradlew deleted file mode 100755 index ef07e016..00000000 --- a/apiTest/gradlew +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH="\\\"\\\"" - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/apiTest/gradlew.bat b/apiTest/gradlew.bat deleted file mode 100644 index db3a6ac2..00000000 --- a/apiTest/gradlew.bat +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH= - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega From aa0408fff3b8218489121fdbb787145cde0cadbf Mon Sep 17 00:00:00 2001 From: samirgarg Date: Fri, 9 Jan 2026 09:49:53 +0000 Subject: [PATCH 3/4] AMP-187 Trimmed readme to take off xml setting --- apiTest/apiTest_README.md | 50 --------------------------------------- 1 file changed, 50 deletions(-) diff --git a/apiTest/apiTest_README.md b/apiTest/apiTest_README.md index 1ead5d5b..3bc1d9e3 100644 --- a/apiTest/apiTest_README.md +++ b/apiTest/apiTest_README.md @@ -152,56 +152,6 @@ lsof -i :5432 - Check database logs: `docker-compose -f docker-compose.yml logs db` - Verify connection string in `docker-compose.yml` matches database configuration -### Issue: IntelliJ not recognizing Java code - -Change .idea/gradle.xml to add apiTest module - -```.idea/gradle.xml - - - - - - - -``` - -**Solution:** -1. **Refresh Gradle Project:** - - Open Gradle tool window (View → Tool Windows → Gradle) - - Click the refresh button (circular arrow icon) - - Or: File → Reload Gradle Project - -2. **Mark Directory as Test Source:** - - Right-click on `apiTest/src/test/java` - - Mark Directory as → Test Sources Root - -3. **Reimport Project:** - - File → Invalidate Caches... → Invalidate and Restart - -4. **Verify Module Recognition:** - - File → Project Structure (⌘; on Mac) - - Check that `apiTest` module appears under Modules - ## Manual Container Management If you need to manually manage containers: From 484c58312f72315a4859ff3eebeb6079ee473312 Mon Sep 17 00:00:00 2001 From: samirgarg Date: Fri, 9 Jan 2026 12:48:45 +0000 Subject: [PATCH 4/4] AMP-187 Update location of docker compose in github action --- .github/workflows/codeql.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b7f2b1dd..fadcf37c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -96,6 +96,7 @@ jobs: - name: DAST - Build and run containerised app run: | + cd apiTest docker compose -f docker-compose.yml up -d echo "Waiting for health endpoint..."