Add list-profiles command

This commit is contained in:
Paul Schaub 2023-04-11 15:06:37 +02:00
parent 17b305924c
commit 83a003e80f
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
14 changed files with 216 additions and 0 deletions

View file

@ -15,6 +15,7 @@ import sop.operation.InlineSign;
import sop.operation.InlineVerify;
import sop.operation.DetachedSign;
import sop.operation.DetachedVerify;
import sop.operation.ListProfiles;
import sop.operation.Version;
/**
@ -146,4 +147,5 @@ public interface SOP {
*/
Dearmor dearmor();
ListProfiles listProfiles();
}

View file

@ -6,6 +6,7 @@ package sop.operation;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import sop.Ready;
import sop.exception.SOPGPException;
@ -56,6 +57,14 @@ public interface GenerateKey {
return withKeyPassword(UTF8Util.decodeUTF8(password));
}
/**
* Pass in a profile identifier.
*
* @param profile profile identifier
* @return this
*/
GenerateKey profile(String profile);
/**
* Generate the OpenPGP key and return it encoded as an {@link InputStream}.
*

View file

@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package sop.operation;
import java.util.List;
public abstract class ListProfiles {
public ListProfiles() {
}
public abstract List<String> ofCommand(String command);
public abstract List<String> global();
}

View file

@ -0,0 +1,40 @@
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package sop.testsuite.operation;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import sop.SOP;
import java.io.IOException;
import java.util.List;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertFalse;
public class ListProfilesTest extends AbstractSOPTest {
static Stream<Arguments> provideInstances() {
return provideBackends();
}
@ParameterizedTest
@MethodSource("provideInstances")
public void listGlobalProfiles(SOP sop) throws IOException {
List<String> profiles = sop.listProfiles()
.global();
assertFalse(profiles.isEmpty());
}
@ParameterizedTest
@MethodSource("provideInstances")
public void listGenerateKeyProfiles(SOP sop) throws IOException {
List<String> profiles = sop.listProfiles()
.ofCommand("generate-key");
assertFalse(profiles.isEmpty());
}
}