mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-26 14:22:05 +01:00
WIP: Tests
This commit is contained in:
parent
e3c60973c4
commit
e2cf1a474e
3 changed files with 103 additions and 1 deletions
|
@ -0,0 +1,65 @@
|
|||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package investigations;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class UnknownKeyVersion {
|
||||
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
String KEY = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
|
||||
"\n" +
|
||||
"xsDNBF2lnPIBDAC5cL9PQoQLTMuhjbYvb4Ncuuo0bfmgPRFywX53jPhoFf4Zg6mv\n" +
|
||||
"/seOXpgecTdOcVttfzC8ycIKrt3aQTiwOG/ctaR4Bk/t6ayNFfdUNxHWk4WCKzdz\n" +
|
||||
"/56fW2O0F23qIRd8UUJp5IIlN4RDdRCtdhVQIAuzvp2oVy/LaS2kxQoKvph/5pQ/\n" +
|
||||
"5whqsyroEWDJoSV0yOb25B/iwk/pLUFoyhDG9bj0kIzDxrEqW+7Ba8nocQlecMF3\n" +
|
||||
"X5KMN5kp2zraLv9dlBBpWW43XktjcCZgMy20SouraVma8Je/ECwUWYUiAZxLIlMv\n" +
|
||||
"9CurEOtxUw6N3RdOtLmYZS9uEnn5y1UkF88o8Nku890uk6BrewFzJyLAx5wRZ4F0\n" +
|
||||
"qV/yq36UWQ0JB/AUGhHVPdFf6pl6eaxBwT5GXvbBUibtf8YI2og5RsgTWtXfU7eb\n" +
|
||||
"SGXrl5ZMpbA6mbfhd0R8aPxWfmDWiIOhBufhMCvUHh1sApMKVZnvIff9/0Dca3wb\n" +
|
||||
"vLIwa3T4CyshfT0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wdFSLw6AzrDGfEWeDkXUJUVDy/vtHL7EZL2FenttRRN\n" +
|
||||
"8CgFoUQnDzY6SYh6L1tnKF8yfKg2O0DjT72TEH+yFXbGzmRpiCAWbTM2558YitFM\n" +
|
||||
"omeu8KeZUCM3dMCYaKZbB/4o/Nl9eDZzWUlHPOpi9UKev5dGgtmopTZUeBSnhLkG\n" +
|
||||
"kOKCEXBBZTLdx3UyEi8QV9XJsYBAWRKa19pS33HwtYgK2TNRe5XroJBoL0sjsUnB\n" +
|
||||
"Jz1r8rnNt5EX5aOBQPZvG+ih5B5TaYffJsZF376wmIDd6M9dThHj9HH8nui2xNEN\n" +
|
||||
"vS5yNksqI8ehIwAj3wwcwqnFkqdliEss7ErYmRlt51fQIs+oCqTFe/YfMkvePW4/\n" +
|
||||
"riluP2sJpxStSpD21C83kN1xpSDx1W0jIulE0+EqGk997wbWAfy6Fv2V+JrzYpej\n" +
|
||||
"Lt7OHgcZDFppjHpDg1VrUj2GWaLt83uYVKLarC3OHnezwsE+BBgBCgByBYJdpZzy\n" +
|
||||
"CRD7/MgqAV5zMEcUAAAAAAAeACBzYWx0QG5vdGF0aW9ucy5zZXF1b2lhLXBncC5v\n" +
|
||||
"cmfXHtuoHICRZCURoCNLw5rdWBodqTTk+2bSlujPHAQ57QKbDBYhBNGmbhojsYLJ\n" +
|
||||
"mA94jPv8yCoBXnMwAADaBwwAj9uyOR7/bNa1x82F8rroudPrR1FS+IWyjyKLKp3u\n" +
|
||||
"tDZZl7gjDQnwp+WH/kXWbA0mgGQIhMw8z2e8CbPpcVufowm0jN4DOZvXwwwVBlSn\n" +
|
||||
"YD0N3blVrVaUMevxaR51mUAODVMrCnzfzxdTS84d9iUnVWPOQupafHmvMHW46rXS\n" +
|
||||
"go7ckWPScA3WonhOvkdcEXWUkotQYR5/xjPUIJk41khrXwJXnaB1Js7GlEPItn0z\n" +
|
||||
"2/buuatcpqrYJiLk4kRV4Cyr4WEJsZ8RXM0yQQM7s9A7uzGMujeSkMsfoMS1+N7b\n" +
|
||||
"SzbqgNppJQt1X1sLjwchxmN0iV72KqeDdUcKASNRKFqN1SG3qgw72RH8RczeToY0\n" +
|
||||
"NEMSqThFpxlmgRw8OPr8BbOqp6YG7NWprJ+53JCsO6fDN7vAEtjEUMVFXIiC0kss\n" +
|
||||
"eU9tP3bmUFMp59f7jamXb6nBvATlT4UXkZb4w/eCIqIhwvCj8LgJvI9w40uFoZxz\n" +
|
||||
"qL69eex25sL6yB33k2aiZQ1f\n" +
|
||||
"=zrVt\n" +
|
||||
"-----END PGP PUBLIC KEY BLOCK-----\n";
|
||||
|
||||
PGPPublicKeyRing cert = PGPainless.readKeyRing().publicKeyRing(KEY);
|
||||
}
|
||||
}
|
37
pgpainless-core/src/test/java/investigations/V6Key.java
Normal file
37
pgpainless-core/src/test/java/investigations/V6Key.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package investigations;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class V6Key {
|
||||
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
|
||||
"\n" +
|
||||
"xioGY4d/4xsAAAAg+U2nu0jWCmHlZ3BqZYfQMxmZu52JGggkLq2EVD34laPCsQYf\n" +
|
||||
"GwoAAABCBYJjh3/jAwsJBwUVCg4IDAIWAAKbAwIeCSIhBssYbE8GCaaX5NUt+mxy\n" +
|
||||
"KwwfHifBilZwj2Ul7Ce62azJBScJAgcCAAAAAK0oIBA+LX0ifsDm185Ecds2v8lw\n" +
|
||||
"gyU2kCcUmKfvBXbAf6rhRYWzuQOwEn7E/aLwIwRaLsdry0+VcallHhSu4RN6HWaE\n" +
|
||||
"QsiPlR4zxP/TP7mhfVEe7XWPxtnMUMtf15OyA51YBM4qBmOHf+MZAAAAIIaTJINn\n" +
|
||||
"+eUBXbki+PSAld2nhJh/LVmFsS+60WyvXkQ1wpsGGBsKAAAALAWCY4d/4wKbDCIh\n" +
|
||||
"BssYbE8GCaaX5NUt+mxyKwwfHifBilZwj2Ul7Ce62azJAAAAAAQBIKbpGG2dWTX8\n" +
|
||||
"j+VjFM21J0hqWlEg+bdiojWnKfA5AQpWUWtnNwDEM0g12vYxoWM8Y81W+bHBw805\n" +
|
||||
"I8kWVkXU6vFOi+HWvv/ira7ofJu16NnoUkhclkUrk0mXubZvyl4GBg==\n" +
|
||||
"-----END PGP PUBLIC KEY BLOCK-----";
|
||||
PGPPublicKeyRing cert = PGPainless.readKeyRing().publicKeyRing(key);
|
||||
|
||||
KeyRingInfo info = PGPainless.inspectKeyRing(cert);
|
||||
assertTrue(info.isUsableForEncryption());
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ DhxJVTgA/1WaFrKdP3AgL0Ffdooc5XXbjQsj0uHo6FZSHRI4pchMAQCyJnKQ3RvW
|
|||
-----END PGP PRIVATE KEY BLOCK-----"""
|
||||
|
||||
@Test
|
||||
@Disabled("Disabled since BC 1.77 chokes on the test key")
|
||||
// @Disabled("Disabled since BC 1.77 chokes on the test key")
|
||||
fun testExtractCertificate() {
|
||||
val key = PGPainless.readKeyRing().secretKeyRing(KEY)!!
|
||||
val cert = PGPainless.extractCertificate(key)
|
||||
|
|
Loading…
Reference in a new issue