Compare commits

...

3 Commits

5 changed files with 18 additions and 26 deletions

View File

@ -180,14 +180,6 @@ byte[] armoredData = sop.armor()
The `data(_)` method can either be called by providing a byte array, or an `InputStream`.
:::{note}
There is a `label(ArmorLabel label)` method, which could theoretically be used to define the label used in the
ASCII armor header.
However, this method is not (yet?) supported by `pgpainless-sop` and will currently throw an `UnsupportedOption`
exception.
Instead, the implementation will figure out the data type and set the respective label on its own.
:::
To remove ASCII armor from armored data, simply use the `dearmor()` API:
```java

View File

@ -16,7 +16,6 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.slf4j.LoggerFactory;
import sop.exception.SOPGPException;
public class ArmorCmdTest extends CLITest {
@ -89,15 +88,6 @@ public class ArmorCmdTest extends CLITest {
assertTrue(armored.contains("SGVsbG8sIFdvcmxkIQo="));
}
@Test
public void labelNotYetSupported() throws IOException {
pipeStringToStdin("Hello, World!\n");
ByteArrayOutputStream out = pipeStdoutToStream();
int exitCode = executeCommand("armor", "--label", "Message");
assertEquals(SOPGPException.UnsupportedOption.EXIT_CODE, exitCode);
assertEquals(0, out.size());
}
@Test
public void armorAlreadyArmoredDataIsIdempotent() throws IOException {
pipeStringToStdin(key);

View File

@ -7,22 +7,14 @@ package org.pgpainless.sop;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.util.ArmorUtils;
import sop.enums.ArmorLabel;
import sop.exception.SOPGPException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class ArmorTest {
@Test
public void labelIsNotSupported() {
assertThrows(SOPGPException.UnsupportedOption.class, () -> new SOPImpl().armor().label(ArmorLabel.sig));
}
@Test
public void armor() throws IOException {
byte[] data = PGPainless.generateKeyRing().modernKeyRing("Alice").getEncoded();

View File

@ -0,0 +1,9 @@
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
/**
* Tests for the {@link sop.SOP} API, tailored to the behavior of PGPainless' implementation specifically.
* Generalized tests can be found in {@link sop.testsuite.pgpainless}.
*/
package org.pgpainless.sop;

View File

@ -0,0 +1,9 @@
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
/**
* Generalized tests for the {@link sop.SOP} API.
* For tests tailored specifically to PGPainless' behavior, see {@link org.pgpainless.sop}.
*/
package sop.testsuite.pgpainless;