mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 12:57:57 +01:00
Implement sop version --sop-spec
This commit is contained in:
parent
dfce1ad6bb
commit
f49c16e4c5
4 changed files with 45 additions and 0 deletions
|
@ -99,4 +99,23 @@ public class VersionExternal implements Version {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSopSpecVersion() {
|
||||||
|
String[] command = new String[] {binary, "version", "--sop-spec"};
|
||||||
|
String[] env = ExternalSOP.propertiesToEnv(environment).toArray(new String[0]);
|
||||||
|
try {
|
||||||
|
Process process = runtime.exec(command, env);
|
||||||
|
BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
while ((line = stdInput.readLine()) != null) {
|
||||||
|
sb.append(line).append('\n');
|
||||||
|
}
|
||||||
|
ExternalSOP.finish(process);
|
||||||
|
return sb.toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ public class VersionCmd extends AbstractSopCmd {
|
||||||
|
|
||||||
@CommandLine.Option(names = "--backend")
|
@CommandLine.Option(names = "--backend")
|
||||||
boolean backend;
|
boolean backend;
|
||||||
|
|
||||||
|
@CommandLine.Option(names = "--sop-spec")
|
||||||
|
boolean sopSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,5 +48,10 @@ public class VersionCmd extends AbstractSopCmd {
|
||||||
Print.outln(version.getBackendVersion());
|
Print.outln(version.getBackendVersion());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exclusive.sopSpec) {
|
||||||
|
Print.outln(version.getSopSpecVersion());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,4 +46,14 @@ public interface Version {
|
||||||
* @return extended version string
|
* @return extended version string
|
||||||
*/
|
*/
|
||||||
String getExtendedVersion();
|
String getExtendedVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the revision of the SOP specification that this implementation is implementing, for example,
|
||||||
|
* <pre>draft-dkg-openpgp-stateless-cli-06</pre>.
|
||||||
|
* If the implementation targets a specific draft but the implementer knows the implementation is incomplete,
|
||||||
|
* it should prefix the draft title with a "~" (TILDE, U+007E), for example: <pre>~draft-dkg-openpgp-stateless-cli-06</pre>.
|
||||||
|
*
|
||||||
|
* @return implemented SOP spec version
|
||||||
|
*/
|
||||||
|
String getSopSpecVersion();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
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;
|
||||||
|
|
||||||
@EnabledIf("sop.testsuite.operation.AbstractSOPTest#hasBackends")
|
@EnabledIf("sop.testsuite.operation.AbstractSOPTest#hasBackends")
|
||||||
public class VersionTest extends AbstractSOPTest {
|
public class VersionTest extends AbstractSOPTest {
|
||||||
|
@ -51,4 +52,11 @@ public class VersionTest extends AbstractSOPTest {
|
||||||
assertFalse(extended.isEmpty());
|
assertFalse(extended.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("provideInstances")
|
||||||
|
public void sopSpecVersionTest(SOP sop) {
|
||||||
|
String sopSpec = sop.version().getSopSpecVersion();
|
||||||
|
assertTrue(sopSpec.startsWith("draft-dkg-openpgp-stateless-cli-") ||
|
||||||
|
sopSpec.startsWith("~draft-dkg-openpgp-stateless-cli-"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue