Repository navigation
Set the licence key field the live 51Did test reads - #113
Merged
Merged
Conversation
DidClientLiveTests declares a licenceKey field, never assigns it, and reads it in identifiersCreatedFor to build the "&license=" part of the form body, so DidClient.encode is handed null and anIdentifierForAnotherAddress_ReportsEveryFactor fails with a NullPointerException. That is the whole of the Cloud 51Did failure on rc. init() now takes the licence key once, keeps it in the field and gives that field to the client, which is the shape the file had before the lookup moved from env() to LiveCloudKeys.find() and was inlined into the constructor call. No fail() is added for a missing licence key, because LiveCloudKeys says the licence key is optional and both tests that need one already skip on client.hasLicenceKey(). One lookup now feeds both that guard and the form body, so the field cannot be null where it is read. Test code only, so nothing a user sees changes.
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.
The problem
The Cloud 51Did Tests
check fails on
rc. Run 43130812995,job 130894182769, on headSha
9a668883, which isrc's head and thisdraft's base, ends with
In
DidClientLiveTests.javathe field
licenceKeyis declared at line 64,init()at lines 67 to 75assigns
resourceKeyand never assignslicenceKey, and line 371 thenreads the field to build the form body
so
encodeis handed null. The field is written nowhere and read in thatone place, inside
identifiersCreatedFor, which onlyanIdentifierForAnotherAddress_ReportsEveryFactorcalls.Where it came from
The field was assigned until commit
d4d4dc6,
"Make every cloud test call the live service and fail when it cannot
(#59)". Its parent had
and d4d4dc6 moved the lookup from
envtoLiveCloudKeys.findand inlined it into the constructor call, which left the field behind.
There is no specification in this. The behaviour under test is what the
cloud service answers, and the fault is the test's own field, so the source
of truth here is the file's own two readers of the licence key, which are
the client and the form body, and those are what the change makes agree.
What changed
Four lines added and two removed, in one test file.
That is the shape the file had before d4d4dc6, with one lookup feeding both
the field and the client.
Why no failure message for a missing licence key
A
NullPointerException300 lines frominit()says nothing about amissing secret, so it is worth asking whether
init()should fail with aclear message when the licence key is absent, the way it already does for a
missing resource key with
fail(LiveCloudKeys.noResourceKey()). It shouldnot, for two reasons.
The licence key is deliberately optional where the resource key is not.
LiveCloudKeyssays so at lines 53 to 57, "A licence key is optional,because an account can hold its products on the resource key alone", and
the workflow says the same at line 59, "Without a license key the tests
that redeem a sealed verdict skip". Both tests that need one already open
with
Assume.assumeTrue("Set _51DEGREES_LICENSE_KEY to redeem a sealed result.", client.hasLicenceKey()), so the clear message for a missinglicence key exists already and it is a skip rather than a failure. A
fail()would turn that designed skip into a red job for every accountthat holds its products on the resource key alone.
The green run below shows that half is live rather than theoretical. The
job runs the test class once for each resource key, and the second key,
_51DEGREES_RESOURCE_KEY_BESPOKE, has no licence key paired with it, soits half logs "License key: none" and skips those two tests. A
fail()would have made that half red.
The second reason is that the fix removes the way the field could be null
where it is read. The field and
client.hasLicenceKey()now come from thesame lookup, and
LiveCloudKeys.findreturns either null or a trimmednon-empty value, so when there is no licence key the guard skips the test
before line 371 is reached, and when there is one the field holds it.
How it was tested
Red and green are the same workflow over the same test class, and they
differ in one line.
on headSha
9a668883, this draft's base. With_51DEGREES_RESOURCE_KEY_51DID, which the log shows paired with_51DEGREES_LICENSE_KEY_51DID, "Tests run: 6, Failures: 0, Errors: 1,Skipped: 0" and BUILD FAILURE. With
_51DEGREES_RESOURCE_KEY_BESPOKE,"License key: none", "Tests run: 6, Failures: 0, Errors: 0, Skipped: 2"
and BUILD SUCCESS.
on headSha
8176b622, this draft's head. With_51DEGREES_RESOURCE_KEY_51DID, "Tests run: 6, Failures: 0, Errors: 0,Skipped: 0" and BUILD SUCCESS. The
Skipped: 0is the part that matters,because it says the test that died ran against the live service and
passed rather than being skipped over. The
_51DEGREES_RESOURCE_KEY_BESPOKEhalf is unchanged at "Skipped: 2" and BUILD SUCCESS.
The green run was started by hand with
workflow_dispatchon the branch.The workflow's
pull_requesttrigger isbranches: [main], so a draftbased on
rcnever starts it, which is also why this fault reachedrcand only showed when #112
opened
rcintomain.Full build
Run 43138137079,
started at 01:58 UTC on the build branch
tmp/pr-matrix-113at0205cf17,finished green. Configure, the Complete job and all nine Build and Test jobs
are a success, those being Ubuntu on Java 8, 11, 17 and 21, Ubuntu ARM on
Java 17, and Windows on Java 8, 11, 17 and 21. The two Compare Performance
jobs are skipped, as they are on every draft of this kind. All ten
Setting 'PullRequestSha'lines in the logs read8176b622ae5abde121a1abc431da6cdec6ed83a0, which is this draft's head, soevery job built this code and not something else.
macOS was left out of this draft's full build under the 9 November decision.
The rc head is built with macOS before it merges into main. Configure printed
"Left out 6 macOS entries".
What this does not touch
Test code only, in one file, so nothing a user sees changes and there is
nothing for the release note.
Ben Shillito's #56
#56, "Create the
51Did for another address as a licensed caller in the live test", changes
this same file and no other, so it is worth saying plainly that it is not
touched here and that there is no clash. Merging
pull/56/headinto thisbranch in a clone auto-merges and leaves the file identical to this branch,
so the merge is a no-op either way round. Everything #56 proposes is
already on
rc, brought in by d4d4dc6, which carriesidentifiersCreatedFor, the POST form body,readIdentifiersand the samewording in the comment above the test. What #113 adds is the one field
assignment d4d4dc6 dropped on the way. #56 is left open, unchanged, for its
author to decide on.
Still to do
8176b622and this body was written afterevery run above had finished, on that head.
tmp/pr-matrix-113is still there at0205cf17. Deletinga branch is refused to the sign-in that started the build, so whoever
merges this draft should delete it.
has to build again once this merges, because its current build is on
rcat9a668883.