Skip to content

Commit

Permalink
Add unit test for test locations. update to latest spring boot 2.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
martinalig committed Dec 16, 2020
1 parent b7b0536 commit 9794d64
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
8 changes: 6 additions & 2 deletions dpppt-config-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
<groupId>org.dpppt.switzerland</groupId>
<artifactId>dpppt-config-backend</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.15-SNAPSHOT</version>
<name>DP3T Config Backend</name>

<properties>
<java-version>11</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot-version>2.2.6.RELEASE</spring-boot-version>
<spring-boot-version>2.3.7.RELEASE</spring-boot-version>
<itCoverageAgent></itCoverageAgent>
<build-helper-maven-plugin.version>1.9.1</build-helper-maven-plugin.version>
</properties>
Expand Down Expand Up @@ -72,6 +72,10 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,13 @@ public class GaenConfigController {
private static final Version APP_VERSION_1_0_9 = new Version("ios-1.0.9");
private static final Version IOS_APP_VERSION_1_1_2 = new Version("ios-1.1.2");

private static final Set<String> ALL_CANTONS_AND_LIECHTENSTEIN = Set.of("canton_graubuenden", "canton_zurich", "canton_berne", "canton_lucerne",
"canton_uri", "canton_schwyz", "canton_obwalden", "canton_nidwalden", "canton_glarus", "canton_zug", "canton_fribourg", "canton_solothurn", "canton_basel_city",
"canton_basel_country", "canton_schaffhausen", "canton_appenzell_ausserrhoden", "canton_appenzell_innerrhoden", "canton_st_gallen", "canton_aargau",
"canton_thurgovia", "canton_ticino", "Waadt", "canton_vaud", "canton_neuchatel", "canton_geneva", "canton_jura", "country_liechtenstein");

private static final Map<String, String> TEST_LOCATIONS = Map.ofEntries(
Map.entry("canton_graubuenden",
"https://www.gr.ch/DE/institutionen/verwaltung/djsg/ga/coronavirus/info/Seiten/Start.aspx"),
Map.entry("canton_zurich", "https://www.zh.ch/de/gesundheit/coronavirus.html"),
Map.entry("canton_berne", "http://www.be.ch/corona"),
Map.entry("canton_lucerne", "https://gesundheit.lu.ch/themen/Humanmedizin/Infektionskrankheiten/Coronavirus"),
Map.entry("canton_lucerne",
"https://gesundheit.lu.ch/themen/Humanmedizin/Infektionskrankheiten/Coronavirus"),
Map.entry("canton_uri", "https://www.ur.ch/themen/2962"),
Map.entry("canton_schwyz",
"https://www.sz.ch/behoerden/information-medien/medienmitteilungen/coronavirus.html/72-416-412-1379-6948"),
Expand All @@ -108,7 +104,8 @@ public class GaenConfigController {
"https://www.gl.ch/verwaltung/finanzen-und-gesundheit/gesundheit/coronavirus.html/4817"),
Map.entry("canton_zug", "https://www.zg.ch/behoerden/gesundheitsdirektion/amt-fuer-gesundheit/corona"),
Map.entry("canton_fribourg", "https://www.fr.ch/de/gesundheit/covid-19/coronavirus-aktuelle-informationen"),
Map.entry("canton_solothurn", "https://corona.so.ch/"), Map.entry("canton_basel_city", "https://www.coronavirus.bs.ch/"),
Map.entry("canton_solothurn", "https://corona.so.ch/"),
Map.entry("canton_basel_city", "https://www.coronavirus.bs.ch/"),
Map.entry("canton_basel_country",
"https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/amt-fur-gesundheit/medizinische-dienste/kantonsarztlicher-dienst/aktuelles"),
Map.entry("canton_schaffhausen",
Expand All @@ -121,7 +118,8 @@ public class GaenConfigController {
Map.entry("canton_aargau", "https://www.ag.ch/de/themen_1/coronavirus_2/coronavirus.jsp"),
Map.entry("canton_thurgovia", "https://www.tg.ch/news/fachdossier-coronavirus.html/10552"),
Map.entry("canton_ticino", "https://www4.ti.ch/dss/dsp/covid19/home/"),
Map.entry("canton_vaud", "https://www.vd.ch/toutes-les-actualites/hotline-et-informations-sur-le-coronavirus/"),
Map.entry("canton_vaud",
"https://www.vd.ch/toutes-les-actualites/hotline-et-informations-sur-le-coronavirus/"),
Map.entry("canton_valais", "https://www.vs.ch/de/web/coronavirus"),
Map.entry("canton_neuchatel",
"https://www.ne.ch/autorites/DFS/SCSP/medecin-cantonal/maladies-vaccinations/Pages/Coronavirus.aspx"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.security.PublicKey;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.dpppt.switzerland.backend.sdk.config.ws.filter.ResponseWrapperFilter;
import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse;
Expand Down Expand Up @@ -325,5 +326,37 @@ public void testiOSInfoBoxWorkaround() throws Exception {
.getResponse();
assertEnterCovidcodeBoxText(result);
}

@Test
public void testTestLocations() throws Exception {
MockHttpServletResponse result =
mockMvc
.perform(
get("/v1/config")
.param("osversion", "ios14.2")
.param("appversion", "ios-1.1.2")
.param("buildnr", "ios-2020.0145asdfa34"))
.andExpect(status().is2xxSuccessful())
.andReturn()
.getResponse();

ConfigResponse resp =
objectMapper.readValue(
result.getContentAsString(Charset.forName("utf-8")), ConfigResponse.class);
// all cantons plus liechtenstein
assertEquals(27, resp.getTestLocations().size());

Set<String> allCantonsAndLiechtenstein = Set.of("canton_graubuenden", "canton_zurich",
"canton_berne", "canton_lucerne", "canton_uri", "canton_schwyz", "canton_obwalden", "canton_nidwalden",
"canton_glarus", "canton_zug", "canton_fribourg", "canton_solothurn", "canton_basel_city",
"canton_basel_country", "canton_schaffhausen", "canton_appenzell_ausserrhoden",
"canton_appenzell_innerrhoden", "canton_st_gallen", "canton_aargau", "canton_thurgovia", "canton_ticino",
"canton_vaud", "canton_valais", "canton_neuchatel", "canton_geneva", "canton_jura", "country_liechtenstein");

// check if all keys are included
for (String key: resp.getTestLocations().keySet()) {
assertTrue("key not found in test locations: " + key, allCantonsAndLiechtenstein.contains(key));
}
}

}

0 comments on commit 9794d64

Please sign in to comment.