-
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.
Merge pull request #256 from medizininformatik-initiative/release/4.3.0
Release 4.3.0
- Loading branch information
Showing
12 changed files
with
321 additions
and
31 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
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
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
79 changes: 79 additions & 0 deletions
79
...st/java/de/numcodex/feasibility_gui_backend/query/broker/direct/DirectSpringConfigIT.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,79 @@ | ||
package de.numcodex.feasibility_gui_backend.query.broker.direct; | ||
|
||
import okhttp3.mockwebserver.MockResponse; | ||
import okhttp3.mockwebserver.MockWebServer; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class DirectSpringConfigIT { | ||
|
||
private static final String USERNAME = "some-user-123"; | ||
private static final String PASSWORD = "vALBAi95WW84x3"; | ||
MockWebServer mockWebServer; | ||
|
||
private DirectSpringConfig directSpringConfig; | ||
|
||
@BeforeEach | ||
void setUp() throws IOException { | ||
mockWebServer = new MockWebServer(); | ||
mockWebServer.start(); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() throws IOException { | ||
mockWebServer.shutdown(); | ||
} | ||
|
||
@Test | ||
void testDirectWebClientFlare_withCredentials() throws InterruptedException { | ||
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody("Foo")); | ||
directSpringConfig = new DirectSpringConfig(true, String.format("http://localhost:%s", mockWebServer.getPort()), null, USERNAME, PASSWORD); | ||
var authHeaderValue = "Basic " + Base64.getEncoder().encodeToString((USERNAME + ":" + PASSWORD).getBytes(StandardCharsets.UTF_8)); | ||
|
||
WebClient webClient = directSpringConfig.directWebClientFlare(); | ||
|
||
webClient | ||
.get() | ||
.uri("/foo") | ||
.retrieve() | ||
.bodyToMono(String.class) | ||
.subscribe(responseBody -> { | ||
}) | ||
; | ||
var recordedRequest = mockWebServer.takeRequest(); | ||
assertThat(recordedRequest.getHeader(HttpHeaders.AUTHORIZATION)).isEqualTo(authHeaderValue); | ||
} | ||
|
||
@Test | ||
void testDirectWebClientFlare_withoutCredentials() throws InterruptedException { | ||
mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody("Foo")); | ||
directSpringConfig = new DirectSpringConfig(true, String.format("http://localhost:%s", mockWebServer.getPort()), null, null, null); | ||
|
||
WebClient webClient = directSpringConfig.directWebClientFlare(); | ||
|
||
webClient | ||
.get() | ||
.uri("/foo") | ||
.retrieve() | ||
.bodyToMono(String.class) | ||
.subscribe(responseBody -> { | ||
}) | ||
; | ||
var recordedRequest = mockWebServer.takeRequest(); | ||
assertThat(recordedRequest.getHeader(HttpHeaders.AUTHORIZATION)).isNull(); | ||
} | ||
|
||
} |
Oops, something went wrong.