Add tests for Verification parsing

This commit is contained in:
Paul Schaub 2023-04-27 14:24:59 +02:00
parent 7ea46a1916
commit aa88904711
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -2,17 +2,19 @@
//
// SPDX-License-Identifier: Apache-2.0
package sop.util;
package sop;
import org.junit.jupiter.api.Test;
import sop.Verification;
import sop.enums.SignatureMode;
import sop.testsuite.assertions.VerificationAssert;
import sop.util.UTCUtil;
import java.text.ParseException;
import java.util.Date;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class VerificationTest {
@ -89,4 +91,20 @@ public class VerificationTest {
.hasMode(null)
.hasDescription("certificate from dkg.asc");
}
@Test
public void missingFingerprintFails() {
String string = "2022-11-07T15:01:24Z F9E6F53F7201C60A87064EAB0B27F2B0760A1209";
assertThrows(IllegalArgumentException.class, () -> Verification.fromString(string));
}
@Test
public void malformedTimestampFails() {
String shorter = "'99-11-07T15:01:24Z F9E6F53F7201C60A87064EAB0B27F2B0760A1209 4E2C78519512C2AE9A8BFE7EB3298EB2FBE5F51B";
assertThrows(IllegalArgumentException.class, () -> Verification.fromString(shorter));
String longer = "'99-11-07T15:01:24Z F9E6F53F7201C60A87064EAB0B27F2B0760A1209 4E2C78519512C2AE9A8BFE7EB3298EB2FBE5F51B mode:binary certificate from dkg.asc";
assertThrows(IllegalArgumentException.class, () -> Verification.fromString(longer));
}
}