diff options
| author | J08nY | 2024-03-30 11:12:17 +0100 |
|---|---|---|
| committer | J08nY | 2024-03-30 11:12:17 +0100 |
| commit | fa5ba0e0e0a3168fdbed27b9c21eada9bb9f1587 (patch) | |
| tree | ded9587bad1e649216a1396af0cacdf0cb7b4ba1 /standalone/src/test/java | |
| parent | 3222a7d206dadeb42422b796389768ac21f976be (diff) | |
| download | ECTester-fa5ba0e0e0a3168fdbed27b9c21eada9bb9f1587.tar.gz ECTester-fa5ba0e0e0a3168fdbed27b9c21eada9bb9f1587.tar.zst ECTester-fa5ba0e0e0a3168fdbed27b9c21eada9bb9f1587.zip | |
Add more suites to tests.
Diffstat (limited to 'standalone/src/test/java')
| -rw-r--r-- | standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java | 75 |
1 files changed, 62 insertions, 13 deletions
diff --git a/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java b/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java index c869233..e3ae573 100644 --- a/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java +++ b/standalone/src/test/java/cz/crcs/ectester/standalone/AppTests.java @@ -1,12 +1,14 @@ package cz.crcs.ectester.standalone; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; +import org.junit.jupiter.params.provider.MethodSource; import org.junitpioneer.jupiter.StdIo; import org.junitpioneer.jupiter.StdOut; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assumptions.assumeFalse; @@ -53,9 +55,13 @@ public class AppTests { assertTrue(s.contains("NONEwithECDSA")); } + static Stream<String> libs() { + return Stream.of("BoringSSL", "Botan", "BouncyCastle", "Crypto++", "IPPCP", "LibreSSL", "libgcrypt", "mbedTLS", "Nettle", "OpenSSL", "SunEC", "tomcrypt", "wolfCrypt"); + } + @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void defaultSuite(String libName, StdOut out) { // TODO: "Nettle" is very broken here for a weird reason. @@ -74,7 +80,7 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void testVectorSuite(String libName, StdOut out) { String[] args = new String[]{"test", "test-vectors", libName}; @@ -89,14 +95,14 @@ public class AppTests { } @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") public void performanceSuite(String libName) { // TODO: "Nettle" is very broken here for a weird reason. assumeFalse(libName.equals("Nettle")); - String[] args = new String[]{"test", "performance", "-o", "/dev/null", libName}; + String[] args = new String[]{"test", "performance", libName}; if (libName.equals("Botan") || libName.equals("Crypto++")) { - args = new String[]{"test", "--kpg-type", "ECDH", "performance", "-o", "/dev/null", libName}; + args = new String[]{"test", "--kpg-type", "ECDH", "performance", libName}; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); @@ -108,9 +114,51 @@ public class AppTests { } } + @ParameterizedTest + @MethodSource("libs") + public void signatureSuite(String libName) { + String[] args = new String[]{"test", "signature", libName}; + switch (libName) { + case "Nettle": + case "libgcrypt": + case "BoringSSL": + case "OpenSSL": + case "tomcrypt": + case "LibreSSL": + case "IPPCP": + case "mbedTLS": + args = new String[]{"test", "-st", "NONEwithECDSA", "signature", libName}; + break; + } + ECTesterStandalone.main(args); + } + + @ParameterizedTest + @MethodSource("libs") + public void miscSuite(String libName) { + String[] args = new String[]{"test", "miscellaneous", libName}; + if (libName.equals("Botan") || libName.equals("Crypto++")) { + args = new String[]{"test", "--kpg-type", "ECDH", "miscellaneous", libName}; + } + ECTesterStandalone.main(args); + } + + @ParameterizedTest + @MethodSource("libs") + public void invalidSuite(String libName) { + // TODO: "Nettle" is very broken here for a weird reason. + assumeFalse(libName.equals("Nettle")); + + String[] args = new String[]{"test", "invalid", libName}; + if (libName.equals("Botan") || libName.equals("Crypto++")) { + args = new String[]{"test", "--kpg-type", "ECDH", "invalid", libName}; + } + ECTesterStandalone.main(args); + } + @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void generate(String libName, StdOut out) { String[] args = new String[]{"generate", "-n", "10", "-nc", "secg/secp256r1", libName}; @@ -133,7 +181,7 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void ecdh(String libName, StdOut out) { String[] args = new String[]{"ecdh", "-n", "10", "-nc", "secg/secp256r1", libName}; @@ -152,7 +200,7 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void ecdsa(String libName, StdOut out) { String[] args = new String[]{"ecdsa", "-n", "10", "-nc", "secg/secp256r1", libName}; @@ -164,10 +212,11 @@ public class AppTests { case "BoringSSL": args = new String[]{"ecdsa", "-n", "10", "-cn", "prime256v1", "-t", "NONEwithECDSA", libName}; break; - case "OpenSSL 3": - case "libtomcrypt": + case "OpenSSL": + case "tomcrypt": case "LibreSSL": - case "2021": + case "IPPCP": + case "mbedTLS": args = new String[]{"ecdsa", "-n", "10", "-nc", "secg/secp256r1", "-t", "NONEwithECDSA", libName}; break; case "wolfCrypt": @@ -179,7 +228,7 @@ public class AppTests { @SuppressWarnings("JUnitMalformedDeclaration") @ParameterizedTest - @ValueSource(strings = {"Bouncy", "Sun", "libtomcrypt", "Botan", "Crypto++", "OpenSSL 3", "BoringSSL", "libgcrypt", "mbed TLS", "2021" /* IPPCP */, "Nettle", "LibreSSL", "wolfCrypt"}) + @MethodSource("libs") @StdIo() public void export(String libName, StdOut out) { // TODO: wolfCrypt is weirdly broken here. |
