diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/Root.java b/alfa-service/src/main/java/de/ozgcloud/alfa/Root.java index 297a9b071ea87d278e7d1070d0d3485351d11180..2b115dc2939e728aa9478fbf9253890c511e6327 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/Root.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/Root.java @@ -28,6 +28,8 @@ import java.util.Objects; import org.springframework.boot.info.BuildProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -40,6 +42,9 @@ public class Root { private boolean production; @Getter private String barrierefreiheitUrl; + @Getter + @JsonInclude(JsonInclude.Include.NON_NULL) + private String impressumUrl; public String getVersion() { return Objects.isNull(buildProperties) ? "--" : buildProperties.getVersion(); diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/RootController.java b/alfa-service/src/main/java/de/ozgcloud/alfa/RootController.java index a748d74394fca5db9c12005a0736d1df44ca0113..b23b0bc15e89ec5db0035a2464dbc2c2634bba1d 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/RootController.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/RootController.java @@ -57,6 +57,7 @@ public class RootController { .buildProperties(buildProperties) .production(production) .barrierefreiheitUrl(rootProperties.getBarrierefreiheitUrl()) + .impressumUrl(rootProperties.getImpressumUrl()) .build(); } } \ No newline at end of file diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/RootProperties.java b/alfa-service/src/main/java/de/ozgcloud/alfa/RootProperties.java index f7ee39c56bf930751ee50c5dbce7244f6c00da03..d339fc00329168ff35b4278df716f6e817c4448d 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/RootProperties.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/RootProperties.java @@ -13,8 +13,14 @@ import lombok.Setter; class RootProperties { /** - * URL pointing to the site with information about accessibility (Barrierefreiheit). + * URL pointing to the site with information about accessibility + * (Barrierefreiheit). */ private String barrierefreiheitUrl; + /** + * URL pointing to the impressum. + */ + private String impressumUrl; + } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/RootControllerTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/RootControllerTest.java index d5a33f093432974751ff02c0b0803b5e6cec00dd..61f01af21ec8cc4f5748e60790b36e15211c10b4 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/RootControllerTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/RootControllerTest.java @@ -106,6 +106,22 @@ class RootControllerTest { doRequest().andExpect(jsonPath("$.barrierefreiheitUrl").value(RootTestFactory.BARRIEREFREIHEIT_URL)); } + @SneakyThrows + @Test + void shouldHaveImpressumUrl() { + when(rootProperties.getImpressumUrl()).thenReturn(RootTestFactory.IMPRESSUM_URL); + + doRequest().andExpect(jsonPath("$.impressumUrl").value(RootTestFactory.IMPRESSUM_URL)); + } + + @SneakyThrows + @Test + void shouldNotHaveImpressumUrl() { + when(rootProperties.getImpressumUrl()).thenReturn(null); + + doRequest().andExpect(jsonPath("$.impressumUrl").doesNotHaveJsonPath()); + } + private ResultActions doRequest() throws Exception { return mockMvc.perform(get(RootController.PATH)).andExpect(status().isOk()); } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/RootTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/RootTestFactory.java index 858aa28e9cbf3cf9991ee5e687eec0a0caef9d39..bd8f69db2d3b69a6462967aaa571c6e52ba94bb9 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/RootTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/RootTestFactory.java @@ -23,9 +23,12 @@ */ package de.ozgcloud.alfa; +import com.thedeanda.lorem.LoremIpsum; + public class RootTestFactory { public static final String BARRIEREFREIHEIT_URL = "https://barrierefreiheit.de/"; + public static final String IMPRESSUM_URL = LoremIpsum.getInstance().getUrl(); public static Root create() { return createBuilder().build(); diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml index 6048e63b56257bb1b427aa53470d7733b203bff4..ca99396fb145aef959cab90037aa14d0df91b5ed 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -125,6 +125,10 @@ spec: {{- end }} - name: ozgcloud_barrierefreiheitUrl value: {{ required "ozgcloud.barrierefreiheitUrl muss angegeben sein" (.Values.ozgcloud).barrierefreiheitUrl }} + {{- if (.Values.ozgcloud).impressumUrl }} + - name: ozgcloud_impressumUrl + value: {{ (.Values.ozgcloud).impressumUrl }} + {{- end }} image: "{{ .Values.image.repo }}/{{ .Values.image.name }}:{{ coalesce (.Values.image).tag "latest" }}" imagePullPolicy: Always name: alfa diff --git a/src/test/helm/deployment_defaults_env_test.yaml b/src/test/helm/deployment_defaults_env_test.yaml index 8c1ec32ef046e2ca9b86757199a9957e77eb3bba..fd21432a9058b93a040dfb93d732b8d2ada51b85 100644 --- a/src/test/helm/deployment_defaults_env_test.yaml +++ b/src/test/helm/deployment_defaults_env_test.yaml @@ -236,4 +236,27 @@ tests: - it: should fail without barrierefreiheitUrl asserts: - failedTemplate: - errorMessage: ozgcloud.barrierefreiheitUrl muss angegeben sein \ No newline at end of file + errorMessage: ozgcloud.barrierefreiheitUrl muss angegeben sein + + - it: should set impressumUrl + set: + ozgcloud: + barrierefreiheitUrl: http://barrierefreiheit.test.url + impressumUrl: http://impressum.test.url + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: ozgcloud_impressumUrl + value: http://impressum.test.url + + - it: should not set impressumUrl + set: + ozgcloud: + barrierefreiheitUrl: http://barrierefreiheit.test.url + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: ozgcloud_impressumUrl + any: true