Accept any length group link password.

This commit is contained in:
Alan Evans
2020-08-20 15:03:03 -03:00
committed by Alex Hart
parent 878b0c9275
commit ffcb90da52
4 changed files with 8 additions and 30 deletions

View File

@@ -33,7 +33,11 @@ public final class GroupInviteLinkUrlTest {
givenGroup().withMasterKey("00f7e0c2a71ab064cc3ced4c04f08d7b7ef4b84b2c2206f69833be6cfe34df80")
.andPassword("9bc324eec437cfda6ae5b8aefbf47ee8")
.expectUrl("https://signal.group/#CjQKIAD34MKnGrBkzDztTATwjXt-9LhLLCIG9pgzvmz-NN-AEhCbwyTuxDfP2mrluK779H7o")
.expectUrl("https://signal.group/#CjQKIAD34MKnGrBkzDztTATwjXt-9LhLLCIG9pgzvmz-NN-AEhCbwyTuxDfP2mrluK779H7o"),
givenGroup().withMasterKey("00f7e0c2a71ab064cc3ced4c04f08d7b7ef4b84b2c2206f69833be6cfe34df80")
.andPassword("9b")
.expectUrl("https://signal.group/#CiUKIAD34MKnGrBkzDztTATwjXt-9LhLLCIG9pgzvmz-NN-AEgGb")
);
}
@@ -91,11 +95,7 @@ public final class GroupInviteLinkUrlTest {
}
public Object[] expectUrl(String url) {
try {
return new Object[]{ groupMasterKey, GroupLinkPassword.fromBytes(passwordBytes), url };
} catch (GroupLinkPassword.InvalidLengthException e) {
throw new AssertionError(e);
}
return new Object[]{ groupMasterKey, GroupLinkPassword.fromBytes(passwordBytes), url };
}
}
}

View File

@@ -92,20 +92,6 @@ public final class GroupInviteLinkUrl_InvalidGroupLinkException_Test {
.hasCauseExactlyInstanceOf(InvalidInputException.class);
}
@Test
public void bad_password_length() throws InvalidInputException {
GroupMasterKey groupMasterKey = new GroupMasterKey(Util.getSecretBytes(32));
byte[] passwordBytes = Util.getSecretBytes(15);
String encoding = createEncodedProtobuf(groupMasterKey.serialize(), passwordBytes);
String url = "https://signal.group/#" + encoding;
assertThatThrownBy(() -> GroupInviteLinkUrl.fromUrl(url))
.isInstanceOf(GroupInviteLinkUrl.InvalidGroupLinkException.class)
.hasCauseExactlyInstanceOf(GroupLinkPassword.InvalidLengthException.class);
}
private static String createEncodedProtobuf(@NonNull byte[] groupMasterKey,
@NonNull byte[] passwordBytes)
{