mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-13 20:29:39 +02:00
Get rid of generics in selection strategies
This commit is contained in:
parent
e53a21ff77
commit
83bd157a78
14 changed files with 144 additions and 162 deletions
|
@ -29,15 +29,14 @@ import org.pgpainless.key.selection.keyring.impl.Email;
|
|||
|
||||
public class EmailKeyRingSelectionStrategyTest {
|
||||
|
||||
Email.PubRingSelectionStrategy pubKeySelectionStrategy = new Email.PubRingSelectionStrategy();
|
||||
Email.SecRingSelectionStrategy secKeySelectionStrategy = new Email.SecRingSelectionStrategy();
|
||||
|
||||
@Test
|
||||
public void testMatchingEmailUIDAcceptedOnPubKey() throws IOException {
|
||||
String uid = "<emil@email.user>";
|
||||
PGPPublicKey key = TestKeys.getEmilPublicKeyRing().getPublicKey();
|
||||
|
||||
assertTrue(pubKeySelectionStrategy.accept(uid, key));
|
||||
Email.PubRingSelectionStrategy pubKeySelectionStrategy = new Email.PubRingSelectionStrategy(uid);
|
||||
|
||||
assertTrue(pubKeySelectionStrategy.accept(key));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,14 +44,19 @@ public class EmailKeyRingSelectionStrategyTest {
|
|||
String uid = "emil@email.user";
|
||||
PGPPublicKey key = TestKeys.getEmilPublicKeyRing().getPublicKey();
|
||||
|
||||
assertTrue(pubKeySelectionStrategy.accept(uid, key));
|
||||
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();
|
||||
assertFalse(pubKeySelectionStrategy.accept(wrongUid, key));
|
||||
|
||||
Email.PubRingSelectionStrategy pubKeySelectionStrategy = new Email.PubRingSelectionStrategy(wrongUid);
|
||||
|
||||
assertFalse(pubKeySelectionStrategy.accept(key));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,7 +64,9 @@ public class EmailKeyRingSelectionStrategyTest {
|
|||
String uid = "<emil@email.user>";
|
||||
PGPSecretKey key = TestKeys.getEmilSecretKeyRing().getSecretKey();
|
||||
|
||||
assertTrue(secKeySelectionStrategy.accept(uid, key));
|
||||
Email.SecRingSelectionStrategy secKeySelectionStrategy = new Email.SecRingSelectionStrategy(uid);
|
||||
|
||||
assertTrue(secKeySelectionStrategy.accept(key));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -68,13 +74,18 @@ public class EmailKeyRingSelectionStrategyTest {
|
|||
String uid = "emil@email.user";
|
||||
PGPSecretKey key = TestKeys.getEmilSecretKeyRing().getSecretKey();
|
||||
|
||||
assertTrue(secKeySelectionStrategy.accept(uid, key));
|
||||
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();
|
||||
assertFalse(secKeySelectionStrategy.accept(wrongUid, key));
|
||||
|
||||
Email.SecRingSelectionStrategy secKeySelectionStrategy = new Email.SecRingSelectionStrategy(wrongUid);
|
||||
|
||||
assertFalse(secKeySelectionStrategy.accept(key));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue