1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-17 00:54:50 +02:00
pgpainless/pgpainless-core/src/test/java/org/pgpainless/key/util/RevocationAttributesTest.java
Paul Schaub 68575f9f1e
Reorganize classes in packages
Move ArmorUtils to org.pgpainless.ascii_armor
Move Armored*StreamFactory to org.pgpainless.ascii_armor
Move CRCingArmoredInputStreamWrapper to org.pgpainless.ascii_armor
Move SessionKey to org.pgpainless.s2k
Move RevocationAttributes to org.pgpainless.key
Move UserId to org.pgpainless.key
Move Passphrase to org.pgpainless.s2k
Move NotationRegistry to org.pgpainless.policy
2022-09-07 13:35:58 +02:00

37 lines
1.8 KiB
Java

// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.key.util;
import org.junit.jupiter.api.Test;
import org.pgpainless.key.RevocationAttributes;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class RevocationAttributesTest {
@Test
public void testIsHardRevocationReason() {
// No reason and key compromised are hard revocation reasons
assertTrue(RevocationAttributes.Reason.isHardRevocation(RevocationAttributes.Reason.NO_REASON));
assertTrue(RevocationAttributes.Reason.isHardRevocation(RevocationAttributes.Reason.KEY_COMPROMISED));
// others are soft
assertFalse(RevocationAttributes.Reason.isHardRevocation(RevocationAttributes.Reason.USER_ID_NO_LONGER_VALID));
assertFalse(RevocationAttributes.Reason.isHardRevocation(RevocationAttributes.Reason.KEY_RETIRED));
assertFalse(RevocationAttributes.Reason.isHardRevocation(RevocationAttributes.Reason.KEY_SUPERSEDED));
}
@Test
public void fromReasonCode() {
assertEquals(RevocationAttributes.Reason.NO_REASON, RevocationAttributes.Reason.fromCode((byte) 0));
assertEquals(RevocationAttributes.Reason.KEY_SUPERSEDED, RevocationAttributes.Reason.fromCode((byte) 1));
assertEquals(RevocationAttributes.Reason.KEY_COMPROMISED, RevocationAttributes.Reason.fromCode((byte) 2));
assertEquals(RevocationAttributes.Reason.KEY_RETIRED, RevocationAttributes.Reason.fromCode((byte) 3));
assertEquals(RevocationAttributes.Reason.USER_ID_NO_LONGER_VALID, RevocationAttributes.Reason.fromCode((byte) 32));
}
}