mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 04:57:56 +01:00
Properly ignore tests if no backends are configured
This commit is contained in:
parent
0b96a5314f
commit
3789b60f0b
11 changed files with 37 additions and 21 deletions
|
@ -16,6 +16,7 @@ dependencies {
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
|
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
|
||||||
|
// Read json config file
|
||||||
testImplementation "com.google.code.gson:gson:2.10.1"
|
testImplementation "com.google.code.gson:gson:2.10.1"
|
||||||
|
|
||||||
api project(":sop-java")
|
api project(":sop-java")
|
||||||
|
@ -23,9 +24,6 @@ dependencies {
|
||||||
api "org.slf4j:slf4j-api:$slf4jVersion"
|
api "org.slf4j:slf4j-api:$slf4jVersion"
|
||||||
testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
|
testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
|
||||||
|
|
||||||
// Compare version strings
|
|
||||||
implementation 'org.apache.maven:maven-artifact:3.6.3'
|
|
||||||
|
|
||||||
// @Nonnull, @Nullable...
|
// @Nonnull, @Nullable...
|
||||||
implementation "com.google.code.findbugs:jsr305:$jsrVersion"
|
implementation "com.google.code.findbugs:jsr305:$jsrVersion"
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,18 +17,13 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
|
||||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|
||||||
|
|
||||||
public abstract class AbstractExternalSOPTest {
|
public abstract class AbstractExternalSOPTest {
|
||||||
|
|
||||||
private static final List<Arguments> backends = new ArrayList<>();
|
private static final List<Arguments> backends = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
TestSuite suite = readConfiguration();
|
TestSuite suite = readConfiguration();
|
||||||
assumeTrue(suite != null);
|
if (suite != null && !suite.backends.isEmpty()) {
|
||||||
assumeFalse(suite.backends.isEmpty());
|
|
||||||
|
|
||||||
for (TestSubject subject : suite.backends) {
|
for (TestSubject subject : suite.backends) {
|
||||||
if (!new File(subject.sop).exists()) {
|
if (!new File(subject.sop).exists()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -45,6 +40,7 @@ public abstract class AbstractExternalSOPTest {
|
||||||
backends.add(Arguments.of(Named.of(subject.name, sop)));
|
backends.add(Arguments.of(Named.of(subject.name, sop)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Stream<Arguments> provideBackends() {
|
public static Stream<Arguments> provideBackends() {
|
||||||
return backends.stream();
|
return backends.stream();
|
||||||
|
@ -62,6 +58,10 @@ public abstract class AbstractExternalSOPTest {
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasBackends() {
|
||||||
|
return !backends.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
// JSON DTOs
|
// JSON DTOs
|
||||||
|
|
||||||
public static class TestSuite {
|
public static class TestSuite {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
|
@ -17,6 +18,7 @@ import static sop.external.JUtils.arrayStartsWith;
|
||||||
import static sop.external.JUtils.assertArrayStartsWith;
|
import static sop.external.JUtils.assertArrayStartsWith;
|
||||||
import static sop.external.JUtils.assertAsciiArmorEquals;
|
import static sop.external.JUtils.assertAsciiArmorEquals;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalArmorDearmorRoundTripTest extends AbstractExternalSOPTest {
|
public class ExternalArmorDearmorRoundTripTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
private static final String BEGIN_PGP_PRIVATE_KEY_BLOCK = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n";
|
private static final String BEGIN_PGP_PRIVATE_KEY_BLOCK = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n";
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.ByteArrayAndResult;
|
import sop.ByteArrayAndResult;
|
||||||
|
@ -17,6 +18,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalDecryptWithSessionKeyTest extends AbstractExternalSOPTest {
|
public class ExternalDecryptWithSessionKeyTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
private static final String CIPHERTEXT = "-----BEGIN PGP MESSAGE-----\n" +
|
private static final String CIPHERTEXT = "-----BEGIN PGP MESSAGE-----\n" +
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
|
@ -21,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static sop.external.JUtils.assertArrayStartsWith;
|
import static sop.external.JUtils.assertArrayStartsWith;
|
||||||
import static sop.external.JUtils.assertSignedBy;
|
import static sop.external.JUtils.assertSignedBy;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalDetachedSignVerifyRoundTripTest extends AbstractExternalSOPTest {
|
public class ExternalDetachedSignVerifyRoundTripTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
private static final String BEGIN_PGP_SIGNATURE = "-----BEGIN PGP SIGNATURE-----\n";
|
private static final String BEGIN_PGP_SIGNATURE = "-----BEGIN PGP SIGNATURE-----\n";
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.ByteArrayAndResult;
|
import sop.ByteArrayAndResult;
|
||||||
|
@ -26,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest {
|
public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
|
@ -17,6 +18,7 @@ import static sop.external.JUtils.arrayStartsWith;
|
||||||
import static sop.external.JUtils.assertArrayStartsWith;
|
import static sop.external.JUtils.assertArrayStartsWith;
|
||||||
import static sop.external.JUtils.assertAsciiArmorEquals;
|
import static sop.external.JUtils.assertAsciiArmorEquals;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalExtractCertTest extends AbstractExternalSOPTest {
|
public class ExternalExtractCertTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
private static final String BEGIN_PGP_PUBLIC_KEY_BLOCK = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n";
|
private static final String BEGIN_PGP_PUBLIC_KEY_BLOCK = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n";
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
|
@ -15,6 +16,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static sop.external.JUtils.assertArrayStartsWith;
|
import static sop.external.JUtils.assertArrayStartsWith;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalGenerateKeyTest extends AbstractExternalSOPTest {
|
public class ExternalGenerateKeyTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
private static final Charset UTF8 = StandardCharsets.UTF_8;
|
private static final Charset UTF8 = StandardCharsets.UTF_8;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.ByteArrayAndResult;
|
import sop.ByteArrayAndResult;
|
||||||
|
@ -20,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static sop.external.JUtils.arrayStartsWith;
|
import static sop.external.JUtils.arrayStartsWith;
|
||||||
import static sop.external.JUtils.assertArrayStartsWith;
|
import static sop.external.JUtils.assertArrayStartsWith;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalInlineSignDetachVerifyRoundTripTest extends AbstractExternalSOPTest {
|
public class ExternalInlineSignDetachVerifyRoundTripTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
private static final byte[] BEGIN_PGP_SIGNATURE = "-----BEGIN PGP SIGNATURE-----\n".getBytes(StandardCharsets.UTF_8);
|
private static final byte[] BEGIN_PGP_SIGNATURE = "-----BEGIN PGP SIGNATURE-----\n".getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.ByteArrayAndResult;
|
import sop.ByteArrayAndResult;
|
||||||
|
@ -22,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static sop.external.JUtils.assertSignedBy;
|
import static sop.external.JUtils.assertSignedBy;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalInlineSignVerifyTest extends AbstractExternalSOPTest {
|
public class ExternalInlineSignVerifyTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
private static final String BEGIN_PGP_MESSAGE = "-----BEGIN PGP MESSAGE-----\n";
|
private static final String BEGIN_PGP_MESSAGE = "-----BEGIN PGP MESSAGE-----\n";
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package sop.external;
|
package sop.external;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.condition.EnabledIf;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
|
@ -12,6 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@EnabledIf("sop.external.AbstractExternalSOPTest#hasBackends")
|
||||||
public class ExternalVersionTest extends AbstractExternalSOPTest {
|
public class ExternalVersionTest extends AbstractExternalSOPTest {
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
|
Loading…
Reference in a new issue