Repository navigation
Test that FodId keeps the byte layout, the payload version and its constructor out of reach - #157
Draft
jwrosewell wants to merge 1 commit into
Draft
jwrosewell wants to merge 1 commit into
jwrosewell wants to merge 1 commit into
Conversation
…ctor out of reach The 51Did specification keeps the offsets and lengths out of a package's public surface (did-specification/README.md lines 33 to 35), keeps the payload version off the identifier (package-surface.md lines 55 and 56), and has a package make an instance only by reading a complete Envelope (identifier-layout.md lines 42 and 43). FodId meets all three, and these tests fail if a later change makes a layout constant, a payload version accessor or the constructor reachable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tests only. Three rules of the 51Did specification limit what
FodIdoffers a caller, and the Java package meets all three, but no test would fail if a later change broke one of them. This adds those tests. It is the follow-up that #141 names under What remains.What the specification says
did-specification/README.md lines 33 to 35:
package-surface.md lines 53 to 56:
identifier-layout.md lines 42 and 43:
What the code does today
At rc de74c8c8, every offset and length constant in
FodIdis package-private (lines 110 to 168), the payload version is read by a private method (payloadVersionOf) and reaches a caller only in the message of a refused read,FodIdis final, its one constructor is private (lines 181 to 192), and the public static readers that give aFodIdeach take one encoded Envelope (fromBase64,fromByteArray,fromOwid). The only public version accessor,getVersion, gives the Envelope's own version, acom.swancommunity.owid.Version.The tests
FodIdSurfaceTestsinpipeline.did, commit e4d094a1, readsFodIdby reflection.layout_OffsetsAndLengths_AreNotPublicfinds no field ofFodIdthat is public or protected.payloadVersion_IsNotAMemberOfTheIdentifierfinds no public or protected method whose name holds "version" and which gives anything other than the Envelope'sVersion.instances_AreMadeOnlyByReadingAnEnvelopechecks thatFodIdis final, that every constructor is private, and that every public static method giving aFodIdtakes oneString,byte[]orOwid.They pass on
rcby design, so the red run breaks the three rules on purpose. Red 43673233766 ran the tests withFodId'sHEADER_LENGTHmade public, a publicgetPayloadVersionadded and the constructor made public, plus a throwaway workflow, Java 17. Exactly the three new tests failed, with "FodId fields a caller can reach expected:<[]> but was:<[HEADER_LENGTH]>", "FodId methods that give a version other than the Envelope's expected:<[]> but was:<[getPayloadVersion]>" and the private constructor assertion, whileFodIdTests(47) andFodIdParseTests(38) passed. Green 43673225548 ran the head plus the same workflow, andFodIdSurfaceTestspassed 3 of 3,FodIdTests47 of 47 andFodIdParseTests38 of 38.Full build
Under way on
tmp/pr-matrix-<n>. This section is replaced with the run, its result and the head it built when it ends.What it releases
Nothing. The change is a test under
src/test, which the release plan leaves out (ci/README.md), so no package is released for it.Base branch
rcat de74c8c.