mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 18:18:08 +01:00
Fix oneof field validation
This commit is contained in:
committed by
ravi-signal
parent
f5f217f3de
commit
a90fa5db02
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.whispersystems.textsecuregcm.grpc;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
@@ -406,6 +407,22 @@ public class ValidatingInterceptorTest {
|
||||
stub.validationsEndpoint(builderWithValidDefaults().setRecursiveMessage(recursiveMessage).build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneOfValidation() throws Exception {
|
||||
|
||||
// These should pass even if we don't meet the requirements on the one-of case that we're not setting
|
||||
assertDoesNotThrow(() ->
|
||||
stub.validationsEndpoint(builderWithValidDefaults()
|
||||
.setOneOfNonEmptyBytes(ByteString.copyFrom(new byte[1]))
|
||||
.build()));
|
||||
assertDoesNotThrow(() ->
|
||||
stub.validationsEndpoint(builderWithValidDefaults()
|
||||
.setOneOfMessage(ValidationsRequest.RequirePresentMessage.getDefaultInstance())
|
||||
.build()));
|
||||
|
||||
assertStatusException(Status.INVALID_ARGUMENT, () -> stub.validationsEndpoint(ValidationsRequest.newBuilder().setOneOfNonEmptyBytes(ByteString.EMPTY).build()));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static ValidationsRequest.Builder builderWithValidDefaults() {
|
||||
return ValidationsRequest.newBuilder()
|
||||
|
||||
Reference in New Issue
Block a user