test: Fix test flake in client get registration token (#26796)

The test was incorrectly writing to state that registration had
been finished before writing the node identity token. This is the
opposite of what happens in the client code and caused a timing
issue which meant we read registration as completed before we had
the identity available and therefore returned the secret ID.
This commit is contained in:
James Rasell
2025-09-18 13:56:17 +01:00
committed by GitHub
parent 46dfd9d992
commit a206ff3858

View File

@@ -1515,14 +1515,16 @@ func TestClient_getRegistrationToken(t *testing.T) {
})
t.Cleanup(func() { _ = testClientCleanup() })
// Ensure the identity is written to state before marking as registered,
// as would happen in a real client.
must.NoError(t, testClient.stateDB.PutNodeIdentity("my-identity-token"))
must.NoError(t, testClient.stateDB.PutNodeRegistration(
&cstructs.NodeRegistration{
HasRegistered: true,
},
))
must.NoError(t, testClient.stateDB.PutNodeIdentity("my-identity-token"))
must.Eq(t, "my-identity-token", testClient.getRegistrationToken())
})
}