From 6f128efc6b3b1977bf14938bc73644106a4b9d14 Mon Sep 17 00:00:00 2001 From: Lubos Racansky Date: Thu, 21 Jul 2022 14:47:41 +0200 Subject: [PATCH] Add WireMock --- .../README.md | 19 ++++++ .../bin/wiremock.sh | 10 +++ .../pom.xml | 64 +++++++++++++++++++ .../__files/body-client-evaluate.json | 8 +++ .../__files/body-consent-storage.json | 1 + .../wiremock/__files/body-consent-text.json | 3 + .../test/wiremock/__files/body-otp-send.json | 3 + .../wiremock/__files/body-user-lookup.json | 4 ++ .../wiremock/mappings/client-evaluate.json | 10 +++ .../wiremock/mappings/consent-storage.json | 10 +++ .../test/wiremock/mappings/consent-text.json | 10 +++ .../src/test/wiremock/mappings/otp-send.json | 10 +++ .../test/wiremock/mappings/user-lookup.json | 10 +++ pom.xml | 1 + 14 files changed, 163 insertions(+) create mode 100644 enrollment-server-onboarding-adapter-mock/README.md create mode 100755 enrollment-server-onboarding-adapter-mock/bin/wiremock.sh create mode 100644 enrollment-server-onboarding-adapter-mock/pom.xml create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-client-evaluate.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-consent-storage.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-consent-text.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-otp-send.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-user-lookup.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/client-evaluate.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/consent-storage.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/consent-text.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/otp-send.json create mode 100644 enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/user-lookup.json diff --git a/enrollment-server-onboarding-adapter-mock/README.md b/enrollment-server-onboarding-adapter-mock/README.md new file mode 100644 index 000000000..e0d4c6b7c --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/README.md @@ -0,0 +1,19 @@ +# Onboarding Adapter Mock + +Mock of onboarding adapter using [WireMock]. + +## Run + +**NOTE**: Before the first usage of the standalone [WireMock] please execute the following command: + +```bash +mvn clean package +``` + +You can start [WireMock] using the predefined script: + +```bash +./bin/wiremock.sh +``` + +[WireMock]: https://wiremock.org/docs/) diff --git a/enrollment-server-onboarding-adapter-mock/bin/wiremock.sh b/enrollment-server-onboarding-adapter-mock/bin/wiremock.sh new file mode 100755 index 000000000..9d7780d18 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/bin/wiremock.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +mydir=`dirname $0` +cd $mydir/.. + +java -jar target/dependency/wiremock-jre8-standalone.jar \ + --port 8090 \ + --root-dir "src/test/wiremock" \ + --verbose \ + --global-response-templating diff --git a/enrollment-server-onboarding-adapter-mock/pom.xml b/enrollment-server-onboarding-adapter-mock/pom.xml new file mode 100644 index 000000000..0171516d3 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/pom.xml @@ -0,0 +1,64 @@ + + + + + 4.0.0 + + + com.wultra.security + enrollment-server-parent + 1.4.0-SNAPSHOT + + + enrollment-server-onboarding-adapter-mock + enrollment-server-onboarding-adapter-mock + Onboarding adapter mock for enrollment server. + + + 2.33.2 + + + + + + maven-dependency-plugin + + + copy-wiremock + + copy + + + + + + + com.github.tomakehurst + wiremock-jre8-standalone + ${wiremock.version} + + + true + + + + + + diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-client-evaluate.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-client-evaluate.json new file mode 100644 index 000000000..9c9144eac --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-client-evaluate.json @@ -0,0 +1,8 @@ +{ + "result": "OK", + "info": { + "aggregationResult": true, + "mdcCheck": true, + "documentsAccepted": true + } +} \ No newline at end of file diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-consent-storage.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-consent-storage.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-consent-storage.json @@ -0,0 +1 @@ +{} diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-consent-text.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-consent-text.json new file mode 100644 index 000000000..a523c2e22 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-consent-text.json @@ -0,0 +1,3 @@ +{ + "consentText": "

Lorem ipsum

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam posuere lacus quis dolor. Nullam feugiat, turpis at pulvinar vulputate, erat libero tristique tellus, nec bibendum odio risus sit amet ante. Nullam at arcu a est sollicitudin euismod. Aliquam in lorem sit amet leo accumsan lacinia. Duis condimentum augue id magna semper rutrum. Sed convallis magna eu sem. Pellentesque arcu. Phasellus faucibus molestie nisl. Maecenas fermentum, sem in pharetra pellentesque, velit turpis volutpat ante, in pharetra metus odio a lectus. Nullam feugiat, turpis at pulvinar vulputate, erat libero tristique tellus, nec bibendum odio risus sit amet ante. Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?" +} diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-otp-send.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-otp-send.json new file mode 100644 index 000000000..a68e82120 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-otp-send.json @@ -0,0 +1,3 @@ +{ + "otpSent": true +} diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-user-lookup.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-user-lookup.json new file mode 100644 index 000000000..45cb383b1 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/__files/body-user-lookup.json @@ -0,0 +1,4 @@ +{ + "userId": "mockuser_{{jsonPath request.body '$.identification.clientNumber'}}", + "consentRequired": true +} diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/client-evaluate.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/client-evaluate.json new file mode 100644 index 000000000..760197fc0 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/client-evaluate.json @@ -0,0 +1,10 @@ +{ + "request": { + "method": "POST", + "url": "/client/evaluate" + }, + "response": { + "status": 200, + "bodyFileName": "body-client-evaluate.json" + } +} diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/consent-storage.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/consent-storage.json new file mode 100644 index 000000000..c1b9e96ce --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/consent-storage.json @@ -0,0 +1,10 @@ +{ + "request": { + "method": "POST", + "url": "/consent/storage" + }, + "response": { + "status": 200, + "bodyFileName": "body-consent-storage.json" + } +} diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/consent-text.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/consent-text.json new file mode 100644 index 000000000..ba72e4d24 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/consent-text.json @@ -0,0 +1,10 @@ +{ + "request": { + "method": "POST", + "url": "/consent/text" + }, + "response": { + "status": 200, + "bodyFileName": "body-consent-text.json" + } +} diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/otp-send.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/otp-send.json new file mode 100644 index 000000000..e7403a611 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/otp-send.json @@ -0,0 +1,10 @@ +{ + "request": { + "method": "POST", + "url": "/otp/send" + }, + "response": { + "status": 200, + "bodyFileName": "body-otp-send.json" + } +} diff --git a/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/user-lookup.json b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/user-lookup.json new file mode 100644 index 000000000..40f64f635 --- /dev/null +++ b/enrollment-server-onboarding-adapter-mock/src/test/wiremock/mappings/user-lookup.json @@ -0,0 +1,10 @@ +{ + "request": { + "method": "POST", + "url": "/user/lookup" + }, + "response": { + "status": 200, + "bodyFileName": "body-user-lookup.json" + } +} diff --git a/pom.xml b/pom.xml index cd1d47aba..22efd44aa 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,7 @@ enrollment-server-api-model enrollment-server enrollment-server-onboarding + enrollment-server-onboarding-adapter-mock enrollment-server-onboarding-api-model enrollment-server-onboarding-common