1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-13 20:29:39 +02:00

Further deletion of unused selection classes

This commit is contained in:
Paul Schaub 2021-06-23 19:39:10 +02:00
parent 3c37072774
commit 259f629b3c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
7 changed files with 0 additions and 324 deletions

View file

@ -1,91 +0,0 @@
/*
* Copyright 2020 Paul Schaub.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pgpainless.util.selection.keyring;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.junit.jupiter.api.Test;
import org.pgpainless.key.TestKeys;
import org.pgpainless.util.selection.keyring.impl.Email;
public class EmailKeyRingSelectionStrategyTest {
@Test
public void testMatchingEmailUIDAcceptedOnPubKey() throws IOException {
String uid = "<emil@email.user>";
PGPPublicKey key = TestKeys.getEmilPublicKeyRing().getPublicKey();
Email.PubRingSelectionStrategy pubKeySelectionStrategy = new Email.PubRingSelectionStrategy(uid);
assertTrue(pubKeySelectionStrategy.accept(key));
}
@Test
public void testAddressIsFormattedToMatchOnPubKey() throws IOException {
String uid = "emil@email.user";
PGPPublicKey key = TestKeys.getEmilPublicKeyRing().getPublicKey();
Email.PubRingSelectionStrategy pubKeySelectionStrategy = new Email.PubRingSelectionStrategy(uid);
assertTrue(pubKeySelectionStrategy.accept(key));
}
@Test
public void testPubKeyWithDifferentUIDIsRejected() throws IOException {
String wrongUid = "emilia@email.user";
PGPPublicKey key = TestKeys.getEmilPublicKeyRing().getPublicKey();
Email.PubRingSelectionStrategy pubKeySelectionStrategy = new Email.PubRingSelectionStrategy(wrongUid);
assertFalse(pubKeySelectionStrategy.accept(key));
}
@Test
public void testMatchingEmailUIDAcceptedOnSecKey() throws IOException, PGPException {
String uid = "<emil@email.user>";
PGPSecretKey key = TestKeys.getEmilSecretKeyRing().getSecretKey();
Email.SecRingSelectionStrategy secKeySelectionStrategy = new Email.SecRingSelectionStrategy(uid);
assertTrue(secKeySelectionStrategy.accept(key));
}
@Test
public void testAddressIsFormattedToMatchOnSecKey() throws IOException, PGPException {
String uid = "emil@email.user";
PGPSecretKey key = TestKeys.getEmilSecretKeyRing().getSecretKey();
Email.SecRingSelectionStrategy secKeySelectionStrategy = new Email.SecRingSelectionStrategy(uid);
assertTrue(secKeySelectionStrategy.accept(key));
}
@Test
public void testSecKeyWithDifferentUIDIsRejected() throws IOException, PGPException {
String wrongUid = "emilia@email.user";
PGPSecretKey key = TestKeys.getEmilSecretKeyRing().getSecretKey();
Email.SecRingSelectionStrategy secKeySelectionStrategy = new Email.SecRingSelectionStrategy(wrongUid);
assertFalse(secKeySelectionStrategy.accept(key));
}
}