Skip to content

Commit

Permalink
Round trip test of json methods in MultiEncryption passes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrand committed Sep 25, 2017
1 parent f9d0904 commit f18c4ef
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.markgrand.cryptoShuffle.keyManagement;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.markgrand.cryptoShuffle.AbstractTest;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
Expand Down Expand Up @@ -62,4 +63,16 @@ public void toStringTest() {
final String string = multiEncryption.toString();
assertTrue(string.contains("MultiEncryption"));
}

@Test
public void jsonRoundTripTest() throws Exception {
Set<KeyPair> keyPairs = generateKeyPairs(3);
final MultiEncryption multiEncryption
= new MultiEncryption(key24, keyPairs.stream().map(KeyPair::getPublic).collect(Collectors.toList()));
final ObjectNode jsonObject = (ObjectNode) multiEncryption.toJson();
final MultiEncryption reconstructedMultiEncryption = MultiEncryption.fromJson(jsonObject);
final Optional<byte[]> reconstructedKey24 = reconstructedMultiEncryption.decrypt(keyPairs.iterator().next());
assertTrue(reconstructedKey24.isPresent());
assertArrayEquals(key24, reconstructedKey24.get());
}
}

0 comments on commit f18c4ef

Please sign in to comment.