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

Bump sop-java to 6.1.0

This commit is contained in:
Paul Schaub 2023-04-27 15:15:42 +02:00
parent 23fd630670
commit eb1ff27a90
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
7 changed files with 79 additions and 45 deletions

View file

@ -13,6 +13,7 @@ import java.io.File;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.util.Date;
import org.bouncycastle.openpgp.PGPException;
@ -105,7 +106,15 @@ public class RoundTripSignVerifyCmdTest extends CLITest {
"-----END PGP SIGNATURE-----";
private static final String TEXT_SIG_VERIFICATION =
"2022-11-09T18:41:18Z 444C10AB011EF8424C83F0A9DA9F413986211DC6 9DA09423C9F94BA4CCA30951099B11BF296A373E mode:text\n";
private static final Date TEXT_SIG_CREATION = UTCUtil.parseUTCDate("2022-11-09T18:41:18Z");
private static final Date TEXT_SIG_CREATION;
static {
try {
TEXT_SIG_CREATION = UTCUtil.parseUTCDate("2022-11-09T18:41:18Z");
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@Test
public void createArmoredSignature() throws IOException {

View file

@ -4,15 +4,15 @@
package org.pgpainless.sop;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import sop.ByteArrayAndResult;
import sop.DecryptionResult;
import sop.Ready;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import sop.testsuite.assertions.VerificationListAssert;
public class CarolKeySignEncryptRoundtripTest {
@ -290,6 +290,8 @@ public class CarolKeySignEncryptRoundtripTest {
byte[] plaintext = decryption.getBytes();
assertArrayEquals(msg, plaintext);
assertEquals(1, decryption.getResult().getVerifications().size());
VerificationListAssert.assertThatVerificationList(decryption.getResult().getVerifications())
.hasSingleItem()
.issuedBy("71FFDA004409E5DDB0C3E8F19BA789DC76D6849A", "71FFDA004409E5DDB0C3E8F19BA789DC76D6849A");
}
}

View file

@ -25,6 +25,7 @@ import sop.Verification;
import sop.enums.SignAs;
import sop.enums.SignatureMode;
import sop.exception.SOPGPException;
import sop.testsuite.assertions.VerificationListAssert;
public class DetachedSignTest {
@ -63,8 +64,9 @@ public class DetachedSignTest {
.signatures(signature)
.data(data);
assertEquals(1, verifications.size());
assertEquals(SignatureMode.binary, verifications.get(0).getSignatureMode());
VerificationListAssert.assertThatVerificationList(verifications)
.hasSingleItem()
.hasMode(SignatureMode.binary);
}
@Test
@ -84,7 +86,8 @@ public class DetachedSignTest {
.signatures(signature)
.data(data);
assertEquals(1, verifications.size());
VerificationListAssert.assertThatVerificationList(verifications)
.hasSingleItem();
}
@Test
@ -103,8 +106,9 @@ public class DetachedSignTest {
.signatures(signature)
.data(data);
assertEquals(1, verifications.size());
assertEquals(SignatureMode.text, verifications.get(0).getSignatureMode());
VerificationListAssert.assertThatVerificationList(verifications)
.hasSingleItem()
.hasMode(SignatureMode.text);
}
@Test

View file

@ -21,7 +21,9 @@ import sop.ByteArrayAndResult;
import sop.DecryptionResult;
import sop.SOP;
import sop.SessionKey;
import sop.enums.SignatureMode;
import sop.exception.SOPGPException;
import sop.testsuite.assertions.VerificationListAssert;
public class EncryptDecryptRoundTripTest {
@ -75,7 +77,8 @@ public class EncryptDecryptRoundTripTest {
assertArrayEquals(message, decrypted.toByteArray());
DecryptionResult result = bytesAndResult.getResult();
assertEquals(1, result.getVerifications().size());
VerificationListAssert.assertThatVerificationList(result.getVerifications())
.hasSingleItem();
}
@Test
@ -106,7 +109,8 @@ public class EncryptDecryptRoundTripTest {
assertArrayEquals(message, decrypted);
DecryptionResult result = bytesAndResult.getResult();
assertEquals(1, result.getVerifications().size());
VerificationListAssert.assertThatVerificationList(result.getVerifications())
.hasSingleItem();
}
@Test
@ -125,7 +129,8 @@ public class EncryptDecryptRoundTripTest {
assertArrayEquals(message, decrypted);
DecryptionResult result = bytesAndResult.getResult();
assertEquals(0, result.getVerifications().size());
VerificationListAssert.assertThatVerificationList(result.getVerifications())
.isEmpty();
}
@Test
@ -144,7 +149,8 @@ public class EncryptDecryptRoundTripTest {
assertArrayEquals(message, decrypted);
DecryptionResult result = bytesAndResult.getResult();
assertEquals(0, result.getVerifications().size());
VerificationListAssert.assertThatVerificationList(result.getVerifications())
.isEmpty();
}
@Test
@ -163,7 +169,8 @@ public class EncryptDecryptRoundTripTest {
assertArrayEquals(message, decrypted);
DecryptionResult result = bytesAndResult.getResult();
assertEquals(0, result.getVerifications().size());
VerificationListAssert.assertThatVerificationList(result.getVerifications())
.isEmpty();
}
@Test
@ -180,7 +187,8 @@ public class EncryptDecryptRoundTripTest {
.toByteArrayAndResult()
.getResult();
assertTrue(result.getVerifications().isEmpty());
VerificationListAssert.assertThatVerificationList(result.getVerifications())
.isEmpty();
}
@Test
@ -486,14 +494,19 @@ public class EncryptDecryptRoundTripTest {
sop.decrypt().withKey(key).verifyWithCert(cert).ciphertext(ciphertext).toByteArrayAndResult();
assertEquals(sessionKey, bytesAndResult.getResult().getSessionKey().get().toString());
assertArrayEquals(plaintext, bytesAndResult.getBytes());
assertEquals(1, bytesAndResult.getResult().getVerifications().size());
VerificationListAssert.assertThatVerificationList(bytesAndResult.getResult().getVerifications())
.hasSingleItem()
.issuedBy("9C26EFAB1C6500A228E8A9C2658EE420C824D191")
.hasMode(SignatureMode.binary);
// Decrypt with session key
bytesAndResult = sop.decrypt().withSessionKey(SessionKey.fromString(sessionKey))
.verifyWithCert(cert).ciphertext(ciphertext).toByteArrayAndResult();
assertEquals(sessionKey, bytesAndResult.getResult().getSessionKey().get().toString());
assertArrayEquals(plaintext, bytesAndResult.getBytes());
assertEquals(1, bytesAndResult.getResult().getVerifications().size());
VerificationListAssert.assertThatVerificationList(bytesAndResult.getResult().getVerifications())
.hasSingleItem()
.issuedBy("9C26EFAB1C6500A228E8A9C2658EE420C824D191")
.hasMode(SignatureMode.binary);
}
@Test

View file

@ -5,8 +5,6 @@
package org.pgpainless.sop;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -34,7 +32,9 @@ import sop.SOP;
import sop.Signatures;
import sop.Verification;
import sop.enums.InlineSignAs;
import sop.enums.SignatureMode;
import sop.exception.SOPGPException;
import sop.testsuite.assertions.VerificationListAssert;
public class InlineDetachTest {
@ -79,9 +79,11 @@ public class InlineDetachTest {
.signatures(signature)
.data(message);
assertFalse(verificationList.isEmpty());
assertEquals(1, verificationList.size());
assertEquals(new OpenPgpV4Fingerprint(secretKey).toString(), verificationList.get(0).getSigningCertFingerprint());
VerificationListAssert.assertThatVerificationList(verificationList)
.hasSingleItem()
.issuedBy(new OpenPgpV4Fingerprint(secretKey).toString())
.hasMode(SignatureMode.text);
assertArrayEquals(data, message);
}
@ -121,8 +123,10 @@ public class InlineDetachTest {
.signatures(signature)
.data(message);
assertFalse(verificationList.isEmpty());
assertEquals(1, verificationList.size());
VerificationListAssert.assertThatVerificationList(verificationList)
.hasSingleItem()
.hasMode(SignatureMode.binary);
assertArrayEquals(data, message);
}
@ -191,8 +195,10 @@ public class InlineDetachTest {
.signatures(signature)
.data(message);
assertFalse(verificationList.isEmpty());
assertEquals(1, verificationList.size());
VerificationListAssert.assertThatVerificationList(verificationList)
.hasSingleItem()
.hasMode(SignatureMode.binary);
assertArrayEquals(data, message);
}
}

View file

@ -4,19 +4,19 @@
package org.pgpainless.sop;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import org.junit.jupiter.api.Test;
import sop.ByteArrayAndResult;
import sop.SOP;
import sop.Verification;
import sop.enums.InlineSignAs;
import sop.enums.SignatureMode;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import sop.testsuite.assertions.VerificationListAssert;
public class InlineSignVerifyRoundtripTest {
@ -48,9 +48,9 @@ public class InlineSignVerifyRoundtripTest {
byte[] verified = result.getBytes();
List<Verification> verificationList = result.getResult();
assertEquals(1, verificationList.size());
Verification verification = verificationList.get(0);
assertEquals(SignatureMode.text, verification.getSignatureMode());
VerificationListAssert.assertThatVerificationList(verificationList)
.hasSingleItem()
.hasMode(SignatureMode.text);
assertArrayEquals(message, verified);
}
@ -81,9 +81,9 @@ public class InlineSignVerifyRoundtripTest {
byte[] verified = result.getBytes();
List<Verification> verificationList = result.getResult();
assertEquals(1, verificationList.size());
Verification verification = verificationList.get(0);
assertEquals(SignatureMode.binary, verification.getSignatureMode());
VerificationListAssert.assertThatVerificationList(verificationList)
.hasSingleItem()
.hasMode(SignatureMode.binary);
assertArrayEquals(message, verified);
}
@ -115,9 +115,9 @@ public class InlineSignVerifyRoundtripTest {
byte[] verified = result.getBytes();
List<Verification> verificationList = result.getResult();
assertEquals(1, verificationList.size());
Verification verification = verificationList.get(0);
assertEquals(SignatureMode.text, verification.getSignatureMode());
VerificationListAssert.assertThatVerificationList(verificationList)
.hasSingleItem()
.hasMode(SignatureMode.text);
assertArrayEquals(message, verified);
}

View file

@ -14,6 +14,6 @@ allprojects {
logbackVersion = '1.2.11'
mockitoVersion = '4.5.1'
slf4jVersion = '1.7.36'
sopJavaVersion = '6.0.0'
sopJavaVersion = '6.1.0'
}
}