Add basic tests for new functionality

This commit is contained in:
Paul Schaub 2023-04-14 16:17:32 +02:00
parent b79e706d65
commit f3a4a01d19
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
2 changed files with 48 additions and 0 deletions

View File

@ -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));
}
}

View File

@ -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"));
}
}