From a0b85ed6a990e8cf533be4ace3b1fabb5ad14d6f Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 7 Sep 2026 09:23:53 +0200 Subject: feat: fail early on invalid gICS HTTP(S) URI (#316) --- .../processor/consent/GicsConsentServiceTest.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/test/java/dev/dnpm') diff --git a/src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java b/src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java index 1f9e698..90c0734 100644 --- a/src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java +++ b/src/test/java/dev/dnpm/etl/processor/consent/GicsConsentServiceTest.java @@ -22,6 +22,7 @@ package dev.dnpm.etl.processor.consent; import static dev.dnpm.etl.processor.consent.GicsConsentService.IS_CONSENTED_ENDPOINT; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withServerError; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @@ -44,7 +45,10 @@ import org.hl7.fhir.r4.model.OperationOutcome.IssueType; import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.restclient.test.autoconfigure.RestClientTest; import org.springframework.http.MediaType; @@ -257,4 +261,27 @@ class GicsConsentServiceTest { assertThat(fhirJsonParser.encodeToString(actual)).isEqualTo(miiConsent); } + + @Nested + static class WithoutValidConfig { + + @ParameterizedTest + @ValueSource(strings = {"", "mailto:test@example.com", "ftp://localhost"}) + void shouldNotUseGicsConsentServiceWithoutGicsUri(String uri) throws Exception { + final var testConfigProperties = + new GIcsConfigProperties(uri, null, null, "", "", null, "", "", "", "", "", ""); + + final var exception = + assertThrows( + IllegalArgumentException.class, + () -> + new GicsConsentService( + testConfigProperties, + RetryTemplate.builder().maxAttempts(1).build(), + new RestTemplate(), + new AppFhirConfig())); + + assertThat(exception.getMessage()).isEqualTo("gICS URI must be a valid URI in configuration"); + } + } } -- cgit v1.2.3