summaryrefslogtreecommitdiff
path: root/src/integrationTest
diff options
context:
space:
mode:
Diffstat (limited to 'src/integrationTest')
-rw-r--r--src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt20
-rw-r--r--src/integrationTest/kotlin/dev/dnpm/etl/processor/pseudonym/GpasPseudonymGeneratorTest.kt70
2 files changed, 58 insertions, 32 deletions
diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt
index 66b62c8..5e25428 100644
--- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt
+++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/config/AppConfigurationTest.kt
@@ -29,6 +29,7 @@ import dev.dnpm.etl.processor.output.KafkaMtbFileSender
import dev.dnpm.etl.processor.output.RestMtbFileSender
import dev.dnpm.etl.processor.pseudonym.AnonymizingGenerator
import dev.dnpm.etl.processor.pseudonym.GpasPseudonymGenerator
+import dev.dnpm.etl.processor.pseudonym.GpasSoapPseudonymGenerator
import dev.dnpm.etl.processor.security.TokenRepository
import dev.dnpm.etl.processor.security.TokenService
import dev.dnpm.etl.processor.services.RequestProcessor
@@ -201,7 +202,8 @@ class AppConfigurationTest {
@Nested
@TestPropertySource(
properties = [
- "app.pseudonymize.generator=gpas"
+ "app.pseudonymize.generator=gpas",
+ "app.pseudonymize.gpas.uri=http://localhost/"
]
)
inner class AppConfigurationPseudonymizeGeneratorGpasTest(private val context: ApplicationContext) {
@@ -216,6 +218,22 @@ class AppConfigurationTest {
@Nested
@TestPropertySource(
properties = [
+ "app.pseudonymize.generator=gpas",
+ "app.pseudonymize.gpas.soap-endpoint=http://localhost/"
+ ]
+ )
+ inner class AppConfigurationPseudonymizeGeneratorGpasSoapTest(private val context: ApplicationContext) {
+
+ @Test
+ fun shouldUseConfiguredGenerator() {
+ assertThat(context.getBean(GpasSoapPseudonymGenerator::class.java)).isNotNull
+ }
+
+ }
+
+ @Nested
+ @TestPropertySource(
+ properties = [
"app.security.enable-tokens=true"
]
)
diff --git a/src/integrationTest/kotlin/dev/dnpm/etl/processor/pseudonym/GpasPseudonymGeneratorTest.kt b/src/integrationTest/kotlin/dev/dnpm/etl/processor/pseudonym/GpasPseudonymGeneratorTest.kt
index 10f2359..578810e 100644
--- a/src/integrationTest/kotlin/dev/dnpm/etl/processor/pseudonym/GpasPseudonymGeneratorTest.kt
+++ b/src/integrationTest/kotlin/dev/dnpm/etl/processor/pseudonym/GpasPseudonymGeneratorTest.kt
@@ -21,6 +21,7 @@ package dev.dnpm.etl.processor.pseudonym
import dev.dnpm.etl.processor.config.AppFhirConfig
import dev.dnpm.etl.processor.config.GPasConfigProperties
+import org.apache.hc.core5.net.URIBuilder
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
@@ -37,6 +38,7 @@ import org.springframework.test.web.client.response.MockRestResponseCreators.wit
import org.springframework.test.web.client.response.MockRestResponseCreators.withStatus
import org.springframework.web.client.RestTemplate
import java.io.IOException
+import java.net.URI
class GpasPseudonymGeneratorTest {
@@ -49,7 +51,8 @@ class GpasPseudonymGeneratorTest {
fun setup() {
val retryTemplate = RetryTemplateBuilder().customPolicy(SimpleRetryPolicy(1)).build()
val gPasConfigProperties = GPasConfigProperties(
- "https://localhost:9990/ttp-fhir/fhir/gpas",
+ CONFIGURED_URI,
+ null,
null,
"test", "test2",
null,
@@ -64,54 +67,59 @@ class GpasPseudonymGeneratorTest {
@Test
fun shouldReturnExpectedPseudonym() {
- this.mockRestServiceServer.expect {
- method(HttpMethod.POST)
- requestTo("https://localhost/ttp-fhir/fhir/gpas/\$pseudonymizeAllowCreate")
- }.andRespond {
- withStatus(HttpStatus.OK).body(
- getDummyResponseBody(
- "1234",
- "test",
- "test1234ABCDEF567890"
+ this.mockRestServiceServer
+ .expect(method(HttpMethod.POST))
+ .andExpect(requestTo(EXPECTED_URI))
+ .andRespond {
+ withStatus(HttpStatus.OK).body(
+ getDummyResponseBody(
+ "1234",
+ "test",
+ "test1234ABCDEF567890"
+ )
)
- )
- .createResponse(it)
- }
+ .createResponse(it)
+ }
assertThat(this.generator.generate("ID1234")).isEqualTo("test1234ABCDEF567890")
}
@Test
fun shouldThrowExceptionIfGpasNotAvailable() {
- this.mockRestServiceServer.expect {
- method(HttpMethod.POST)
- requestTo("https://localhost/ttp-fhir/fhir/gpas/\$pseudonymizeAllowCreate")
- }.andRespond {
- withException(IOException("Simulated IO error")).createResponse(it)
- }
+ this.mockRestServiceServer
+ .expect(method(HttpMethod.POST))
+ .andExpect(requestTo(EXPECTED_URI))
+ .andRespond {
+ withException(IOException("Simulated IO error")).createResponse(it)
+ }
assertThrows<PseudonymRequestFailed> { this.generator.generate("ID1234") }
}
@Test
fun shouldThrowExceptionIfGpasDoesNotReturn2xxResponse() {
- this.mockRestServiceServer.expect {
- method(HttpMethod.POST)
- requestTo("https://localhost/ttp-fhir/fhir/gpas/\$pseudonymizeAllowCreate")
- }.andRespond {
- withStatus(HttpStatus.FOUND)
- .header(
- HttpHeaders.LOCATION,
- "https://localhost/ttp-fhir/fhir/gpas/\$pseudonymizeAllowCreate"
- )
- .createResponse(it)
- }
+ this.mockRestServiceServer
+ .expect(method(HttpMethod.POST))
+ .andExpect(requestTo(EXPECTED_URI))
+ .andRespond {
+ withStatus(HttpStatus.FOUND)
+ .header(
+ HttpHeaders.LOCATION,
+ $$"https://localhost/ttp-fhir/fhir/gpas/$pseudonymizeAllowCreate"
+ )
+ .createResponse(it)
+ }
assertThrows<PseudonymRequestFailed> { this.generator.generate("ID1234") }
}
companion object {
+ const val CONFIGURED_URI = "https://localhost/ttp-fhir/fhir/gpas"
+
+ val EXPECTED_URI = URIBuilder(URI.create(CONFIGURED_URI)).appendPath($$"$pseudonymizeAllowCreate")
+ .build()!!
+
fun getDummyResponseBody(original: String, target: String, pseudonym: String) = """{
"resourceType": "Parameters",
"parameter": [
@@ -145,4 +153,4 @@ class GpasPseudonymGeneratorTest {
}""".trimIndent()
}
-} \ No newline at end of file
+}