1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 06:12:06 +01:00

Increase coverage of Policy class

This commit is contained in:
Paul Schaub 2022-06-20 18:48:27 +02:00
parent 37441a81e8
commit 0690a21360
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -6,6 +6,7 @@ package org.pgpainless.policy;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays; import java.util.Arrays;
@ -167,4 +168,41 @@ public class PolicyTest {
policy.getNotationRegistry().addKnownNotation("notation@pgpainless.org"); policy.getNotationRegistry().addKnownNotation("notation@pgpainless.org");
assertTrue(policy.getNotationRegistry().isKnownNotation("notation@pgpainless.org")); assertTrue(policy.getNotationRegistry().isKnownNotation("notation@pgpainless.org"));
} }
@Test
public void testUnknownSymmetricKeyEncryptionAlgorithmIsNotAcceptable() {
assertFalse(policy.getSymmetricKeyEncryptionAlgorithmPolicy().isAcceptable(-1));
}
@Test
public void testUnknownSymmetricKeyDecryptionAlgorithmIsNotAcceptable() {
assertFalse(policy.getSymmetricKeyDecryptionAlgorithmPolicy().isAcceptable(-1));
}
@Test
public void testUnknownSignatureHashAlgorithmIsNotAcceptable() {
assertFalse(policy.getSignatureHashAlgorithmPolicy().isAcceptable(-1));
assertFalse(policy.getSignatureHashAlgorithmPolicy().isAcceptable(-1, new Date()));
}
@Test
public void testUnknownRevocationHashAlgorithmIsNotAcceptable() {
assertFalse(policy.getRevocationSignatureHashAlgorithmPolicy().isAcceptable(-1));
assertFalse(policy.getRevocationSignatureHashAlgorithmPolicy().isAcceptable(-1, new Date()));
}
@Test
public void testUnknownCompressionAlgorithmIsNotAcceptable() {
assertFalse(policy.getCompressionAlgorithmPolicy().isAcceptable(-1));
}
@Test
public void testUnknownPublicKeyAlgorithmIsNotAcceptable() {
assertFalse(policy.getPublicKeyAlgorithmPolicy().isAcceptable(-1, 4096));
}
@Test
public void setNullSignerUserIdValidationLevelThrows() {
assertThrows(NullPointerException.class, () -> policy.setSignerUserIdValidationLevel(null));
}
} }