1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-16 16:44:50 +02:00
pgpainless/pgpainless-core/src/test/java/org/pgpainless/util/selection/keyring/WildcardKeyRingSelectionStrategyTest.java

58 lines
1.9 KiB
Java
Raw Normal View History

2021-10-07 15:48:52 +02:00
// SPDX-FileCopyrightText: 2020 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.util.selection.keyring;
2020-11-13 16:31:59 +01:00
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
2020-11-13 16:31:59 +01:00
import org.junit.jupiter.api.Test;
import org.pgpainless.key.TestKeys;
import org.pgpainless.util.selection.keyring.impl.Wildcard;
public class WildcardKeyRingSelectionStrategyTest {
2021-12-28 13:32:50 +01:00
private static final Wildcard.PubRingSelectionStrategy<String> pubKeySelectionStrategy
= new Wildcard.PubRingSelectionStrategy<>();
private static final Wildcard.SecRingSelectionStrategy<String> secKeySelectionStrategy
= new Wildcard.SecRingSelectionStrategy<>();
@Test
public void testStratAcceptsMatchingUIDsOnPubKey() throws IOException {
String uid = TestKeys.EMIL_UID;
PGPPublicKeyRing key = TestKeys.getEmilPublicKeyRing();
assertTrue(pubKeySelectionStrategy.accept(uid, key));
}
@Test
public void testStratAcceptsMismatchingUIDsOnPubKey() throws IOException {
String uid = "blabla@bla.bla";
PGPPublicKeyRing key = TestKeys.getEmilPublicKeyRing();
assertTrue(pubKeySelectionStrategy.accept(uid, key));
}
@Test
public void testStratAcceptsMatchingUIDsOnSecKey() throws IOException, PGPException {
String uid = TestKeys.EMIL_UID;
PGPSecretKeyRing key = TestKeys.getEmilSecretKeyRing();
assertTrue(secKeySelectionStrategy.accept(uid, key));
}
@Test
public void testStratAcceptsMismatchingUIDsOnSecKey() throws IOException, PGPException {
String uid = "blabla@bla.bla";
PGPSecretKeyRing key = TestKeys.getEmilSecretKeyRing();
assertTrue(secKeySelectionStrategy.accept(uid, key));
}
}