Repository navigation
test: share the same-answer refusal check and fold the saved repository provisioning cases - #3738
Merged
Merged
Conversation
…ry provisioning cases assertSameAnswer replaces five hand-written missing-versus-unreadable comparisons, and refusedAnswer replaces two local copies of the error-to-answer mapping. The three saved repository access provisioning cases share one fixture, body and worker-failure helper.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
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.
Problem
The finding 2536 slices (#3725, #3732, #3735) and #3726 were written in parallel, and each added its own copy of the same test patterns:
protected-source-refusals.mjsandcredential-source-occeach had a local function that turns a thrown error into the API's status, code and message. Onecredential-source-occcheck calledrequestFailuretwice for one error, and one returned a bare true/false toassert.rejects, so a failure said nothing about the answer it got.postgres-agent-provisioningtests built the same repository policy, Kubernetes topology and second fixture by hand (about 25 lines each), and three of them polled the work row for its error the same way. The saved-access test from fix(api): name saved repository, Credential Proxy deploy and protected source refusals #3732 and the older topology-change test (finding 1145) are the same scenario with a different change after admission, and each built a fresh Namespace per case.refusal-text.mjs.Change
Test-only. No product file changes and no assertion is weakened.
tests/helpers/refusal-answers.mjs:assertSameAnswer(send, ids, { status, label })sends one request per ID and requires the first answer to have the expected status (403 by default), so two identical successes or two not-founds cannot pass. Every other answer must match it exactly once each answer's own ID is hidden. It accepts the three response shapes the tests use (error,body.error, or a flat answer).refusedAnswer(work, options)is the shared error-to-answer mapping. It fails when the work succeeds.assertSameAnswercalls replace the 5 loops incredential-source-occ(update, rotate, delete, create),repository-credentials-admission(PATCH, deploy, Agent create, provisioning),openshell-device-authorization-apiandprotected-source-refusals.refusedAnswerreplaces the fixture'sanswer, the bare true/false check and the withdrawal loop's inline mapping.repositoryProvisioningFixture,repositoryProvisioningBodyandworkerFailurereplace the hand-built setup in 4 tests. The Compute-without-repositories, withdrawn-policy and topology-change cases are now one table in one test. Each case still admits its own job, makes its own change, and checks the status. The topology case also still checks the retry answer. They share one Namespace and fixture, and each case restores the Drivers first. Composed fixtures go from 6 to 2 and Namespace bootstraps from 3 to 1. The topology case also gains the status-endpoint check that the other two had.COMPUTE_TOPOLOGY_REPOSITORY_UNSUPPORTEDandPROVISIONING_NOT_COMPLETEDare added at the end ofrefusal-text.mjs. They replace 8 pasted copies in the two files this PR touches.Left alone on purpose:
credential-source-occ(Gateway source, controller) and inprotected-source-refusals(Proxy-owned source, HTTP). Those are different setups.occ-apiandconfiguration-controllercompare whole error objects or successes, which the helper does not model.Diff: 8 files, +249/−309 (51 of the added lines are the new helper).
Verification
credential-source-occ,repository-credentials-admission,openshell-device-authorization-apiandprotected-source-refusalspassed 20/20 at 2 CPUs, 99 tests per run.postgres-agent-provisioningpassed 20/20 at 2 CPUs, with a fresh database per run (57 tests).run-tests.mjs audit, eslint, prettier andtsc --buildpass.Risks
Low; tests only. The folded provisioning cases share a Namespace. Each admits a separate job, and failed jobs are permanent, so no case can pick up another's work. A restore that leaked between cases would fail a later case; it would not hide a failure.