diff --git a/.gitignore b/.gitignore index ce0fa6a1d52b0c70e534034c4c61b128c7e087c8..c66fa1701975930fa26e192cb8c7ae3f6e2a7268 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.iml .idea/ dist/ +examples/ # Dependencies node_modules/ @@ -11,3 +12,6 @@ node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* + +examples/ +examples_fail/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 103e554686a3c88d7c1064801e62e735f3797c56..18f30d1846be3b79b766f1929f02405a15c78b31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,7 @@ workflow: stages: - lint + - test - build - upload @@ -61,3 +62,21 @@ upload:release: script: - sed -i "s,SCHEMA_VERSION,$CI_COMMIT_TAG,g" dist/set-payload.schema.json - rsync -Lvz -e "ssh -o CheckHostIP=no" ./dist/set-payload.schema.json fitko@dorado.uberspace.de:schema.fitko.de/fit-connect/set-payload/$CI_COMMIT_TAG/ + +test: + stage: test + image: $CI_REGISTRY/node:current-alpine + before_script: + - yarn + - yarn bundle + script: + - yarn test + +test-failing: + stage: test + image: $CI_REGISTRY/node:current-alpine + before_script: + - yarn + - yarn bundle + script: + - yarn test_higher_version diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..d5107366475dcb53ba1d91c940d7591493d998d5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +<!-- +Types of changes: + - Added: for new features. + - Changed: for changes in existing functionality. + - Deprecated: for soon-to-be removed features. + - Removed: for now removed features. + - Fixed: for any bug fixes. + - Security: in case of vulnerabilities. +--> + +# Event-Payload Changelog + +* The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +* If available, include a ticket number in format `(planning#XXXX)`. + + +## [1.1.0] + +### Changed + + - `$schema` von einem Enum in eine RegEx geändert `(planning#608)` + +## [1.0.0] \ No newline at end of file diff --git a/bundle.sh b/bundle.sh index 05dc6a5c256da8fbf3ec294c1ee159269e89b3e3..fc8503328ed4db77f646457d23df607adf495b4a 100755 --- a/bundle.sh +++ b/bundle.sh @@ -1,7 +1,8 @@ #!/usr/bin/env sh -set -euxo pipefail +# set -euxo pipefail node scripts/bundle.js spec/authentication-tags.schema.json dist/authentication-tags.schema.json node scripts/bundle.js spec/problems.schema.json dist/problems.schema.json node scripts/bundle.js spec/set-payload.schema.json dist/set-payload.schema.json +sh create_examples.sh diff --git a/create_examples.sh b/create_examples.sh new file mode 100755 index 0000000000000000000000000000000000000000..b112e7180ae7c120a2753d687ba20377e8c5b9d2 --- /dev/null +++ b/create_examples.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env sh + +# Create a directory for the examples +rm -rf examples +rm -rf examples_fail +mkdir -p examples +mkdir examples_fail + + +# Run over Templates and create examples +for template in templates/*.json; do + # Get the name of the template + template_name=$(basename $template) + + # Get the name of the example + example_name=${template_name%.template} + + # Create the example + set -- "1.0.0" "1.0.1" "1.0.2" "1.0.11" "1.1.0" "1.5.11" + for version in "$@"; do + cat $template | sed -e "s|SCHEMA_VERSION|$version|g" > ./examples/"$template_name"_"$version".json + done + + set -- "2.0.0" "3.0.1" "2.0.2" "2.0.11" "2.1.0" "3.5.11" + for version in "$@"; do + cat $template | sed -e "s|SCHEMA_VERSION|$version|g" > ./examples_fail/"$template_name"_"$version".json + done + +done diff --git a/package.json b/package.json index e0bd3704a58932d257ef650e4760eca73b156ea2..cf6d42f5f9de1c7fda7af748b1041eb5d1d5e404 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "scripts": { "bundle": "sh bundle.sh", "lint": "ajv compile --spec=draft2020 -c ajv-formats -s dist/set-payload.schema.json", - "test": "ajv validate --errors=text --verbose --all-errors -d examples/**/*.json --spec=draft2020 -c ajv-formats -s dist/set-payload.schema.json" + "test": "ajv validate --errors=text --verbose --all-errors -d examples/**/*.json --spec=draft2020 -c ajv-formats -s dist/set-payload.schema.json", + "test_higher_version": "! ajv validate --errors=text --verbose --all-errors -d examples_fail/**/*.json --spec=draft2020 -c ajv-formats -s dist/set-payload.schema.json" }, "dependencies": { "@apidevtools/json-schema-ref-parser": "9.0.9", diff --git a/spec/set-payload.schema.json b/spec/set-payload.schema.json index f25a66a9071b427820fd20eb1a8bdac7a08f5862..7d6a7662f791284f247355b90846801ce706701d 100644 --- a/spec/set-payload.schema.json +++ b/spec/set-payload.schema.json @@ -8,7 +8,7 @@ "$schema": { "description": "URI des Schemas, dem dieser Security Event Token entspricht. Zulässig sind alle Schema-URLs mit enthaltener Version 1.x.y, wobei x und y beliebige Minor- und Patch-Versionen gemäß https://semver.org/ sein können.", "type": "string", - "pattern": "^https:\\/\\/schema\\.fitko\\.de\\/fit-connect\\/set-payload\\/1\\.\\d+\\.\\d+\\/set-payload\\.schema\\.json$" + "pattern": "^https://schema\\.fitko\\.de/fit-connect/set-payload/1\\.\\d+\\.\\d+/set-payload\\.schema\\.json$" }, "jti": { "description": "Die JWT ID (jti) ist eine eindeutige UUID für das SET.", diff --git a/examples/accept-submission_1.json b/templates/accept-submission_1.json similarity index 100% rename from examples/accept-submission_1.json rename to templates/accept-submission_1.json diff --git a/examples/accept-submission_2.json b/templates/accept-submission_2.json similarity index 100% rename from examples/accept-submission_2.json rename to templates/accept-submission_2.json diff --git a/examples/create-submission_1.json b/templates/create-submission_1.json similarity index 100% rename from examples/create-submission_1.json rename to templates/create-submission_1.json diff --git a/examples/delete-submission_1.json b/templates/delete-submission_1.json similarity index 100% rename from examples/delete-submission_1.json rename to templates/delete-submission_1.json diff --git a/examples/forward-submission_1.json b/templates/forward-submission_1.json similarity index 100% rename from examples/forward-submission_1.json rename to templates/forward-submission_1.json diff --git a/examples/forward-submission_2.json b/templates/forward-submission_2.json similarity index 100% rename from examples/forward-submission_2.json rename to templates/forward-submission_2.json diff --git a/examples/notify-submission_1.json b/templates/notify-submission_1.json similarity index 100% rename from examples/notify-submission_1.json rename to templates/notify-submission_1.json diff --git a/examples/notify-submission_2.json b/templates/notify-submission_2.json similarity index 100% rename from examples/notify-submission_2.json rename to templates/notify-submission_2.json diff --git a/examples/reject-submission_1.json b/templates/reject-submission_1.json similarity index 100% rename from examples/reject-submission_1.json rename to templates/reject-submission_1.json diff --git a/examples/reject-submission_2.json b/templates/reject-submission_2.json similarity index 100% rename from examples/reject-submission_2.json rename to templates/reject-submission_2.json diff --git a/examples/submit-submission_1.json b/templates/submit-submission_1.json similarity index 100% rename from examples/submit-submission_1.json rename to templates/submit-submission_1.json