Repository navigation
Move janitor's policies routes onto HttpApi - #134
Merged
Merged
Conversation
Tests only: a new Ingress/Policies test calls the policies group through
makeClient. It covers list, get, listVersions and validate, writes made
as the Access identity, and each endpoint's refusals by tag and fields:
RepositoryNotFound, RepositoryBlocked on writes, PolicyNotFound,
PolicyConflict, PolicyNameTaken, PolicyInvalid { diagnostic }, PolicyInUse
and PolicyHistoryRetained on delete. The policy cases leave the raw Rules
test, which keeps an unused Policies for the rule-test route.
The Policies service tests read PolicyInvalid.diagnostic, expect
PolicyHistoryRetained for the retained-history delete block, and expect
RepositoryBlocked "disconnected" for a write to a disconnected repository.
Ownership reads diagnostic too.
They fail until the policies group and the domain errors land.
The policies group (list, get, listVersions, create, update, publish,
delete and validate) joins JanitorApi, and the cluster serves it through
HttpApiBuilder behind the API middleware. The raw Ingress/Rules.ts and
its test become LabelingRoutes, freeing the name for the rules group.
PolicyNotFound, PolicyConflict, PolicyNameTaken, PolicyInUse,
PolicyHistoryRetained and PolicyInvalid { diagnostic } move into
Labeling/Policy/Configuration as tagged errors with their statuses. The
retained-history delete block is PolicyHistoryRetained (409, was a 422
PolicyInvalid). PoliciesError goes: SQL, decode and configuration
failures die. withRepositoryMutation fails a disconnected repository with
RepositoryBlocked "disconnected" and lets SQL failures die, so the raw
rule routes now answer that with a 409 RepositoryBlocked body instead of a
503.
The web policy editor and workspace call api.policies.* and own the copy
for each tag. Drafts decode into the domain ProgramSource before they are
sent. The labeling-wire copies of PolicyDetail, PolicyVersionRecord,
ValidatePolicyResponse, Manifest and the policy endpoint paths go.
Test updates are mechanical: the raw-route tests import LabelingRoutes,
GroupsApi saves its invalid draft through the service, and web fixtures
use branded ids and the draft's caseSensitive default.
Tests only: the Policies service test creates a policy under a repository janitor doesn't know and expects RepositoryNotFound, ahead of the disconnected case it shares a test with. Today withRepositoryMutation reads a missing row as disconnected, so this fails with RepositoryBlocked.
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.
Moves the
policiesgroup ontoHttpApi:list,get,listVersions,create,update,publish,deleteandvalidate. This is the first of the four Labeling PRs, so it also renames the rawIngress/Rules.tstoIngress/LabelingRoutes.ts(and its test toLabelingRoutes.test.ts). Therulesgroup needs theRules.tsname.Api/Policies.tsdefines the group, andJanitorApiadds it.Labeling/Policy/Configuration.tsgainsPolicyNotFound(404),PolicyConflict { current }(409),PolicyNameTaken { name }(409),PolicyInUse { policyId, rules, references }(409),PolicyHistoryRetained { policyId }(409) andPolicyInvalid { diagnostic }(422). Each endpoint declares only the errors it can fail with.createanswers 201 anddeleteanswers 204, as before.Ingress/Policies.tsis oneHttpApiBuilder.grouplayer, merged inRoutes.tsbehind the API middleware.Policiesservice fails with the domain classes directly, typed per method.PoliciesErroris gone: SQL, decode and configuration failures die.PolicyHistoryRetained(409). It used to be a 422PolicyInvalid.withRepositoryMutationfails a disconnected repository withRepositoryBlocked { reason: "disconnected" }and lets SQL failures die. The rules service shares it.LabelingRoutes.ts: the policy routes and their tags leavehandledTags, theHandledunion andrespond.RepositoryBlockedjoins them and answers 409 with the tagged body. A rule write to a disconnected repository used to be a 503.api.policies.*. They map each tag to their own copy withcatchTag/catchTags, and a fallback covers everything else.ProgramSourcebefore it's sent. A draft that doesn't decode gets "The draft isn't in the policy format." instead of a server 400.DeleteSubjectuntil the rules group moves.labeling-wire.tsloses its copies ofPolicyDetail,PolicyVersionRecord,ValidatePolicyResponseandManifest, and the policy endpoint paths.Ingress/Policies.test.tsonmakeClient, and the service tests readingdiagnostic,PolicyHistoryRetainedandRepositoryBlocked. The second commit makes only mechanical test changes:LabelingRoutes.GroupsApi.test.tssaves its invalid draft through the service, because the rawPUT /policies/:idis gone.caseSensitive: falsedefault, because foldkit validates message payloads against the domainPolicyDetail.vp checkreports 0 errors, andvp testpasses all 130 files and 817 tests.Closes EFF-2520