From d7238312b1ff39c1f77c5baa39d73cbbf2e6c959 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Tue, 8 Jun 2021 15:51:29 +0100 Subject: [PATCH] Add unit tests for addRotationKeys() methods. --- .../bramble/transport/KeyManagerImplTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/bramble-core/src/test/java/org/briarproject/bramble/transport/KeyManagerImplTest.java b/bramble-core/src/test/java/org/briarproject/bramble/transport/KeyManagerImplTest.java index 02bb20244..5936b89e1 100644 --- a/bramble-core/src/test/java/org/briarproject/bramble/transport/KeyManagerImplTest.java +++ b/bramble-core/src/test/java/org/briarproject/bramble/transport/KeyManagerImplTest.java @@ -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)); + } }