-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable Logging of Requests by DSF Webservice Client
Add environment variable to enable request logging if needed.
- Loading branch information
Showing
5 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...va/de/numcodex/feasibility_gui_backend/query/broker/dsf/DSFFhirWebClientProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package de.numcodex.feasibility_gui_backend.query.broker.dsf; | ||
|
||
import ca.uhn.fhir.context.FhirContext; | ||
import dev.dsf.fhir.client.FhirWebserviceClient; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.boot.test.system.CapturedOutput; | ||
import org.springframework.boot.test.system.OutputCaptureExtension; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.Network; | ||
import org.testcontainers.junit.jupiter.Container; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
import static java.lang.String.format; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@Testcontainers | ||
@ExtendWith(OutputCaptureExtension.class) | ||
public class DSFFhirWebClientProviderTest { | ||
|
||
@Container | ||
private GenericContainer<?> blaze = new GenericContainer<>("samply/blaze:0.23.3") | ||
.withExposedPorts(8080) | ||
.withNetwork(Network.newNetwork()) | ||
.withReuse(true); | ||
|
||
@Test | ||
void settingLogRequestsFlagToTrueEnablesRequestLogs(CapturedOutput output) throws Exception { | ||
String webserviceBaseUrl = format("http://%s:%s/fhir", blaze.getHost(), blaze.getFirstMappedPort()); | ||
String websocketBaseUrl = format("ws://%s:%s/fhir", blaze.getHost(), blaze.getFirstMappedPort()); | ||
FhirSecurityContextProvider securityContextProvider = () -> new FhirSecurityContext(null, null, null); | ||
FhirProxyContext proxyContext = new FhirProxyContext(null, null, null); | ||
DSFFhirWebClientProvider clientProvider = new DSFFhirWebClientProvider(FhirContext.forR4(), webserviceBaseUrl, | ||
20000, 2000, websocketBaseUrl, securityContextProvider, proxyContext, true); | ||
FhirWebserviceClient client = clientProvider.provideFhirWebserviceClient(); | ||
|
||
client.getConformance(); | ||
|
||
assertThat(output) | ||
.containsIgnoringCase("sending client request") | ||
.containsIgnoringCase("client response received"); | ||
} | ||
|
||
@Test | ||
void settingLogRequestsFlagToFalseDisablesRequestLogs(CapturedOutput output) throws Exception { | ||
String webserviceBaseUrl = format("http://%s:%s/fhir", blaze.getHost(), blaze.getFirstMappedPort()); | ||
String websocketBaseUrl = format("ws://%s:%s/fhir", blaze.getHost(), blaze.getFirstMappedPort()); | ||
FhirSecurityContextProvider securityContextProvider = () -> new FhirSecurityContext(null, null, null); | ||
FhirProxyContext proxyContext = new FhirProxyContext(null, null, null); | ||
DSFFhirWebClientProvider clientProvider = new DSFFhirWebClientProvider(FhirContext.forR4(), webserviceBaseUrl, | ||
20000, 2000, websocketBaseUrl, securityContextProvider, proxyContext, false); | ||
FhirWebserviceClient client = clientProvider.provideFhirWebserviceClient(); | ||
|
||
client.getConformance(); | ||
|
||
assertThat(output) | ||
.doesNotContainIgnoringCase("sending client request") | ||
.doesNotContainIgnoringCase("client response received"); | ||
} | ||
|
||
} |