mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 20:18:05 +01:00
Support "captcha" rename in AnswerChallengeRequest.type
This commit is contained in:
@@ -11,13 +11,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.whispersystems.textsecuregcm.util.SystemMapper;
|
||||
|
||||
class AnswerChallengeRequestTest {
|
||||
|
||||
@Test
|
||||
void parse() throws JsonProcessingException {
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"captcha", "recaptcha"})
|
||||
void parse(final String type) throws JsonProcessingException {
|
||||
{
|
||||
final String pushChallengeJson = """
|
||||
{
|
||||
@@ -35,16 +37,16 @@ class AnswerChallengeRequestTest {
|
||||
}
|
||||
|
||||
{
|
||||
final String recaptchaChallengeJson = """
|
||||
final String captchaChallengeJson = """
|
||||
{
|
||||
"type": "recaptcha",
|
||||
"type": "%s",
|
||||
"token": "A server-generated token",
|
||||
"captcha": "The value of the solved captcha token"
|
||||
}
|
||||
""";
|
||||
""".formatted(type);
|
||||
|
||||
final AnswerChallengeRequest answerChallengeRequest =
|
||||
SystemMapper.jsonMapper().readValue(recaptchaChallengeJson, AnswerChallengeRequest.class);
|
||||
SystemMapper.jsonMapper().readValue(captchaChallengeJson, AnswerChallengeRequest.class);
|
||||
|
||||
assertTrue(answerChallengeRequest instanceof AnswerRecaptchaChallengeRequest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user