mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-10 10:49:48 +02:00
Allow for extension of test suite from 3rd party SOP implementations
This commit is contained in:
parent
fd426b533c
commit
0709bce35c
33 changed files with 731 additions and 547 deletions
75
external-sop/src/test/java/sop/testsuite/external/ExternalSOPInstanceFactory.java
vendored
Normal file
75
external-sop/src/test/java/sop/testsuite/external/ExternalSOPInstanceFactory.java
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import sop.SOP;
|
||||
import sop.external.ExternalSOP;
|
||||
import sop.testsuite.SOPInstanceFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ExternalSOPInstanceFactory extends SOPInstanceFactory {
|
||||
|
||||
@Override
|
||||
public Map<String, SOP> provideSOPInstances() {
|
||||
Map<String, SOP> backends = new HashMap<>();
|
||||
TestSuite suite = readConfiguration();
|
||||
if (suite != null && !suite.backends.isEmpty()) {
|
||||
for (TestSubject subject : suite.backends) {
|
||||
if (!new File(subject.sop).exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Properties env = new Properties();
|
||||
if (subject.env != null) {
|
||||
for (Var var : subject.env) {
|
||||
env.put(var.key, var.value);
|
||||
}
|
||||
}
|
||||
|
||||
SOP sop = new ExternalSOP(subject.sop, env);
|
||||
backends.put(subject.name, sop);
|
||||
}
|
||||
}
|
||||
return backends;
|
||||
}
|
||||
|
||||
|
||||
public static TestSuite readConfiguration() {
|
||||
Gson gson = new Gson();
|
||||
InputStream inputStream = ExternalSOPInstanceFactory.class.getResourceAsStream("config.json");
|
||||
if (inputStream == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(inputStream);
|
||||
return gson.fromJson(reader, TestSuite.class);
|
||||
}
|
||||
|
||||
|
||||
// JSON DTOs
|
||||
|
||||
public static class TestSuite {
|
||||
List<TestSubject> backends;
|
||||
}
|
||||
|
||||
public static class TestSubject {
|
||||
String name;
|
||||
String sop;
|
||||
List<Var> env;
|
||||
}
|
||||
|
||||
public static class Var {
|
||||
String key;
|
||||
String value;
|
||||
}
|
||||
}
|
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalArmorDearmorTest.java
vendored
Normal file
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalArmorDearmorTest.java
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.ArmorDearmorTest;
|
||||
|
||||
public class ExternalArmorDearmorTest extends ArmorDearmorTest {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.DecryptWithSessionKeyTest;
|
||||
|
||||
public class ExternalDecryptWithSessionKeyTest extends DecryptWithSessionKeyTest {
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.DetachedSignDetachedVerifyTest;
|
||||
|
||||
public class ExternalDetachedSignDetachedVerifyTest extends DetachedSignDetachedVerifyTest {
|
||||
}
|
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalEncryptDecryptTest.java
vendored
Normal file
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalEncryptDecryptTest.java
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.EncryptDecryptTest;
|
||||
|
||||
public class ExternalEncryptDecryptTest extends EncryptDecryptTest {
|
||||
|
||||
}
|
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalExtractCertTest.java
vendored
Normal file
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalExtractCertTest.java
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.ExtractCertTest;
|
||||
|
||||
public class ExternalExtractCertTest extends ExtractCertTest {
|
||||
|
||||
}
|
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalGenerateKeyTest.java
vendored
Normal file
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalGenerateKeyTest.java
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.GenerateKeyTest;
|
||||
|
||||
public class ExternalGenerateKeyTest extends GenerateKeyTest {
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.InlineSignInlineDetachDetachedVerifyTest;
|
||||
|
||||
public class ExternalInlineSignInlineDetachDetachedVerifyTest
|
||||
extends InlineSignInlineDetachDetachedVerifyTest {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.InlineSignInlineVerifyTest;
|
||||
|
||||
public class ExternalInlineSignInlineVerifyTest extends InlineSignInlineVerifyTest {
|
||||
|
||||
}
|
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalVersionTest.java
vendored
Normal file
11
external-sop/src/test/java/sop/testsuite/external/operation/ExternalVersionTest.java
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import sop.testsuite.operation.VersionTest;
|
||||
|
||||
public class ExternalVersionTest extends VersionTest {
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue