mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 11:46:53 +00:00
Don't try to decode null session IDs
This commit is contained in:
1 parent
52b4e0b87f
commit
de5cb3370d
4 files changed
+27
-11
No files matched your search
+7
-3
@@ -59,6 +59,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.signal.libsignal.protocol.IdentityKey;
|
||||
@@ -151,8 +152,11 @@ class AccountControllerV2Test {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void changeNumberSuccess() throws Exception {
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {true, false})
|
||||
void changeNumberSuccess(final boolean useSessionVerification) throws Exception {
|
||||
@Nullable final String sessionId = useSessionVerification ? encodeSessionId("session") : null;
|
||||
@Nullable final byte[] recoveryPassword = useSessionVerification ? null : "recovery-password".getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
final AccountIdentityResponse accountIdentityResponse =
|
||||
resources.getJerseyTest()
|
||||
@@ -161,7 +165,7 @@ class AccountControllerV2Test {
|
||||
.header(HttpHeaders.AUTHORIZATION,
|
||||
AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||
.put(Entity.entity(
|
||||
new ChangeNumberRequest(encodeSessionId("session"), null, NEW_NUMBER, "123", IDENTITY_KEY,
|
||||
new ChangeNumberRequest(sessionId, recoveryPassword, NEW_NUMBER, "123", IDENTITY_KEY,
|
||||
Collections.emptyList(),
|
||||
Map.of(Device.PRIMARY_ID, KeysHelper.signedECPreKey(1, IDENTITY_KEY_PAIR)),
|
||||
Map.of(Device.PRIMARY_ID, KeysHelper.signedKEMPreKey(2, IDENTITY_KEY_PAIR)),
|
||||
|
||||
+13
-6
@@ -369,8 +369,9 @@ class RegistrationControllerTest {
|
||||
}
|
||||
|
||||
// this is functionally the same as deviceTransferAvailable(existingAccount=false)
|
||||
@Test
|
||||
void registrationSuccess() throws Exception {
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {true, false})
|
||||
void registrationSuccess(final boolean useSessionVerification) throws Exception {
|
||||
final Account account = mock(Account.class);
|
||||
when(account.getPrimaryDevice()).thenReturn(mock(Device.class));
|
||||
|
||||
@@ -382,13 +383,19 @@ class RegistrationControllerTest {
|
||||
.request()
|
||||
.header(HttpHeaders.AUTHORIZATION, AuthHelper.getProvisioningAuthHeader(NUMBER, PASSWORD));
|
||||
|
||||
try (Response response = request.post(Entity.json(requestJson("sessionId")))) {
|
||||
final String requestJson = useSessionVerification
|
||||
? requestJson("sessionId")
|
||||
: requestJsonRecoveryPassword("recovery-password".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
try (Response response = request.post(Entity.json(requestJson))) {
|
||||
assertEquals(200, response.getStatus());
|
||||
}
|
||||
|
||||
verify(registrationFraudChecker)
|
||||
.handleVerificationCompleted(Base64.getEncoder().encodeToString("sessionId".getBytes(StandardCharsets.UTF_8)),
|
||||
account);
|
||||
if (useSessionVerification) {
|
||||
verify(registrationFraudChecker)
|
||||
.handleVerificationCompleted(Base64.getEncoder().encodeToString("sessionId".getBytes(StandardCharsets.UTF_8)),
|
||||
account);
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
Reference in new issue
Block a user