1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-22 19:08:00 +01:00

Add tests for mode to DetachedSignTest

This commit is contained in:
Paul Schaub 2023-04-18 18:43:56 +02:00
parent b0974c6ade
commit 06c924d41d
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -23,6 +23,7 @@ import org.pgpainless.signature.SignatureUtils;
import sop.SOP;
import sop.Verification;
import sop.enums.SignAs;
import sop.enums.SignatureMode;
import sop.exception.SOPGPException;
public class DetachedSignTest {
@ -49,6 +50,7 @@ public class DetachedSignTest {
public void signArmored() throws IOException {
byte[] signature = sop.sign()
.key(key)
.mode(SignAs.Binary)
.data(data)
.toByteArrayAndResult().getBytes();
@ -62,6 +64,7 @@ public class DetachedSignTest {
.data(data);
assertEquals(1, verifications.size());
assertEquals(SignatureMode.binary, verifications.get(0).getSignatureMode());
}
@Test
@ -84,6 +87,26 @@ public class DetachedSignTest {
assertEquals(1, verifications.size());
}
@Test
public void textSig() throws IOException {
byte[] signature = sop.sign()
.key(key)
.noArmor()
.mode(SignAs.Text)
.data(data)
.toByteArrayAndResult().getBytes();
List<Verification> verifications = sop.verify()
.cert(cert)
.notAfter(new Date(new Date().getTime() + 10000))
.notBefore(new Date(new Date().getTime() - 10000))
.signatures(signature)
.data(data);
assertEquals(1, verifications.size());
assertEquals(SignatureMode.text, verifications.get(0).getSignatureMode());
}
@Test
public void rejectSignatureAsTooOld() throws IOException {
byte[] signature = sop.sign()