mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Add helper method for encoding authors.
This commit is contained in:
@@ -94,6 +94,8 @@ public interface ClientHelper {
|
||||
|
||||
BdfList toList(Message m) throws FormatException;
|
||||
|
||||
BdfList toList(Author a);
|
||||
|
||||
byte[] sign(String label, BdfList toSign, byte[] privateKey)
|
||||
throws FormatException, GeneralSecurityException;
|
||||
|
||||
|
||||
@@ -351,6 +351,11 @@ class ClientHelperImpl implements ClientHelper {
|
||||
raw.length - MESSAGE_HEADER_LENGTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BdfList toList(Author a) {
|
||||
return BdfList.of(a.getFormatVersion(), a.getName(), a.getPublicKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sign(String label, BdfList toSign, byte[] privateKey)
|
||||
throws FormatException, GeneralSecurityException {
|
||||
|
||||
@@ -331,6 +331,18 @@ public class ClientHelperImplTest extends BrambleTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsesAndEncodesAuthor() throws Exception {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(authorFactory).createAuthor(author.getFormatVersion(),
|
||||
author.getName(), author.getPublicKey());
|
||||
will(returnValue(author));
|
||||
}});
|
||||
|
||||
BdfList authorList = clientHelper.toList(author);
|
||||
assertEquals(author, clientHelper.parseAndValidateAuthor(authorList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptsValidAuthor() throws Exception {
|
||||
BdfList authorList = BdfList.of(
|
||||
|
||||
Reference in New Issue
Block a user