mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 10:17:59 +01:00
Remove transitional and legacy client
This commit is contained in:
@@ -19,6 +19,8 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
class EnterpriseRecaptchaClientTest {
|
||||
|
||||
private static final String PREFIX = EnterpriseRecaptchaClient.V2_PREFIX.substring(0,
|
||||
EnterpriseRecaptchaClient.V2_PREFIX.lastIndexOf(SEPARATOR));
|
||||
private static final String SITE_KEY = "site-key";
|
||||
private static final String TOKEN = "some-token";
|
||||
|
||||
@@ -57,6 +59,21 @@ class EnterpriseRecaptchaClientTest {
|
||||
String.join(SEPARATOR, SITE_KEY, "an-action", TOKEN, "something-else"),
|
||||
TOKEN + SEPARATOR + "something-else",
|
||||
SITE_KEY,
|
||||
"an-action"),
|
||||
Arguments.of(
|
||||
String.join(SEPARATOR, PREFIX, SITE_KEY, TOKEN),
|
||||
TOKEN,
|
||||
SITE_KEY,
|
||||
null),
|
||||
Arguments.of(
|
||||
String.join(SEPARATOR, PREFIX, SITE_KEY, "an-action", TOKEN),
|
||||
TOKEN,
|
||||
SITE_KEY,
|
||||
"an-action"),
|
||||
Arguments.of(
|
||||
String.join(SEPARATOR, PREFIX, SITE_KEY, "an-action", TOKEN, "something-else"),
|
||||
TOKEN + SEPARATOR + "something-else",
|
||||
SITE_KEY,
|
||||
"an-action")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.whispersystems.textsecuregcm.recaptcha;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.whispersystems.textsecuregcm.recaptcha.EnterpriseRecaptchaClient.SEPARATOR;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
class TransitionalRecaptchaClientTest {
|
||||
|
||||
private TransitionalRecaptchaClient transitionalRecaptchaClient;
|
||||
private EnterpriseRecaptchaClient enterpriseRecaptchaClient;
|
||||
private LegacyRecaptchaClient legacyRecaptchaClient;
|
||||
|
||||
private static final String PREFIX = TransitionalRecaptchaClient.V2_PREFIX.substring(0,
|
||||
TransitionalRecaptchaClient.V2_PREFIX.lastIndexOf(SEPARATOR));
|
||||
private static final String TOKEN = "some-token";
|
||||
private static final String IP_ADDRESS = "127.0.0.1";
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
enterpriseRecaptchaClient = mock(EnterpriseRecaptchaClient.class);
|
||||
legacyRecaptchaClient = mock(LegacyRecaptchaClient.class);
|
||||
transitionalRecaptchaClient = new TransitionalRecaptchaClient(legacyRecaptchaClient, enterpriseRecaptchaClient);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
void testVerify(final String inputToken, final boolean expectLegacy, final String expectedToken) {
|
||||
|
||||
transitionalRecaptchaClient.verify(inputToken, IP_ADDRESS);
|
||||
|
||||
if (expectLegacy) {
|
||||
verifyNoInteractions(enterpriseRecaptchaClient);
|
||||
verify(legacyRecaptchaClient).verify(expectedToken, IP_ADDRESS);
|
||||
} else {
|
||||
verifyNoInteractions(legacyRecaptchaClient);
|
||||
verify(enterpriseRecaptchaClient).verify(expectedToken, IP_ADDRESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Stream<Arguments> testVerify() {
|
||||
return Stream.of(
|
||||
Arguments.of(
|
||||
TOKEN,
|
||||
true,
|
||||
TOKEN),
|
||||
Arguments.of(
|
||||
String.join(SEPARATOR, PREFIX, TOKEN),
|
||||
false,
|
||||
TOKEN),
|
||||
Arguments.of(
|
||||
String.join(SEPARATOR, PREFIX, "site-key", "an-action", TOKEN),
|
||||
false,
|
||||
String.join(SEPARATOR, "site-key", "an-action", TOKEN),
|
||||
"an-action"),
|
||||
Arguments.of(
|
||||
String.join(SEPARATOR, PREFIX, "site-key", "an-action", TOKEN, "something-else"),
|
||||
false,
|
||||
"site-key" + SEPARATOR + "an-action" + SEPARATOR + TOKEN + SEPARATOR + "something-else")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user