mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-22 20:32:05 +01:00
Add basic tests for new functionality
This commit is contained in:
parent
b79e706d65
commit
f3a4a01d19
2 changed files with 48 additions and 0 deletions
|
@ -7,6 +7,7 @@ package org.pgpainless.sop;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -21,6 +22,7 @@ import org.pgpainless.key.info.KeyRingInfo;
|
|||
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import sop.SOP;
|
||||
import sop.exception.SOPGPException;
|
||||
|
||||
public class GenerateKeyTest {
|
||||
|
||||
|
@ -92,4 +94,16 @@ public class GenerateKeyTest {
|
|||
assertNotNull(UnlockSecretKey.unlockSecretKey(key, Passphrase.fromPassword("sw0rdf1sh")));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidProfile() {
|
||||
assertThrows(SOPGPException.UnsupportedProfile.class, () ->
|
||||
sop.generateKey().profile("invalid"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullProfile() {
|
||||
assertThrows(SOPGPException.UnsupportedProfile.class, () ->
|
||||
sop.generateKey().profile((String) null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.sop;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import sop.SOP;
|
||||
import sop.exception.SOPGPException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class ListProfilesTest {
|
||||
|
||||
private SOP sop;
|
||||
|
||||
@BeforeEach
|
||||
public void prepare() {
|
||||
this.sop = new SOPImpl();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listProfilesOfGenerateKey() {
|
||||
assertFalse(sop.listProfiles().subcommand("generate-key").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listProfilesOfHelpCommandThrows() {
|
||||
assertThrows(SOPGPException.UnsupportedProfile.class, () ->
|
||||
sop.listProfiles().subcommand("help"));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue