mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 00:48:38 +01:00
Return empty lists instead of null in GetCallingRelaysV2
This commit is contained in:
@@ -127,8 +127,8 @@ public class TurnCallRouterTest {
|
||||
TurnServerOptions optionsWithUrls(List<String> urls) {
|
||||
return new TurnServerOptions(
|
||||
TEST_HOSTNAME,
|
||||
urls,
|
||||
EXPECTED_TEST_URLS_WITH_HOSTS
|
||||
Optional.of(urls),
|
||||
Optional.of(EXPECTED_TEST_URLS_WITH_HOSTS)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ public class TurnCallRouterTest {
|
||||
assertThat(router().getRoutingFor(aci, Optional.of(InetAddress.getByName("0.0.0.1")), 10))
|
||||
.isEqualTo(new TurnServerOptions(
|
||||
TEST_HOSTNAME,
|
||||
null,
|
||||
targetedUrls
|
||||
Optional.empty(),
|
||||
Optional.of(targetedUrls)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ public class TurnCallRouterTest {
|
||||
assertThat(router().getRoutingFor(aci, Optional.of(InetAddress.getByName("0.0.0.1")), 10))
|
||||
.isEqualTo(new TurnServerOptions(
|
||||
TEST_HOSTNAME,
|
||||
null,
|
||||
TEST_URLS_WITH_HOSTS
|
||||
Optional.empty(),
|
||||
Optional.of(TEST_URLS_WITH_HOSTS)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -172,8 +172,8 @@ public class TurnCallRouterTest {
|
||||
assertThat(router().getRoutingFor(aci, Optional.of(InetAddress.getByName("0.0.0.1")), 0))
|
||||
.isEqualTo(new TurnServerOptions(
|
||||
TEST_HOSTNAME,
|
||||
null,
|
||||
TEST_URLS_WITH_HOSTS
|
||||
Optional.empty(),
|
||||
Optional.of(TEST_URLS_WITH_HOSTS)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory;
|
||||
@@ -84,8 +85,8 @@ class CallRoutingControllerTest {
|
||||
void testGetTurnEndpointsSuccess() throws UnknownHostException {
|
||||
TurnServerOptions options = new TurnServerOptions(
|
||||
"example.domain.org",
|
||||
List.of("stun:12.34.56.78"),
|
||||
List.of("stun:example.domain.org")
|
||||
Optional.of(List.of("stun:12.34.56.78")),
|
||||
Optional.of(List.of("stun:example.domain.org"))
|
||||
);
|
||||
|
||||
when(turnCallRouter.getRoutingFor(
|
||||
@@ -104,8 +105,8 @@ class CallRoutingControllerTest {
|
||||
assertThat(token.username()).isNotEmpty();
|
||||
assertThat(token.password()).isNotEmpty();
|
||||
assertThat(token.hostname()).isEqualTo(options.hostname());
|
||||
assertThat(token.urlsWithIps()).isEqualTo(options.urlsWithIps());
|
||||
assertThat(token.urls()).isEqualTo(options.urlsWithHostname());
|
||||
assertThat(token.urlsWithIps()).isEqualTo(options.urlsWithIps().get());
|
||||
assertThat(token.urls()).isEqualTo(options.urlsWithHostname().get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ class CallRoutingControllerTest {
|
||||
.thenReturn(true);
|
||||
|
||||
when(cloudflareTurnCredentialsManager.retrieveFromCloudflare()).thenReturn(new TurnToken("ABC", "XYZ",
|
||||
List.of("turn:cloudflare.example.com:3478?transport=udp"), null,
|
||||
List.of("turn:cloudflare.example.com:3478?transport=udp"), Collections.emptyList(),
|
||||
"cf.example.com"));
|
||||
|
||||
try (Response response = resources.getJerseyTest()
|
||||
@@ -129,7 +130,7 @@ class CallRoutingControllerTest {
|
||||
assertThat(token.username()).isEqualTo("ABC");
|
||||
assertThat(token.password()).isEqualTo("XYZ");
|
||||
assertThat(token.hostname()).isEqualTo("cf.example.com");
|
||||
assertThat(token.urlsWithIps()).isNull();
|
||||
assertThat(token.urlsWithIps()).isEmpty();
|
||||
assertThat(token.urls()).isEqualTo(List.of("turn:cloudflare.example.com:3478?transport=udp"));
|
||||
}
|
||||
}
|
||||
@@ -138,8 +139,8 @@ class CallRoutingControllerTest {
|
||||
void testGetTurnEndpointsInvalidIpSuccess() throws UnknownHostException {
|
||||
TurnServerOptions options = new TurnServerOptions(
|
||||
"example.domain.org",
|
||||
List.of(),
|
||||
List.of("stun:example.domain.org")
|
||||
Optional.of(List.of()),
|
||||
Optional.of(List.of("stun:example.domain.org"))
|
||||
);
|
||||
|
||||
when(turnCallRouter.getRoutingFor(
|
||||
@@ -158,8 +159,8 @@ class CallRoutingControllerTest {
|
||||
assertThat(token.username()).isNotEmpty();
|
||||
assertThat(token.password()).isNotEmpty();
|
||||
assertThat(token.hostname()).isEqualTo(options.hostname());
|
||||
assertThat(token.urlsWithIps()).isEqualTo(options.urlsWithIps());
|
||||
assertThat(token.urls()).isEqualTo(options.urlsWithHostname());
|
||||
assertThat(token.urlsWithIps()).isEqualTo(options.urlsWithIps().get());
|
||||
assertThat(token.urls()).isEqualTo(options.urlsWithHostname().get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ class CallRoutingControllerV2Test {
|
||||
private static final String REMOTE_ADDRESS = "123.123.123.1";
|
||||
private static final TurnServerOptions TURN_SERVER_OPTIONS = new TurnServerOptions(
|
||||
"example.domain.org",
|
||||
List.of("stun:12.34.56.78"),
|
||||
List.of("stun:example.domain.org")
|
||||
Optional.of(List.of("stun:12.34.56.78")),
|
||||
Optional.of(List.of("stun:example.domain.org"))
|
||||
);
|
||||
private static final TurnToken CLOUDFLARE_TURN_TOKEN = new TurnToken(
|
||||
"ABC",
|
||||
@@ -129,8 +129,8 @@ class CallRoutingControllerV2Test {
|
||||
assertThat(relays.getFirst().username()).isNotEmpty();
|
||||
assertThat(relays.getFirst().password()).isNotEmpty();
|
||||
assertThat(relays.getFirst().hostname()).isEqualTo(options.hostname());
|
||||
assertThat(relays.getFirst().urlsWithIps()).isEqualTo(options.urlsWithIps());
|
||||
assertThat(relays.getFirst().urls()).isEqualTo(options.urlsWithHostname());
|
||||
assertThat(relays.getFirst().urlsWithIps()).isEqualTo(options.urlsWithIps().get());
|
||||
assertThat(relays.getFirst().urls()).isEqualTo(options.urlsWithHostname().get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ class CallRoutingControllerV2Test {
|
||||
assertThat(token.username()).isNotEmpty();
|
||||
assertThat(token.password()).isNotEmpty();
|
||||
assertThat(token.hostname()).isEqualTo(options.hostname());
|
||||
assertThat(token.urlsWithIps()).isEqualTo(options.urlsWithIps());
|
||||
assertThat(token.urls()).isEqualTo(options.urlsWithHostname());
|
||||
assertThat(token.urlsWithIps()).isEqualTo(options.urlsWithIps().get());
|
||||
assertThat(token.urls()).isEqualTo(options.urlsWithHostname().get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ class CallRoutingControllerV2Test {
|
||||
void testGetRelaysInvalidIpSuccess() throws UnknownHostException {
|
||||
TurnServerOptions options = new TurnServerOptions(
|
||||
"example.domain.org",
|
||||
List.of(),
|
||||
List.of("stun:example.domain.org")
|
||||
Optional.of(List.of()),
|
||||
Optional.of(List.of("stun:example.domain.org"))
|
||||
);
|
||||
|
||||
when(turnCallRouter.getRoutingFor(
|
||||
@@ -192,8 +192,8 @@ class CallRoutingControllerV2Test {
|
||||
assertThat(token.username()).isNotEmpty();
|
||||
assertThat(token.password()).isNotEmpty();
|
||||
assertThat(token.hostname()).isEqualTo(options.hostname());
|
||||
assertThat(token.urlsWithIps()).isEqualTo(options.urlsWithIps());
|
||||
assertThat(token.urls()).isEqualTo(options.urlsWithHostname());
|
||||
assertThat(token.urlsWithIps()).isEqualTo(options.urlsWithIps().get());
|
||||
assertThat(token.urls()).isEqualTo(options.urlsWithHostname().get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user