mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 04:17:59 +01:00
Further increase coverage of PDA class
This commit is contained in:
parent
09ba8d1e17
commit
ba947c81d3
1 changed files with 78 additions and 0 deletions
|
@ -73,6 +73,42 @@ public class PDATest {
|
||||||
assertTrue(check.isValid());
|
assertTrue(check.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOPSSignedEncryptedMessageIsValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.OnePassSignature);
|
||||||
|
check.next(InputAlphabet.EncryptedData);
|
||||||
|
check.next(InputAlphabet.Signature);
|
||||||
|
check.next(InputAlphabet.EndOfSequence);
|
||||||
|
assertTrue(check.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void anyInputAfterEOSIsNotValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.LiteralData);
|
||||||
|
check.next(InputAlphabet.EndOfSequence);
|
||||||
|
assertThrows(MalformedOpenPgpMessageException.class,
|
||||||
|
() -> check.next(InputAlphabet.Signature));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEncryptedMessageWithAppendedStandalongSigIsNotValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.EncryptedData);
|
||||||
|
assertThrows(MalformedOpenPgpMessageException.class,
|
||||||
|
() -> check.next(InputAlphabet.Signature));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOPSSignedEncryptedMessageWithMissingSigIsNotValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.OnePassSignature);
|
||||||
|
check.next(InputAlphabet.EncryptedData);
|
||||||
|
assertThrows(MalformedOpenPgpMessageException.class,
|
||||||
|
() -> check.next(InputAlphabet.EndOfSequence));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTwoLiteralDataIsNotValid() {
|
public void testTwoLiteralDataIsNotValid() {
|
||||||
PDA check = new PDA();
|
PDA check = new PDA();
|
||||||
|
@ -89,6 +125,48 @@ public class PDATest {
|
||||||
() -> check.next(InputAlphabet.Signature));
|
() -> check.next(InputAlphabet.Signature));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOPSAloneIsNotValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.OnePassSignature);
|
||||||
|
assertThrows(MalformedOpenPgpMessageException.class,
|
||||||
|
() -> check.next(InputAlphabet.EndOfSequence));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOPSLitWithMissingSigIsNotValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.OnePassSignature);
|
||||||
|
check.next(InputAlphabet.LiteralData);
|
||||||
|
assertThrows(MalformedOpenPgpMessageException.class,
|
||||||
|
() -> check.next(InputAlphabet.EndOfSequence));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCompressedMessageWithStandalongAppendedSigIsNotValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.CompressedData);
|
||||||
|
assertThrows(MalformedOpenPgpMessageException.class,
|
||||||
|
() -> check.next(InputAlphabet.Signature));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOPSCompressedDataWithMissingSigIsNotValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.OnePassSignature);
|
||||||
|
check.next(InputAlphabet.CompressedData);
|
||||||
|
assertThrows(MalformedOpenPgpMessageException.class,
|
||||||
|
() -> check.next(InputAlphabet.EndOfSequence));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCompressedMessageFollowedByTrailingLiteralDataIsNotValid() {
|
||||||
|
PDA check = new PDA();
|
||||||
|
check.next(InputAlphabet.CompressedData);
|
||||||
|
assertThrows(MalformedOpenPgpMessageException.class,
|
||||||
|
() -> check.next(InputAlphabet.LiteralData));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOPSWithPrependedSigIsValid() {
|
public void testOPSWithPrependedSigIsValid() {
|
||||||
PDA check = new PDA();
|
PDA check = new PDA();
|
||||||
|
|
Loading…
Reference in a new issue