mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 10:19:47 +02:00
Add list-profiles command
This commit is contained in:
parent
17b305924c
commit
83a003e80f
14 changed files with 216 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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}.
|
||||
*
|
||||
|
|
19
sop-java/src/main/java/sop/operation/ListProfiles.java
Normal file
19
sop-java/src/main/java/sop/operation/ListProfiles.java
Normal 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();
|
||||
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue