From 824b8de40412da3693eef5cb3c4a250523989aec Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 9 Jan 2022 01:25:18 +0100 Subject: [PATCH] Add sessionKey fromString test --- sop-java/src/test/java/sop/util/SessionKeyTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sop-java/src/test/java/sop/util/SessionKeyTest.java b/sop-java/src/test/java/sop/util/SessionKeyTest.java index 2d03279d..2891d0d4 100644 --- a/sop-java/src/test/java/sop/util/SessionKeyTest.java +++ b/sop-java/src/test/java/sop/util/SessionKeyTest.java @@ -6,6 +6,7 @@ package sop.util; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; import sop.SessionKey; @@ -45,4 +46,16 @@ public class SessionKeyTest { assertNotEquals(s1, null); assertNotEquals(s1, "FCA4BEAF687F48059CACC14FB019125CD57392BAB7037C707835925CBF9F7BCD"); } + + @Test + public void fromString_missingAlgorithmIdThrows() { + String missingAlgorithId = "FCA4BEAF687F48059CACC14FB019125CD57392BAB7037C707835925CBF9F7BCD"; + assertThrows(IllegalArgumentException.class, () -> SessionKey.fromString(missingAlgorithId)); + } + + @Test + public void fromString_wrongDivider() { + String semicolonDivider = "9;FCA4BEAF687F48059CACC14FB019125CD57392BAB7037C707835925CBF9F7BCD"; + assertThrows(IllegalArgumentException.class, () -> SessionKey.fromString(semicolonDivider)); + } }