mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 10:19:47 +02:00
Expose SOP revision info more fine-grained
This commit is contained in:
parent
90c77706a8
commit
8425665fa7
3 changed files with 96 additions and 4 deletions
|
@ -47,13 +47,62 @@ public interface Version {
|
|||
*/
|
||||
String getExtendedVersion();
|
||||
|
||||
/**
|
||||
* Return the version number of the latest targeted SOP spec revision.
|
||||
*
|
||||
* @return SOP spec revision number
|
||||
*/
|
||||
int getSopSpecVersionNumber();
|
||||
|
||||
/**
|
||||
* Return the latest targeted revision of the SOP spec.
|
||||
*
|
||||
* @return SOP spec revision string
|
||||
*/
|
||||
default String getSopSpecRevisionString() {
|
||||
return "draft-dkg-openpgp-stateless-cli-" + String.format("%02d", getSopSpecVersionNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return <pre>true</pre>, if this implementation of the SOP spec is known to be incomplete or defective.
|
||||
*
|
||||
* @return true if incomplete, false otherwise
|
||||
*/
|
||||
boolean isSopSpecImplementationIncomplete();
|
||||
|
||||
/**
|
||||
* Return free-form text containing remarks about the completeness of the SOP implementation.
|
||||
* If no remarks are known, this method returns <pre>null</pre>.
|
||||
*
|
||||
* @return remarks or null
|
||||
*/
|
||||
String getSopSpecImplementationIncompletenessRemarks();
|
||||
|
||||
/**
|
||||
* 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>.
|
||||
* it should prefix the draft title with a "~" (TILDE, U+007E), for example:
|
||||
* <pre>~draft-dkg-openpgp-stateless-cli-06</pre>.
|
||||
* The implementation MAY emit additional text about its relationship to the targeted draft on the lines following
|
||||
* the versioned title.
|
||||
*
|
||||
* @return implemented SOP spec version
|
||||
*/
|
||||
String getSopSpecVersion();
|
||||
default String getSopSpecVersion() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (isSopSpecImplementationIncomplete()) {
|
||||
sb.append('~');
|
||||
}
|
||||
|
||||
sb.append(getSopSpecRevisionString());
|
||||
|
||||
if (getSopSpecImplementationIncompletenessRemarks() != null) {
|
||||
sb.append('\n')
|
||||
.append('\n')
|
||||
.append(getSopSpecImplementationIncompletenessRemarks());
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.stream.Stream;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@EnabledIf("sop.testsuite.operation.AbstractSOPTest#hasBackends")
|
||||
|
@ -56,7 +57,13 @@ public class VersionTest extends AbstractSOPTest {
|
|||
@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-"));
|
||||
if (sop.version().isSopSpecImplementationIncomplete()) {
|
||||
assertTrue(sopSpec.startsWith("~draft-dkg-openpgp-stateless-cli-"));
|
||||
} else {
|
||||
assertTrue(sopSpec.startsWith("draft-dkg-openpgp-stateless-cli-"));
|
||||
}
|
||||
|
||||
int sopRevision = sop.version().getSopSpecVersionNumber();
|
||||
assertTrue(sop.version().getSopSpecRevisionString().endsWith("" + sopRevision));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue