-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
service/src/test/java/org/whispersystems/textsecuregcm/captcha/HCaptchaResponseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2024 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
package org.whispersystems.textsecuregcm.captcha; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.whispersystems.textsecuregcm.util.SystemMapper; | ||
|
||
class HCaptchaResponseTest { | ||
|
||
@Test | ||
void testParse() throws Exception { | ||
|
||
final Instant challengeTs = Instant.parse("2024-09-13T21:36:15Z"); | ||
|
||
final HCaptchaResponse response = | ||
SystemMapper.jsonMapper().readValue(""" | ||
{ | ||
"success": "true", | ||
"challenge_ts": "2024-09-13T21:36:15.000000Z", | ||
"hostname": "example.com", | ||
"error-codes": ["one", "two"], | ||
"score": 0.5, | ||
"score_reason": ["three", "four"] | ||
} | ||
""", HCaptchaResponse.class); | ||
|
||
assertEquals(challengeTs, response.challengeTs); | ||
assertEquals(List.of("one", "two"), response.errorCodes); | ||
assertEquals(List.of("three", "four"), response.scoreReasons); | ||
} | ||
|
||
} |