mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-29 15:52:08 +01:00
Test fine-grained SOP spec version
This commit is contained in:
parent
3b1edb076c
commit
926e540016
3 changed files with 47 additions and 5 deletions
|
@ -41,4 +41,12 @@ public class VersionCmdTest extends CLITest {
|
||||||
assertTrue(info.contains("Bouncy Castle"));
|
assertTrue(info.contains("Bouncy Castle"));
|
||||||
assertTrue(info.contains("Stateless OpenPGP Protocol"));
|
assertTrue(info.contains("Stateless OpenPGP Protocol"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSopSpecVersion() throws IOException {
|
||||||
|
ByteArrayOutputStream out = pipeStdoutToStream();
|
||||||
|
assertSuccess(executeCommand("version", "--sop-spec"));
|
||||||
|
String info = out.toString();
|
||||||
|
assertTrue(info.startsWith("draft-dkg-openpgp-stateless-cli-"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import sop.operation.Version;
|
||||||
public class VersionImpl implements Version {
|
public class VersionImpl implements Version {
|
||||||
|
|
||||||
// draft version
|
// draft version
|
||||||
private static final String SOP_VERSION = "06";
|
private static final int SOP_VERSION = 6;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -51,11 +51,12 @@ public class VersionImpl implements Version {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExtendedVersion() {
|
public String getExtendedVersion() {
|
||||||
|
String FORMAT_VERSION = String.format("%02d", SOP_VERSION);
|
||||||
return getName() + " " + getVersion() + "\n" +
|
return getName() + " " + getVersion() + "\n" +
|
||||||
"https://codeberg.org/PGPainless/pgpainless/src/branch/master/pgpainless-sop\n" +
|
"https://codeberg.org/PGPainless/pgpainless/src/branch/master/pgpainless-sop\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Implementation of the Stateless OpenPGP Protocol Version " + SOP_VERSION + "\n" +
|
"Implementation of the Stateless OpenPGP Protocol Version " + FORMAT_VERSION + "\n" +
|
||||||
"https://datatracker.ietf.org/doc/html/draft-dkg-openpgp-stateless-cli-" + SOP_VERSION + "\n" +
|
"https://datatracker.ietf.org/doc/html/draft-dkg-openpgp-stateless-cli-" + FORMAT_VERSION + "\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"Based on pgpainless-core " + getVersion() + "\n" +
|
"Based on pgpainless-core " + getVersion() + "\n" +
|
||||||
"https://pgpainless.org\n" +
|
"https://pgpainless.org\n" +
|
||||||
|
@ -65,7 +66,17 @@ public class VersionImpl implements Version {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSopSpecVersion() {
|
public int getSopSpecVersionNumber() {
|
||||||
return "draft-dkg-openpgp-stateless-cli-" + SOP_VERSION;
|
return SOP_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSopSpecImplementationIncomplete() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSopSpecImplementationIncompletenessRemarks() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.pgpainless.sop;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
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;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -49,4 +50,26 @@ public class VersionTest {
|
||||||
String firstLine = extendedVersion.split("\n")[0];
|
String firstLine = extendedVersion.split("\n")[0];
|
||||||
assertEquals(sop.version().getName() + " " + sop.version().getVersion(), firstLine);
|
assertEquals(sop.version().getName() + " " + sop.version().getVersion(), firstLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetSopSpecVersion() {
|
||||||
|
boolean incomplete = sop.version().isSopSpecImplementationIncomplete();
|
||||||
|
int revisionNumber = sop.version().getSopSpecVersionNumber();
|
||||||
|
|
||||||
|
String revisionString = sop.version().getSopSpecRevisionString();
|
||||||
|
assertEquals("draft-dkg-openpgp-stateless-cli-" + String.format("%02d", revisionNumber), revisionString);
|
||||||
|
|
||||||
|
String incompletenessRemarks = sop.version().getSopSpecImplementationIncompletenessRemarks();
|
||||||
|
|
||||||
|
String fullSopSpecVersion = sop.version().getSopSpecVersion();
|
||||||
|
if (incomplete) {
|
||||||
|
assertTrue(fullSopSpecVersion.startsWith("~" + revisionString));
|
||||||
|
} else {
|
||||||
|
assertTrue(fullSopSpecVersion.startsWith(revisionString));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (incompletenessRemarks != null) {
|
||||||
|
assertTrue(fullSopSpecVersion.endsWith(incompletenessRemarks));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue