diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 5f9d2649..d3159597 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -68,7 +68,7 @@ jobs: - name: Generate buildx cache key id: generate_buildx_cache_key run: | - echo "::set-output name=cache_key::$(./container_build/generate_buildx_cache_key.sh)" + echo "cache_key=$(./container_build/generate_buildx_cache_key.sh)" >> $GITHUB_OUTPUT shell: bash - name: Cache Hugo Docker layers diff --git a/build.gradle b/build.gradle index 01f77c51..8507444b 100644 --- a/build.gradle +++ b/build.gradle @@ -9,9 +9,12 @@ buildscript { } plugins { - id "com.github.johnrengelman.shadow" version "8.1.1" apply false + //id "com.github.johnrengelman.shadow" version "8.1.1" apply false + alias(libs.plugins.shadow) apply false //must be applied to all projects including root - id "ca.cutterslade.analyze" version "1.9.1" apply true + //id "ca.cutterslade.analyze" version "1.9.1" apply true + alias(libs.plugins.analyze) apply true + id 'java-platform' } def projectGroup = "event-logging-transformer" @@ -32,19 +35,7 @@ ext.getPropertyOrDefault = { propName, defaultValue -> } ext.versions = [ - //------event-logging-------------- eventLogging: getPropertyOrDefault('version', 'SNAPSHOT'), - - //------------3rd-party------------ - assertj: '3.6.2', - javaDiffUtils: '4.0', - jackson: '2.8.9', - junit: '4.12', - logback: '1.2.3', - saxon: '9.6.0-6', - slf4j: '1.7.22', - systemRules: '1.19.0', - zzDUMMYzz: 'makes sorting easier' ] allprojects { @@ -63,15 +54,24 @@ subprojects { mavenLocal() } + dependencies { + // So deps from the BOM can get the versions + implementation platform(libs.junit.bom) + } + configurations { all { + exclude group: "junit", module: "junit" exclude group: "org.slf4j", module: "slf4j-log4j12" exclude group: "log4j", module: "log4j" exclude group: "commons-logging", module: "commons-logging" resolutionStrategy { dependencySubstitution { - substitute module('log4j:log4j') using module('org.slf4j:log4j-over-slf4j:$versions.slf4j') + + // Ought to be a way to use the libs.slf4j.log4jOverSlf4j alias + substitute module('log4j:log4j') using module("org.slf4j:log4j-over-slf4j:${libs.versions.slf4j}") + //substitute module('log4j:log4j') using alias(libs.slf4j.log4jOverSlf4j) } forcedModules = [ @@ -79,5 +79,5 @@ subprojects { } } } -} +} diff --git a/container_build/docker_pdf/Dockerfile b/container_build/docker_pdf/Dockerfile index e26a1d48..48ad2381 100644 --- a/container_build/docker_pdf/Dockerfile +++ b/container_build/docker_pdf/Dockerfile @@ -1,14 +1,40 @@ -FROM buildkite/puppeteer:10.0.0 +# See this link for details of how this is put together +# https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md +FROM node:20.2.0-buster-slim + +# Comment to change cache key WORKDIR /builder -# Run separately so docker can cache the layer to speed up image re-creation -RUN apt-get update && apt-get install -y \ - curl \ - wait-for-it \ - && echo "installing npm packages" \ - && npm install html2canvas jspdf \ - && mkdir -p /builder/repo +# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) +# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer +# installs, work. +RUN apt-get update \ + && apt-get install -y wget gnupg \ + && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ + && echo "installing apt-get packages" \ + && apt-get update \ + && apt-get install -y \ + curl \ + wait-for-it \ + google-chrome-stable \ + fonts-ipafont-gothic \ + fonts-wqy-zenhei \ + fonts-thai-tlwg \ + fonts-kacst \ + fonts-freefont-ttf \ + libxss1 \ + --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* + +RUN npm init -y \ + && echo "installing npm packages" \ + && npm install \ + puppeteer@20.5.0 \ + html2canvas \ + jspdf \ + && mkdir -p /builder/repo # Pass in the uid/gid of the running user so we can use the same user id # in the container so that any files created can be read outside the @@ -36,11 +62,24 @@ RUN echo "USER_ID: [$USER_ID]" \ && if [ ! -n "${user_name}" ]; then adduser --uid "$USER_ID" --system --shell /bin/false --disabled-password --ingroup "${group_name}" builder; fi \ && if [ ! -n "${user_name}" ]; then user_name="builder"; fi \ && echo "user_name: [$user_name]" \ - && echo "Done" + && mkdir -p "/home/${user_name}/Downloads" \ + && chown -R "${USER_ID}:${GROUP_ID}" "/home/${user_name}" \ + && chown -R "${USER_ID}:${GROUP_ID}" ./node_modules \ + && chown -R "${USER_ID}:${GROUP_ID}" ./package.json \ + && chown -R "${USER_ID}:${GROUP_ID}" ./package-lock.json \ + && echo "Done setting up users/groups" -ENV PATH="${PATH}:/node_modules/.bin" +ENV PATH="${PATH}:/builder/node_modules/.bin" COPY --chown=$USER_ID:$GROUP_ID generate-pdf.js /builder/ USER $USER_ID +# This needs to be run after we switch to user $USER_ID so it can see the locally +# installed chromium. +RUN \ + cd /builder/node_modules/puppeteer \ + && pwd \ + && ls -l \ + && npm install \ + && cd /builder diff --git a/container_build/docker_pdf/generate-pdf.js b/container_build/docker_pdf/generate-pdf.js index 73be1e46..81e29e23 100644 --- a/container_build/docker_pdf/generate-pdf.js +++ b/container_build/docker_pdf/generate-pdf.js @@ -4,11 +4,11 @@ const puppeteer = require('puppeteer'); var args = process.argv.slice(2); var url = args[0] -console.log('Generating pdf for: ', url); +console.log('Generating pdf for url: ', url); (async () => { const browser = await puppeteer.launch({ - headless: true, + headless: "new", // TODO should not be running with no-sandbox really, see // https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#setting-up-chrome-linux-sandbox args: [ @@ -18,10 +18,19 @@ console.log('Generating pdf for: ', url); }); const page = await browser.newPage(); + await page.setDefaultNavigationTimeout(300000); await page.goto(url, { - waitUntil: 'networkidle2', - }); - await page.pdf({ path: 'event-logging-schema-docs.pdf', format: 'a4' }); + waitUntil: 'networkidle2'}); + + // If networkidle2 doesn't work then try + //await page.goto(url, { + //waitUntil: 'domcontentloaded'}); + //await page.waitForSelector('h1'); + + await page.pdf({ + path: 'event-logging-schema-docs.pdf', + format: 'a4', + timeout: 300000 }); await browser.close(); })(); diff --git a/container_build/runInPupeteerDocker.sh b/container_build/runInPupeteerDocker.sh index 85185b59..620a3035 100755 --- a/container_build/runInPupeteerDocker.sh +++ b/container_build/runInPupeteerDocker.sh @@ -52,20 +52,25 @@ docker_login() { clean_up() { echo -e "${GREEN}Stopping schema-hugo-build-env* containers${NC}" + # MacOS doesn't support xargs --no-run-if-empty/-r , so need a hacky + # work around to deal with the case then the ls returns nothing docker container \ ls \ -q \ --filter "name=schema-hugo-build-env*" \ - | xargs -r docker container stop + | xargs -I XxX bash -c '[[ -n "XxX" ]] && docker container stop XxX' + # Seconds sleep 1 echo -e "${GREEN}Deleting schema-hugo-build-env* containers${NC}" + # MacOS doesn't support xargs --no-run-if-empty/-r , so need a hacky + # work around to deal with the case then the ls returns nothing docker container \ ls -a \ -q \ --filter "name=schema-hugo-build-env*" \ - | xargs --no-run-if-empty docker container rm + | xargs -I XxX bash -c '[[ -n "XxX" ]] && docker container rm XxX' remove_network } @@ -150,8 +155,8 @@ wait_for_200_response() { fi n=$(( n + 1 )) - # sleep for one secs - sleep 0.5s + # Seconds + sleep 0.3 done if [ "${were_dots_shown}" = true ]; then @@ -182,8 +187,7 @@ main() { if [ "${bash_cmd}" = "bash" ]; then run_cmd=( "bash" ) - elif [ "${bash_cmd}" = "PDF" ]; then - #run_cmd=( "node" "../generate-pdf.js" "http://site:1313/all-content/" ) + elif [[ "${bash_cmd}" = "PDF" || "${bash_cmd}" = "pdf" ]]; then # Hugo is running in another container so use the service name 'site' as # the host @@ -221,18 +225,32 @@ main() { echo -e "${GREEN}Group ID ${BLUE}${group_id}${NC}" echo -e "${GREEN}Host repo root dir ${BLUE}${host_abs_repo_dir}${NC}" + if ! docker version >/dev/null 2>&1; then + echo -e "${RED}ERROR: Docker is not installed. Please install Docker or Docker Desktop.${NC}" + exit 1 + fi + + if ! docker buildx version >/dev/null 2>&1; then + echo -e "${RED}ERROR: Docker buildx is not installed. Please install it.${NC}" + exit 1 + fi + # So we are not rate limited, login before doing the build as this # will pull images docker_login - if ! docker buildx inspect schema-puppeteer-builder >/dev/null 2>&1; then + buildx_instance="${image_tag}" + + if ! docker buildx inspect "${buildx_instance}" >/dev/null 2>&1; then + echo -e "${GREEN}Creating buildx instance: ${YELLOW}${buildx_instance}${NC}" docker buildx \ create \ - --name schema-puppeteer-builder + --name "${buildx_instance}" fi + docker buildx \ use \ - schema-puppeteer-builder + "${buildx_instance}" # Make a hash of these things and effectively use this as the cache key for # buildx so any change makes it ignore a previous cache. @@ -262,9 +280,12 @@ main() { echo -e "${GREEN}Removing old cache directories${NC}" #ls -1trd "${cache_dir_base}/from_"* + # List all matching dirs + # Remove the last item + # Delete each item ls -1trd "${cache_dir_base}/from_"* \ - | head -n -1 \ - | xargs -d '\n' rm -rf -- + | sed '$d' \ + | xargs rm -rf -- echo -e "${GREEN}Remaining cache directories${NC}" ls -1trd "${cache_dir_base}/from_"* fi @@ -274,6 +295,7 @@ main() { echo -e "${GREEN}Building image ${BLUE}${image_tag}${GREEN}" \ "(this may take a while on first run)${NC}" docker buildx build \ + --progress=plain \ --tag "${image_tag}" \ --build-arg "USER_ID=${user_id}" \ --build-arg "GROUP_ID=${group_id}" \ @@ -314,6 +336,7 @@ main() { --workdir "${dest_dir}" \ --name "schema_puppeteer-build-env" \ --network "hugo-schema" \ + --init \ --env "BUILD_VERSION=${BUILD_VERSION:-SNAPSHOT}" \ --env "DOCKER_USERNAME=${DOCKER_USERNAME}" \ --env "DOCKER_PASSWORD=${DOCKER_PASSWORD}" \ @@ -321,6 +344,19 @@ main() { "${run_cmd[@]}" clean_up + + # Would be nice to use "${bash_cmd,,}" = "pdf" for case insense compare + # but that is bash4, and well, you know, macOS :-( + if [[ "${bash_cmd}" = "PDF" || "${bash_cmd}" = "pdf" ]]; then + pdf_file="${local_repo_root}/event-logging-schema-docs.pdf" + if [[ ! -f "${pdf_file}" ]]; then + echo -e "${RED}ERROR${NC} Can't find PDF file ${pdf_file}." \ + "Has the Puppeteer PDF generation failed?" + exit 1 + fi + fi + + echo -e "${GREEN}Done${NC}" } main "$@" diff --git a/diffAgainstLatestReleases.sh b/diffAgainstLatestReleases.sh index 069bc3d8..4cd52539 100755 --- a/diffAgainstLatestReleases.sh +++ b/diffAgainstLatestReleases.sh @@ -142,9 +142,9 @@ main() { echo -e "Diffing ${BLUE}${localFile}${NC} against ${BLUE}${downloadedFile}${NC}" diffFile="${downloadedFile}.diff" #OR with true to stop the exit code from diff stopping the script - diff "${localFile}" "${downloadedFile}" > "${diffFile}" || true + diff "${downloadedFile}" "${localFile}" > "${diffFile}" || true if [ "$( wc -l < "${diffFile}" )" -gt 0 ]; then - diff "${localFile}" "${downloadedFile}" || true + diff --color "${downloadedFile}" "${localFile}" || true echo -e "\n${RED}Warning${NC}: Local schema ${BLUE}${localFile}${NC} differs from the latest release ${BLUE}${downloadedFile}${NC}" echo -e "This will likely be as intended but serves as a confirmation of what has changed since the latest release" echo -e "(see changes in $PWD/${diffFile})${NC}" diff --git a/event-logging-transformer-main/build.gradle b/event-logging-transformer-main/build.gradle index e1a633e0..8e71beeb 100644 --- a/event-logging-transformer-main/build.gradle +++ b/event-logging-transformer-main/build.gradle @@ -46,20 +46,18 @@ shadowJar { // In this section you declare the dependencies for your production and test code dependencies { + implementation libs.bundles.jackson // The production code uses the SLF4J logging API at compile time - implementation "com.fasterxml.jackson.core:jackson-annotations:$versions.jackson" - implementation "com.fasterxml.jackson.core:jackson-databind:$versions.jackson" - implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$versions.jackson" - implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$versions.jackson" - implementation "org.slf4j:slf4j-api:${versions.slf4j}" - - runtimeOnly "ch.qos.logback:logback-classic:${versions.logback}" - runtimeOnly "net.sf.saxon:Saxon-HE:${versions.saxon}" - - testImplementation "com.github.stefanbirkner:system-rules:${versions.systemRules}" - testImplementation "io.github.java-diff-utils:java-diff-utils:${versions.javaDiffUtils}" - testImplementation "junit:junit:${versions.junit}" - testImplementation "org.assertj:assertj-core:${versions.assertj}" + implementation libs.slf4j.api + + runtimeOnly libs.logback.classic + runtimeOnly libs.saxon + + testImplementation libs.systemLambda + testImplementation libs.javaDiffUtils + testImplementation libs.bundles.basicTest.impl + + testRuntimeOnly libs.bundles.basicTest.runtime } run { @@ -143,6 +141,8 @@ tasks.compileJava.dependsOn validateSchemaVersions def failedTestReportFiles = [] test { + useJUnitPlatform() + // Use full logging for test exceptions so we can see where the failure occurred testLogging { events "failed" @@ -160,6 +160,13 @@ test { failedTestReportFiles.add(pair) } } + + // Use full logging for test exceptions so we can see where the failure occurred + testLogging { + events "failed" + exceptionFormat = 'full' + showStackTraces = true + } } gradle.buildFinished { diff --git a/event-logging-transformer-main/pipelines/configuration.yml b/event-logging-transformer-main/pipelines/configuration.yml index 334341b6..ac78f790 100644 --- a/event-logging-transformer-main/pipelines/configuration.yml +++ b/event-logging-transformer-main/pipelines/configuration.yml @@ -59,6 +59,8 @@ pipelines: - "jaxbEventRoot.xsl" - "jaxbNoEventId.xsl" - "jaxbNoUserDetails.xsl" + # Sharing data is only intended for adding to received events + - "removeSharingElement.xsl" # A varient that imposes limits on the values and occurances intended # for untrusted sources. @@ -70,6 +72,7 @@ pipelines: - "addSafeStringSimpleType.xsl" - "replaceStringWithSafeString.xsl" - "removeMetaElement.xsl" + - "removeSharingElement.xsl" - "removeAnyContentComplexType.xsl" - "limitOccurrence.xsl" - "limitDataElementRecursion.xsl" diff --git a/event-logging-transformer-main/pipelines/transformations/jaxbNoSharing.xsl b/event-logging-transformer-main/pipelines/transformations/removeSharingElement.xsl similarity index 100% rename from event-logging-transformer-main/pipelines/transformations/jaxbNoSharing.xsl rename to event-logging-transformer-main/pipelines/transformations/removeSharingElement.xsl diff --git a/event-logging-transformer-main/src/main/java/event/logging/transformer/SchemaGenerator.java b/event-logging-transformer-main/src/main/java/event/logging/transformer/SchemaGenerator.java index 42e92702..bc707e86 100644 --- a/event-logging-transformer-main/src/main/java/event/logging/transformer/SchemaGenerator.java +++ b/event-logging-transformer-main/src/main/java/event/logging/transformer/SchemaGenerator.java @@ -450,7 +450,7 @@ private void validateSchema(final Path safeSchemaPath) { try { // attempt to construct a schema object from the file. Will fail if our schema // is not a valid w3c XML Schema. This will ensure the transformation chain - //generates a valid schema + // generates a valid schema schemaFactory.newSchema(safeSchemaPath.toFile()); } catch (final SAXException e1) { throw new RuntimeException("Error initialising schema object", e1); diff --git a/event-logging-transformer-main/src/test/java/event/logging/transformer/TestRealPipelines.java b/event-logging-transformer-main/src/test/java/event/logging/transformer/TestRealPipelines.java index 7870b565..b186b76c 100644 --- a/event-logging-transformer-main/src/test/java/event/logging/transformer/TestRealPipelines.java +++ b/event-logging-transformer-main/src/test/java/event/logging/transformer/TestRealPipelines.java @@ -1,8 +1,10 @@ package event.logging.transformer; +import com.github.stefanbirkner.systemlambda.Statement; +import com.github.stefanbirkner.systemlambda.SystemLambda; import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,13 +13,15 @@ import java.nio.file.Path; import java.nio.file.Paths; +import static org.assertj.core.api.Assertions.assertThat; + public class TestRealPipelines { private static final Logger LOGGER = LoggerFactory.getLogger(TestRealPipelines.class); private static final Path GENERATED_PATH = Paths.get("./pipelines/generated"); - @Before + @BeforeEach public void setup() throws IOException { if (Files.exists(GENERATED_PATH)) { @@ -27,10 +31,12 @@ public void setup() throws IOException { } @Test - public void testMain() throws IOException { - SchemaGenerator.main(new String[]{ - "pipelines", - "../event-logging.xsd"}); + public void testMain() throws Exception { + assertExitStatus(0, () -> { + SchemaGenerator.main(new String[]{ + "pipelines", + "../event-logging.xsd"}); + }); //two pipelines in config so should result in 2 files Assertions.assertThat(Files.list(GENERATED_PATH).count()) @@ -44,4 +50,10 @@ public void testMain() throws IOException { .endsWith(".xsd"); }); } -} \ No newline at end of file + + private void assertExitStatus(final int expectedExitStatus, final Statement statement) throws Exception{ + final int exitStatus = SystemLambda.catchSystemExit(statement); + assertThat(exitStatus) + .isEqualTo(expectedExitStatus); + } +} diff --git a/event-logging-transformer-main/src/test/java/event/logging/transformer/TestSchemaGenerator.java b/event-logging-transformer-main/src/test/java/event/logging/transformer/TestSchemaGenerator.java index ce9f565a..4391322e 100644 --- a/event-logging-transformer-main/src/test/java/event/logging/transformer/TestSchemaGenerator.java +++ b/event-logging-transformer-main/src/test/java/event/logging/transformer/TestSchemaGenerator.java @@ -4,10 +4,10 @@ import com.github.difflib.algorithm.DiffException; import com.github.difflib.patch.AbstractDelta; import com.github.difflib.patch.Patch; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.contrib.java.lang.system.ExpectedSystemExit; +import com.github.stefanbirkner.systemlambda.Statement; +import com.github.stefanbirkner.systemlambda.SystemLambda; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,10 +40,7 @@ public class TestSchemaGenerator { TEST_03 ); - @Rule - public final ExpectedSystemExit exit = ExpectedSystemExit.none(); - - @Before + @BeforeEach public void setup() { // Clean out all the generated content @@ -63,58 +60,60 @@ public void setup() { } @Test - public void test01_versionChange() throws IOException { - - exit.expectSystemExitWithStatus(0); - final List generatedFiles = runTest(TEST_01); - - assertThat(generatedFiles) - .hasSize(2); - - String majorVersion = "v7"; - String fullVersion = majorVersion + ".8.9"; - String baseName = "my-new-schema"; - String suffix1 = "-variantOne"; - String suffix2 = "-variantTwo"; - String expectedFile1 = baseName + "-" + majorVersion + suffix1 + ".xsd"; - String expectedFile2 = baseName + "-" + majorVersion + suffix2 + ".xsd"; - String expectedId1 = baseName + "-" + fullVersion + suffix1; - String expectedId2 = baseName + "-" + fullVersion + suffix2; - - assertGeneratedFilenames(generatedFiles, expectedFile1, expectedFile2); - - assertThat(getFileText(generatedFiles.get(0))) - .contains(expectedId1); - assertThat(getFileText(generatedFiles.get(1))) - .contains(expectedId2); + public void test01_versionChange() throws Exception { + + assertExitStatus(0, () -> { + final List generatedFiles = runTest(TEST_01); + + assertThat(generatedFiles) + .hasSize(2); + + String majorVersion = "v7"; + String fullVersion = majorVersion + ".8.9"; + String baseName = "my-new-schema"; + String suffix1 = "-variantOne"; + String suffix2 = "-variantTwo"; + String expectedFile1 = baseName + "-" + majorVersion + suffix1 + ".xsd"; + String expectedFile2 = baseName + "-" + majorVersion + suffix2 + ".xsd"; + String expectedId1 = baseName + "-" + fullVersion + suffix1; + String expectedId2 = baseName + "-" + fullVersion + suffix2; + + assertGeneratedFilenames(generatedFiles, expectedFile1, expectedFile2); + + assertThat(getFileText(generatedFiles.get(0))) + .contains(expectedId1); + assertThat(getFileText(generatedFiles.get(1))) + .contains(expectedId2); + }); } @Test - public void test02_noChanges() throws IOException { + public void test02_noChanges() throws Exception { + assertExitStatus(0, () -> { + List generatedFiles = runTest(TEST_02); - exit.expectSystemExitWithStatus(0); - List generatedFiles = runTest(TEST_02); + assertThat(generatedFiles).hasSize(1); - assertThat(generatedFiles).hasSize(1); - - assertThat(generatedFiles.get(0).getFileName().toString()) - .matches("event-logging-v([0-9]|SNAPSHOT).xsd"); + assertThat(generatedFiles.get(0).getFileName().toString()) + .matches("event-logging-v([0-9]|SNAPSHOT).xsd"); + }); } @Test - public void test03_addRegexSimpleType() throws IOException { + public void test03_addRegexSimpleType() throws Exception { - exit.expectSystemExitWithStatus(0); - List generatedFiles = runTest(TEST_03); + assertExitStatus(0, () -> { + List generatedFiles = runTest(TEST_03); - assertThat(generatedFiles).hasSize(1); + assertThat(generatedFiles).hasSize(1); - assertThat(generatedFiles.get(0).getFileName().toString()) - .matches("event-logging-v([0-9]|SNAPSHOT).xsd"); + assertThat(generatedFiles.get(0).getFileName().toString()) + .matches("event-logging-v([0-9]|SNAPSHOT).xsd"); - // make sure the regex is correct in the generated file - assertThat(getFileText(generatedFiles.get(1))) - .contains("[0-9]{91,99}[A-Z]{3}$"); + // make sure the regex is correct in the generated file + assertThat(getFileText(generatedFiles.get(1))) + .contains("[0-9]{91,99}[A-Z]{3}$"); + }); } private void assertGeneratedFilenames(final List generatedFiles, final String... expectedFileNames) { @@ -205,4 +204,10 @@ private Path getTestCaseDir(final String testCaseName) { private String getFileText(final Path file) throws IOException { return String.join("\n", Files.readAllLines(file)); } + + private void assertExitStatus(final int expectedExitStatus, final Statement statement) throws Exception{ + final int exitStatus = SystemLambda.catchSystemExit(statement); + assertThat(exitStatus) + .isEqualTo(expectedExitStatus); + } } diff --git a/event-logging-transformer-main/src/test/java/event/logging/transformer/configuration/TestConfiguration.java b/event-logging-transformer-main/src/test/java/event/logging/transformer/configuration/TestConfiguration.java index 7537e0fa..260cccc2 100644 --- a/event-logging-transformer-main/src/test/java/event/logging/transformer/configuration/TestConfiguration.java +++ b/event-logging-transformer-main/src/test/java/event/logging/transformer/configuration/TestConfiguration.java @@ -1,6 +1,7 @@ package event.logging.transformer.configuration; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -101,4 +102,4 @@ public void getEffectiveOutputPipelines() { assertThat(effectivePipe5.getTransformations()) .containsExactly("T5.1", "T5.2"); } -} \ No newline at end of file +} diff --git a/event-logging-transformer-main/src/test/java/event/logging/transformer/configuration/TestPipeline.java b/event-logging-transformer-main/src/test/java/event/logging/transformer/configuration/TestPipeline.java index eb115ace..9f0d1196 100644 --- a/event-logging-transformer-main/src/test/java/event/logging/transformer/configuration/TestPipeline.java +++ b/event-logging-transformer-main/src/test/java/event/logging/transformer/configuration/TestPipeline.java @@ -1,11 +1,10 @@ package event.logging.transformer.configuration; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; -import java.util.Optional; public class TestPipeline { @@ -49,4 +48,4 @@ public void merge() { parentTransform2); } -} \ No newline at end of file +} diff --git a/event-logging.xsd b/event-logging.xsd index b8ead37b..db7a26a1 100644 --- a/event-logging.xsd +++ b/event-logging.xsd @@ -30,6 +30,11 @@ The root element that contains multiple Event elements. + + + This element contains data relating to the sharing of a set of events between different systems or organisations. The data contained within this element will confirm to a specification defined outside of this schema. + + A single event that has occurred and been recorded. @@ -49,6 +54,11 @@ The classification for the event. + + + This element contains data relating to the sharing of an event between different systems or organisations. The data contained within this element will confirm to a specification defined outside of this schema. + + This element contains information about the time the event was created. @@ -2906,6 +2916,11 @@ Describes the organisation that owns or has responsibility for the system. + + + An optional element to define the domain that the system exists in. + + The version of the system's software, e.g. 1.3.2 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..cb3b7d3e --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,43 @@ +[versions] +assertj = '3.24.2' +jackson = '2.8.9' +junit = '5.10.0' +logback = '1.2.3' +slf4j = '1.7.36' + +[libraries] +assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" } +jackson-annotations = { module = "com.fasterxml.jackson.core:jackson-annotations", version.ref = "jackson" } +jackson-dataFormatYaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson" } +jackson-dataTypeJdk8 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jdk8", version.ref = "jackson" } +jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" } +javaDiffUtils = "io.github.java-diff-utils:java-diff-utils:4.0" +junit-api = { module = "org.junit.jupiter:junit-jupiter-api" } # BOM controls ver +junit-bom = "org.junit:junit-bom:5.10.0" +junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } # BOM controls ver +junit-launcher = { module = "org.junit.platform:junit-platform-launcher" } # BOM controls ver +logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } +saxon = "net.sf.saxon:Saxon-HE:9.6.0-6" +slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } +slf4j-log4jOverSlf4j = { module = "org.slf4j:log4j-over-slf4j", version.ref = "slf4j" } +systemLambda = "com.github.stefanbirkner:system-lambda:1.2.1" + +[bundles] +basicTest-impl = [ + "assertj-core", + "junit-api", +] +basicTest-runtime = [ + "junit-engine", + "junit-launcher", +] +jackson = [ + "jackson.annotations", + "jackson.dataFormatYaml", + "jackson.dataTypeJdk8", + "jackson.databind", +] + +[plugins] +shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" } +analyze = { id = "ca.cutterslade.analyze", version = "1.9.1" } diff --git a/unreleased_changes/20231012_181714_212__68.md b/unreleased_changes/20231012_181714_212__68.md new file mode 100644 index 00000000..0054636a --- /dev/null +++ b/unreleased_changes/20231012_181714_212__68.md @@ -0,0 +1,24 @@ +* Issue **#68** : Add `` to ``. + + +```sh +# ******************************************************************************** +# Issue title: Add a Security Domain element to the SystemComplexType +# Issue link: https://github.com/gchq/event-logging-schema/issues/68 +# ******************************************************************************** + +# ONLY the top line will be included as a change entry in the CHANGELOG. +# The entry should be in GitHub flavour markdown and should be written on a SINGLE +# line with no hard breaks. You can have multiple change files for a single GitHub issue. +# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than +# 'Fixed nasty bug'. +# +# Examples of acceptable entries are: +# +# +# * Issue **123** : Fix bug with an associated GitHub issue in this repository +# +# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository +# +# * Fix bug with no associated GitHub issue. +``` diff --git a/unreleased_changes/20231013_115655_695__0.md b/unreleased_changes/20231013_115655_695__0.md new file mode 100644 index 00000000..1eb32ba0 --- /dev/null +++ b/unreleased_changes/20231013_115655_695__0.md @@ -0,0 +1,19 @@ +* Add `` element to `` and ``. + + +```sh +# ONLY the top line will be included as a change entry in the CHANGELOG. +# The entry should be in GitHub flavour markdown and should be written on a SINGLE +# line with no hard breaks. You can have multiple change files for a single GitHub issue. +# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than +# 'Fixed nasty bug'. +# +# Examples of acceptable entries are: +# +# +# * Issue **123** : Fix bug with an associated GitHub issue in this repository +# +# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository +# +# * Fix bug with no associated GitHub issue. +```