From 1ea81d2bb82cfa2e16853040dcc9f95b32e17509 Mon Sep 17 00:00:00 2001 From: Felix Haller Date: Tue, 18 May 2021 17:46:39 +0200 Subject: [PATCH] add endpoint and mock. refactor localized collections as maps --- .../config/shared/helper/MockHelper.java | 141 ++++++++++++++++++ .../config/shared/model/ConfigResponse.java | 25 ++-- .../config/shared/model/FaqCollection.java | 44 ------ .../backend/config/shared/model/FaqEntry.java | 4 +- .../shared/model/InfoBoxCollection.java | 55 ------- .../backend/config/shared/model/Language.java | 21 +++ .../resources/http/config-verifier-ws.http | 5 + .../test/resources/http/config-wallet-ws.http | 5 + .../test/resources/http/http-client.env.json | 24 ++- .../ws/config/VerifierWsBaseConfig.java | 2 +- .../verifier/ws/config/mock/MockConfig.java | 45 ++++++ .../controller/VerifierConfigController.java | 22 +++ .../resources/application-mock.properties | 10 ++ .../wallet/ws/config/mock/MockConfig.java | 45 ++++++ .../ws/controller/WalletConfigController.java | 22 +++ .../resources/application-mock.properties | 10 ++ 16 files changed, 362 insertions(+), 118 deletions(-) create mode 100644 ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/helper/MockHelper.java delete mode 100644 ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/FaqCollection.java delete mode 100644 ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/InfoBoxCollection.java create mode 100644 ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/Language.java create mode 100644 ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/config/mock/MockConfig.java create mode 100644 ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/resources/application-mock.properties create mode 100644 ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/wallet/ws/config/mock/MockConfig.java create mode 100644 ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/resources/application-mock.properties diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/helper/MockHelper.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/helper/MockHelper.java new file mode 100644 index 0000000..37740ed --- /dev/null +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/helper/MockHelper.java @@ -0,0 +1,141 @@ +package ch.admin.bag.covidcertificate.backend.config.shared.helper; + +import ch.admin.bag.covidcertificate.backend.config.shared.model.Faq; +import ch.admin.bag.covidcertificate.backend.config.shared.model.FaqEntry; +import ch.admin.bag.covidcertificate.backend.config.shared.model.InfoBox; +import ch.admin.bag.covidcertificate.backend.config.shared.model.Language; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MockHelper { + public static Map getWorksMock() { + Map works = new HashMap<>(); + for (Language language : Language.values()) { + Faq faq = new Faq(); + faq.setFaqTitle("Wie funktioniert die App?"); + faq.setFaqSubTitle( + "Hier steht eine kurze Zusammenfassung. Das ist aber erst mal nur Blindtext. Das muss man dann noch ausformulieren und noch ein bisschen."); + faq.setFaqIconIos("ic-how-it-works-image"); + faq.setFaqIconAndroid("ic_how_it_works_image"); + faq.setFaqEntries(getWorksFaqEntriesMock()); + works.put(language, faq); + } + return works; + } + + private static List getWorksFaqEntriesMock() { + return List.of( + getFaqEntryMock("Wie kann ich ein Covid-Zertifikat zur App hinzufügen?"), + getFaqEntryMock("Können auch mehrere Zertifikate hinzugefügt werden?"), + getFaqEntryMock("Wie sehe ich, ob mein Zertifikat gültig ist?"), + getFaqEntryMock("Wie sind meine Daten geschützt?"), + getFaqEntryMock("Welche Daten sind im QR-Code enthalten?")); + } + + private static FaqEntry getFaqEntryMock(String title) { + FaqEntry faqEntry = new FaqEntry(); + faqEntry.setTitle(title); + faqEntry.setText("Hier steht ein Text"); + faqEntry.setIconAndroid(null); + faqEntry.setIconIos(null); + faqEntry.setLinkTitle(null); + faqEntry.setLinkUrl(null); + return faqEntry; + } + + public static Map getQuestionsMock() { + Map questions = new HashMap<>(); + for (Language language : Language.values()) { + Faq faq = new Faq(); + faq.setFaqTitle("Was sind Covid-Zertifikate?"); + faq.setFaqSubTitle( + "Das Covid-Zertifikat ist eine Möglichkeit eine Covid-19-Impfung, eine durchgemachte Erkrankung oder ein negatives Testergebnis fälschungssicher zu dokumentieren."); + faq.setFaqIconIos("ic-faq-image"); + faq.setFaqIconAndroid("ic_faq_image"); + faq.setFaqEntries(getQuestionFaqEntriesMock()); + questions.put(language, faq); + } + return questions; + } + + private static List getQuestionFaqEntriesMock() { + return List.of( + getFaqEntry0Mock(), + getFaqEntry1Mock(), + getFaqEntry2Mock(), + getFaqEntry3Mock(), + getFaqEntry4Mock()); + } + + private static FaqEntry getFaqEntry0Mock() { + FaqEntry faqEntry = new FaqEntry(); + faqEntry.setTitle("Wann und wo kann ich ein Covid-Zertifikat erhalten?"); + faqEntry.setText("Hier steht ein Text"); + faqEntry.setIconAndroid(null); + faqEntry.setIconIos(null); + faqEntry.setLinkTitle(null); + faqEntry.setLinkUrl(null); + return faqEntry; + } + + private static FaqEntry getFaqEntry1Mock() { + FaqEntry faqEntry = new FaqEntry(); + faqEntry.setTitle("Wie kann ich ein Covid-Zertifikat vorweisen?"); + faqEntry.setText("Hier steht ein Text"); + faqEntry.setIconAndroid(null); + faqEntry.setIconIos(null); + faqEntry.setLinkTitle(null); + faqEntry.setLinkUrl(null); + return faqEntry; + } + + private static FaqEntry getFaqEntry2Mock() { + FaqEntry faqEntry = new FaqEntry(); + faqEntry.setTitle("Wo sind meine Daten gespeichert?"); + faqEntry.setText("Hier steht ein Text"); + faqEntry.setIconAndroid(null); + faqEntry.setIconIos(null); + faqEntry.setLinkTitle(null); + faqEntry.setLinkUrl(null); + return faqEntry; + } + + private static FaqEntry getFaqEntry3Mock() { + FaqEntry faqEntry = new FaqEntry(); + faqEntry.setTitle("Wie werden Missbrauch und Fälschung verhindert?"); + faqEntry.setText("Hier steht ein Text"); + faqEntry.setIconAndroid(null); + faqEntry.setIconIos(null); + faqEntry.setLinkTitle(null); + faqEntry.setLinkUrl(null); + return faqEntry; + } + + private static FaqEntry getFaqEntry4Mock() { + FaqEntry faqEntry = new FaqEntry(); + faqEntry.setTitle("Was passiert, wenn ich mein Covid-Zertifikat verliere?"); + faqEntry.setText( + "Ihr Covid-Zertifikat wird in keinem zentralen System gespeichert. Es befindet sich ausschliesslich in Ihrem Besitz. Bewahren Sie das Covid-Zertifikat auf Papier deshalb sorgfältig auf."); + faqEntry.setIconAndroid(null); + faqEntry.setIconIos(null); + faqEntry.setLinkTitle(null); + faqEntry.setLinkUrl(null); + return faqEntry; + } + + public static Map getInfoBoxMock() { + Map infoBoxes = new HashMap<>(); + for (Language language : Language.values()) { + InfoBox infoBox = new InfoBox(); + infoBox.setTitle("Noch keinen Covidcode?"); + infoBox.setMsg( + "Sie wurden positiv getestet (PCR-Test oder Antigen-Schnelltest) und haben nach 4h noch keinen Covidcode erhalten?\nDann kontaktieren Sie die Infoline Coronavirus:"); + infoBox.setUrl("tel:+41583877780"); + infoBox.setUrlTitle("+41 58 387 77 80"); + infoBox.setIsDismissible(false); + infoBoxes.put(language, infoBox); + } + return infoBoxes; + } +} diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/ConfigResponse.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/ConfigResponse.java index 278d703..89c789a 100644 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/ConfigResponse.java +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/ConfigResponse.java @@ -12,6 +12,7 @@ import ch.ubique.openapi.docannotations.Documentation; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.Map; @JsonIgnoreProperties(ignoreUnknown = true) @Documentation(description = "ConfigResponse description") @@ -22,14 +23,14 @@ public class ConfigResponse { "Blocks the app and shows a link to the app-store. The user can only continue once he updated the app") private boolean forceUpdate = false; - @Documentation(description = "Holds a message translated in different languages") - private InfoBoxCollection infoBox = null; + @Documentation(description = "Holds an info box for every language") + private Map infoBox = null; - @Documentation(description = "Holds covid-certificate FAQ parameters") - private FaqCollection questions = null; + @Documentation(description = "Holds covid-certificate FAQ parameters by language") + private Map questions = null; - @Documentation(description = "Holds how-it-works FAQ parameters") - private FaqCollection works = null; + @Documentation(description = "Holds how-it-works FAQ parameters by language") + private Map works = null; public boolean isForceUpdate() { return forceUpdate; @@ -39,27 +40,27 @@ public void setForceUpdate(boolean forceUpdate) { this.forceUpdate = forceUpdate; } - public InfoBoxCollection getInfoBox() { + public Map getInfoBox() { return infoBox; } - public void setInfoBox(InfoBoxCollection infoBox) { + public void setInfoBox(Map infoBox) { this.infoBox = infoBox; } - public FaqCollection getQuestions() { + public Map getQuestions() { return questions; } - public void setQuestions(FaqCollection questions) { + public void setQuestions(Map questions) { this.questions = questions; } - public FaqCollection getWorks() { + public Map getWorks() { return works; } - public void setWorks(FaqCollection works) { + public void setWorks(Map works) { this.works = works; } } diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/FaqCollection.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/FaqCollection.java deleted file mode 100644 index d376865..0000000 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/FaqCollection.java +++ /dev/null @@ -1,44 +0,0 @@ -package ch.admin.bag.covidcertificate.backend.config.shared.model; - -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(value = JsonInclude.Include.NON_NULL) -public class FaqCollection { - - private Faq de; - private Faq en; - private Faq fr; - private Faq it; - - public Faq getDe() { - return de; - } - - public void setDe(Faq de) { - this.de = de; - } - - public Faq getEn() { - return en; - } - - public void setEn(Faq en) { - this.en = en; - } - - public Faq getFr() { - return fr; - } - - public void setFr(Faq fr) { - this.fr = fr; - } - - public Faq getIt() { - return it; - } - - public void setIt(Faq it) { - this.it = it; - } -} diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/FaqEntry.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/FaqEntry.java index 99e8215..11f1264 100644 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/FaqEntry.java +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/FaqEntry.java @@ -14,10 +14,10 @@ public class FaqEntry { private String title; private String text; - private String iconAndroid = ""; - private String iconIos = ""; /* optional */ + private String iconAndroid; + private String iconIos; private String linkTitle; private String linkUrl; diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/InfoBoxCollection.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/InfoBoxCollection.java deleted file mode 100644 index c209683..0000000 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/InfoBoxCollection.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Ubique Innovation AG - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * SPDX-License-Identifier: MPL-2.0 - */ - -package ch.admin.bag.covidcertificate.backend.config.shared.model; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -@JsonInclude(value = Include.NON_NULL) -public class InfoBoxCollection { - - private InfoBox deInfoBox; - private InfoBox frInfoBox; - private InfoBox itInfoBox; - private InfoBox enInfoBox; - - public InfoBox getDeInfoBox() { - return deInfoBox; - } - - public void setDeInfoBox(InfoBox deInfoBox) { - this.deInfoBox = deInfoBox; - } - - public InfoBox getFrInfoBox() { - return frInfoBox; - } - - public void setFrInfoBox(InfoBox frInfoBox) { - this.frInfoBox = frInfoBox; - } - - public InfoBox getItInfoBox() { - return itInfoBox; - } - - public void setItInfoBox(InfoBox itInfoBox) { - this.itInfoBox = itInfoBox; - } - - public InfoBox getEnInfoBox() { - return enInfoBox; - } - - public void setEnInfoBox(InfoBox enInfoBox) { - this.enInfoBox = enInfoBox; - } -} \ No newline at end of file diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/Language.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/Language.java new file mode 100644 index 0000000..5c3b7f6 --- /dev/null +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/main/java/ch/admin/bag/covidcertificate/backend/config/shared/model/Language.java @@ -0,0 +1,21 @@ +package ch.admin.bag.covidcertificate.backend.config.shared.model; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum Language { + DE("de"), + EN("en"), + FR("fr"), + IT("it"); + + private String key; + + Language(String key) { + this.key = key; + } + + @JsonValue + public String getKey() { + return key; + } +} diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/config-verifier-ws.http b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/config-verifier-ws.http index e69de29..069fa62 100644 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/config-verifier-ws.http +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/config-verifier-ws.http @@ -0,0 +1,5 @@ +### config +GET {{verifierBaseUrl}}/v1/verifier/config?appversion={{appversion}}&osversion={{osversion}}&buildnr={{buildnr}} +Accept: application/json + +### \ No newline at end of file diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/config-wallet-ws.http b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/config-wallet-ws.http index e69de29..f01239d 100644 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/config-wallet-ws.http +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/config-wallet-ws.http @@ -0,0 +1,5 @@ +### config +GET {{walletBaseUrl}}/v1/wallet/config?appversion={{appversion}}&osversion={{osversion}}&buildnr={{buildnr}} +Accept: application/json + +### \ No newline at end of file diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/http-client.env.json b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/http-client.env.json index 63922e3..f0c6e8e 100644 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/http-client.env.json +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-shared/src/test/resources/http/http-client.env.json @@ -1,14 +1,30 @@ { "local": { - "baseUrl": "localhost:8080" + "walletBaseUrl": "localhost:8080", + "verifierBaseUrl": "localhost:8081", + "appversion": "ios-1.1.0", + "osversion": "ios14.1", + "buildnr": "ios-210119.1234.123" }, "dev": { - "baseUrl": "TODO" + "walletBaseUrl": "TODO", + "verifierBaseUrl": "TODO", + "appversion": "ios-1.1.0", + "osversion": "ios14.1", + "buildnr": "ios-210119.1234.123" }, "abn": { - "baseUrl": "TODO" + "walletBaseUrl": "TODO", + "verifierBaseUrl": "TODO", + "appversion": "ios-1.1.0", + "osversion": "ios14.1", + "buildnr": "ios-210119.1234.123" }, "prod": { - "baseUrl": "TODO" + "walletBaseUrl": "TODO", + "verifierBaseUrl": "TODO", + "appversion": "ios-1.1.0", + "osversion": "ios14.1", + "buildnr": "ios-210119.1234.123" } } \ No newline at end of file diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/config/VerifierWsBaseConfig.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/config/VerifierWsBaseConfig.java index b67e775..38c7d94 100644 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/config/VerifierWsBaseConfig.java +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/config/VerifierWsBaseConfig.java @@ -19,7 +19,7 @@ public abstract class VerifierWsBaseConfig { @Bean - public VerifierConfigController VerifierConfigController(Messages messages) { + public VerifierConfigController verifierConfigController(Messages messages) { return new VerifierConfigController(messages); } } diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/config/mock/MockConfig.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/config/mock/MockConfig.java new file mode 100644 index 0000000..55a0deb --- /dev/null +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/config/mock/MockConfig.java @@ -0,0 +1,45 @@ +package ch.admin.bag.covidcertificate.backend.config.verifier.ws.config.mock; + +import ch.admin.bag.covidcertificate.backend.config.shared.helper.MockHelper; +import ch.admin.bag.covidcertificate.backend.config.shared.model.ConfigResponse; +import ch.admin.bag.covidcertificate.backend.config.shared.poeditor.Messages; +import ch.admin.bag.covidcertificate.backend.config.verifier.ws.controller.VerifierConfigController; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.http.ResponseEntity; + +@Configuration +@Profile("mock") +public class MockConfig { + + @Bean + @Primary + public VerifierConfigController verifierConfigController(Messages messages) { + return new MockConfigController(messages); + } + + public class MockConfigController extends VerifierConfigController { + + public MockConfigController(Messages messages) { + super(messages); + } + + @Override + public String hello() { + return super.hello() + " (mock)"; + } + + @Override + public ResponseEntity getConfig( + String appversion, String osversion, String buildnr) { + ConfigResponse response = new ConfigResponse(); + response.setForceUpdate(false); + response.setInfoBox(MockHelper.getInfoBoxMock()); + response.setQuestions(MockHelper.getQuestionsMock()); + response.setWorks(MockHelper.getWorksMock()); + return ResponseEntity.ok(response); + } + } +} diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/controller/VerifierConfigController.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/controller/VerifierConfigController.java index 24f3405..f2b0fb1 100644 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/controller/VerifierConfigController.java +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/verifier/ws/controller/VerifierConfigController.java @@ -10,12 +10,15 @@ package ch.admin.bag.covidcertificate.backend.config.verifier.ws.controller; +import ch.admin.bag.covidcertificate.backend.config.shared.model.ConfigResponse; import ch.admin.bag.covidcertificate.backend.config.shared.poeditor.Messages; import ch.ubique.openapi.docannotations.Documentation; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -36,4 +39,23 @@ public VerifierConfigController(Messages messages) { public @ResponseBody String hello() { return "Hello from CH Covidcertificate Config Verifier WS"; } + + @Documentation( + description = + "Read latest configuration and messages, depending on the version of the phone and the app.", + responses = {"200 => ConfigResponse structure with dynamic infos and forceupdate"}) + @CrossOrigin(origins = {"https://editor.swagger.io"}) + @GetMapping(value = "/config") + public @ResponseBody ResponseEntity getConfig( + @Documentation(description = "Version of the App installed", example = "ios-1.0.7") + @RequestParam + String appversion, + @Documentation(description = "Version of the OS", example = "ios13.6") @RequestParam + String osversion, + @Documentation(description = "Build number of the app", example = "ios-200619.2333.175") + @RequestParam + String buildnr) { + ConfigResponse configResponse = new ConfigResponse(); + return ResponseEntity.ok(configResponse); + } } diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/resources/application-mock.properties b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/resources/application-mock.properties new file mode 100644 index 0000000..4b00361 --- /dev/null +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-verifier-ws/src/main/resources/application-mock.properties @@ -0,0 +1,10 @@ +# +# Copyright (c) 2021 Ubique Innovation AG +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. +# +# SPDX-License-Identifier: MPL-2.0 +# +spring.main.allow-bean-definition-overriding=true \ No newline at end of file diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/wallet/ws/config/mock/MockConfig.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/wallet/ws/config/mock/MockConfig.java new file mode 100644 index 0000000..b898126 --- /dev/null +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/wallet/ws/config/mock/MockConfig.java @@ -0,0 +1,45 @@ +package ch.admin.bag.covidcertificate.backend.config.wallet.ws.config.mock; + +import ch.admin.bag.covidcertificate.backend.config.shared.helper.MockHelper; +import ch.admin.bag.covidcertificate.backend.config.shared.model.ConfigResponse; +import ch.admin.bag.covidcertificate.backend.config.shared.poeditor.Messages; +import ch.admin.bag.covidcertificate.backend.config.wallet.ws.controller.WalletConfigController; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.http.ResponseEntity; + +@Configuration +@Profile("mock") +public class MockConfig { + + @Bean + @Primary + public WalletConfigController walletConfigController(Messages messages) { + return new MockConfigController(messages); + } + + public class MockConfigController extends WalletConfigController { + + public MockConfigController(Messages messages) { + super(messages); + } + + @Override + public String hello() { + return super.hello() + " (mock)"; + } + + @Override + public ResponseEntity getConfig( + String appversion, String osversion, String buildnr) { + ConfigResponse response = new ConfigResponse(); + response.setForceUpdate(false); + response.setInfoBox(MockHelper.getInfoBoxMock()); + response.setQuestions(MockHelper.getQuestionsMock()); + response.setWorks(MockHelper.getWorksMock()); + return ResponseEntity.ok(response); + } + } +} diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/wallet/ws/controller/WalletConfigController.java b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/wallet/ws/controller/WalletConfigController.java index a196d2a..b365719 100644 --- a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/wallet/ws/controller/WalletConfigController.java +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/java/ch/admin/bag/covidcertificate/backend/config/wallet/ws/controller/WalletConfigController.java @@ -10,12 +10,15 @@ package ch.admin.bag.covidcertificate.backend.config.wallet.ws.controller; +import ch.admin.bag.covidcertificate.backend.config.shared.model.ConfigResponse; import ch.admin.bag.covidcertificate.backend.config.shared.poeditor.Messages; import ch.ubique.openapi.docannotations.Documentation; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -36,4 +39,23 @@ public WalletConfigController(Messages messages) { public @ResponseBody String hello() { return "Hello from CH Covidcertificate Config Wallet WS"; } + + @Documentation( + description = + "Read latest configuration and messages, depending on the version of the phone and the app.", + responses = {"200 => ConfigResponse structure with dynamic infos and forceupdate"}) + @CrossOrigin(origins = {"https://editor.swagger.io"}) + @GetMapping(value = "/config") + public @ResponseBody ResponseEntity getConfig( + @Documentation(description = "Version of the App installed", example = "ios-1.0.7") + @RequestParam + String appversion, + @Documentation(description = "Version of the OS", example = "ios13.6") @RequestParam + String osversion, + @Documentation(description = "Build number of the app", example = "ios-200619.2333.175") + @RequestParam + String buildnr) { + ConfigResponse configResponse = new ConfigResponse(); + return ResponseEntity.ok(configResponse); + } } diff --git a/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/resources/application-mock.properties b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/resources/application-mock.properties new file mode 100644 index 0000000..4b00361 --- /dev/null +++ b/ch-covidcertificate-backend-config/ch-covidcertificate-backend-config-wallet-ws/src/main/resources/application-mock.properties @@ -0,0 +1,10 @@ +# +# Copyright (c) 2021 Ubique Innovation AG +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. +# +# SPDX-License-Identifier: MPL-2.0 +# +spring.main.allow-bean-definition-overriding=true \ No newline at end of file