Skip to content

Commit

Permalink
chore(tests): Fix race condition in ProxyHandler tests (#4008)
Browse files Browse the repository at this point in the history
  • Loading branch information
ztefanie authored Feb 17, 2025
1 parent d3708e7 commit fa92d98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private Optional<ProxyDetails> getConfigFromSystemProperties(String protocol) {
true));
} catch (NumberFormatException e) {
throw new ConnectorInputException(
"Invalid proxy port in system properties", e); // TODO add protocol
"Invalid proxy port in system properties for " + protocol, e);
}
}
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.hc.client5.http.impl.routing.DefaultProxyRoutePlanner;
import org.apache.hc.client5.http.impl.routing.SystemDefaultRoutePlanner;
import org.apache.hc.core5.http.HttpHost;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
Expand All @@ -54,6 +55,17 @@ public void setUp() {

@Nested
class LoadProxyConfigTests {
@AfterEach
public void unsetAllSystemProperties() {
System.setProperty("http.proxyHost", "");
System.setProperty("http.proxyPort", "");
System.setProperty("http.nonProxyHosts", "");
System.setProperty("https.proxyHost", "");
System.setProperty("https.proxyPort", "");
System.setProperty("https.nonProxyHosts", "");
System.setProperty("http.proxyUser", "");
System.setProperty("http.proxyPassword", "");
}

@Test
public void shouldUseCorrectProtocol_whenMultipleProtocolsSet() {
Expand Down Expand Up @@ -110,16 +122,16 @@ private static Stream<Arguments> provideNonProxyHostTestData() {
Arguments.of("www.camunda.de", "www.camunda.de", true),
Arguments.of("www.example.de", "www.camunda.de", false),
Arguments.of("www.example.de|www.camunda.de", "www.camunda.io", false),
Arguments.of("example.de", "www.example.de", true), // sollte auch Subdomains matchen
Arguments.of("example.de", "www.example.de", true),
Arguments.of("example.de", "api.example.de", true),
Arguments.of("example.de", "another.example.de", true),
Arguments.of("example.de", "example.com", false), // andere Domain
Arguments.of("example.de", "example.com", false),
Arguments.of("example.de|camunda.de", "www.example.de", true),
Arguments.of("example.de|camunda.de", "www.camunda.de", true),
Arguments.of("example.de|camunda.de", "www.google.de", false),
Arguments.of("*.example.de", "api.example.de", true),
Arguments.of("*.example.de", "www.example.de", true),
Arguments.of("*.example.de", "example.de", false), // Wildcard greift nur auf Subdomains
Arguments.of("*.example.de", "example.de", false),
Arguments.of("*.example.de", "example.com", false),
Arguments.of("*.example.de|*.camunda.io", "sub.example.de", true),
Arguments.of("*.example.de|*.camunda.io", "api.camunda.io", true),
Expand Down

0 comments on commit fa92d98

Please sign in to comment.