Add unit tests for addRotationKeys() methods.

This commit is contained in:
akwizgran
2021-06-08 15:51:29 +01:00
committed by Torsten Grote
parent ec40da4353
commit d7238312b1

View File

@@ -242,4 +242,37 @@ public class KeyManagerImplTest extends BrambleMockTestCase {
keyManager.eventOccurred(event);
executor.runUntilIdle();
}
@Test
public void testAddMultipleRotationKeySets() throws Exception {
long timestamp = System.currentTimeMillis();
boolean alice = random.nextBoolean();
boolean active = random.nextBoolean();
context.checking(new Expectations() {{
oneOf(transportKeyManager).addRotationKeys(txn, contactId,
rootKey, timestamp, alice, active);
will(returnValue(keySetId));
}});
assertEquals(singletonMap(transportId, keySetId),
keyManager.addRotationKeys(txn, contactId, rootKey, timestamp,
alice, active));
}
@Test
public void testAddSingleRotationKeySet() throws Exception {
long timestamp = System.currentTimeMillis();
boolean alice = random.nextBoolean();
boolean active = random.nextBoolean();
context.checking(new Expectations() {{
oneOf(transportKeyManager).addRotationKeys(txn, contactId,
rootKey, timestamp, alice, active);
will(returnValue(keySetId));
}});
assertEquals(keySetId, keyManager.addRotationKeys(txn, contactId,
transportId, rootKey, timestamp, alice, active));
}
}