mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 00:18:06 +01:00
Strictly enforce ACI service identifier strings have no prefix
This commit is contained in:
committed by
ravi-signal
parent
408b065b9e
commit
3820a231ec
@@ -53,11 +53,12 @@ class AciServiceIdentifierTest {
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
|
||||
assertEquals(uuid, AciServiceIdentifier.valueOf(uuid.toString()).uuid());
|
||||
assertEquals(uuid, AciServiceIdentifier.valueOf("ACI:" + uuid).uuid());
|
||||
assertThrows(IllegalArgumentException.class, () -> AciServiceIdentifier.valueOf("Not a valid UUID"));
|
||||
assertThrows(IllegalArgumentException.class, () -> AciServiceIdentifier.valueOf("PNI:" + uuid));
|
||||
assertThrows(IllegalArgumentException.class, () -> AciServiceIdentifier.valueOf("ACI:" + uuid).uuid());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void fromBytes() {
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
|
||||
@@ -32,12 +32,11 @@ class ServiceIdentifierTest {
|
||||
|
||||
return Stream.of(
|
||||
Arguments.of(uuid.toString(), IdentityType.ACI, uuid),
|
||||
Arguments.of("ACI:" + uuid, IdentityType.ACI, uuid),
|
||||
Arguments.of("PNI:" + uuid, IdentityType.PNI, uuid));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"Not a valid UUID", "BAD:a9edc243-3e93-45d4-95c6-e3a84cd4a254"})
|
||||
@ValueSource(strings = {"Not a valid UUID", "BAD:a9edc243-3e93-45d4-95c6-e3a84cd4a254", "ACI:a9edc243-3e93-45d4-95c6-e3a84cd4a254"})
|
||||
void valueOfIllegalArgument(final String identifierString) {
|
||||
assertThrows(IllegalArgumentException.class, () -> ServiceIdentifier.valueOf(identifierString));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user