Support "captcha" rename in AnswerChallengeRequest.type

This commit is contained in:
Chris Eager
2024-03-11 14:07:58 -05:00
committed by Chris Eager
parent a4d4a9c686
commit 8574494573
3 changed files with 19 additions and 16 deletions

View File

@@ -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);