mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-20 03:12:05 +01:00
Add tests for mode to DetachedSignTest
This commit is contained in:
parent
b0974c6ade
commit
06c924d41d
1 changed files with 23 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue