feat(19.7-01): account contributions, prompted record actions and backend subject events
- pact.HasAccountContributions compiled at Activate; GET /account/contributions
and POST /account/contributions/{name}/actions/{action} behind interactiveOnly
(AccountContributionView, AccountContributionActionView, AccountActionResultView)
- RecordAction.prompt (RecordActionPrompt) for a pact.AdminRecordAction with a
Prompt; the record action route accepts payload only for such an action
(trimmed JSON string, non-empty, capped at max_length) and hands it to Run as
Value through CRUDService.RecordActionWithValue; a prompt without a label
fails boot
- fireSubjectChanged: pact.MCPSubjectChanged for revoked tokens, Administrators
saves that changed role, permissions or superuser, Roles saves that changed
grants, deactivation and deletion
- phrases backend::lang.form.action_prompt_required/_too_long (en, pl)
- smoke tests TestAccountContributionsSmoke and TestRecordActionPromptSmoke;
TestRecordActionPromptRun on Postgres; route inventories, CSRF walk and
OpenAPI conformance cases extended for the two routes
- regenerated admin/openapi/admin.json and admin/src/api/schema.d.ts; cabana
README, docs/backend/{admin-controllers,users-and-permissions}.md
This commit is contained in:
@@ -773,6 +773,12 @@ func conformCases() []conformCase {
|
||||
}
|
||||
return e.send(t, http.MethodDelete, fmt.Sprintf("/account/tokens/%d", e.tokenID), nil, true)
|
||||
}, into[cabana.Envelope[cabana.AdminAPIToken]](), nil},
|
||||
{"GET /account/contributions", 200, "cabana.Envelope-array_cabana_AccountContributionView", func(t *testing.T, e *conformEnv) *httptest.ResponseRecorder {
|
||||
return e.send(t, http.MethodGet, "/account/contributions", nil, true)
|
||||
}, into[cabana.Envelope[[]cabana.AccountContributionView]](), nil},
|
||||
{"POST /account/contributions/{name}/actions/{action}", 200, "cabana.Envelope-cabana_AccountActionResultView", func(t *testing.T, e *conformEnv) *httptest.ResponseRecorder {
|
||||
return e.send(t, http.MethodPost, "/account/contributions/conform_link/actions/open", nil, true)
|
||||
}, into[cabana.Envelope[cabana.AccountActionResultView]](), nil},
|
||||
{"POST /auth/logout", 200, "cabana.Envelope-cabana_AdminLogoutData", func(t *testing.T, e *conformEnv) *httptest.ResponseRecorder {
|
||||
return e.send(t, http.MethodPost, "/auth/logout", nil, true)
|
||||
}, into[cabana.Envelope[cabana.AdminLogoutData]](), nil},
|
||||
@@ -1167,6 +1173,21 @@ func (p conformPlugin) AdminControllers() []pact.AdminController {
|
||||
// creates parts under deferral, so cabana's boot requires conformPart here.
|
||||
func (conformPlugin) Models() []any { return []any{&conformGadget{}, &conformPart{}} }
|
||||
|
||||
// AccountContributions is the My account section the conformance cases of
|
||||
// GET /account/contributions and its action route exercise.
|
||||
func (conformPlugin) AccountContributions() []pact.AccountContribution {
|
||||
return []pact.AccountContribution{{
|
||||
Name: "conform_link", Label: "Conformance link", Description: "A section the conformance suite contributes.",
|
||||
Status: func(context.Context, uint) (string, error) { return "linked", nil },
|
||||
Actions: []pact.AccountAction{{
|
||||
Name: "open", Label: "Open",
|
||||
Run: func(_ context.Context, in pact.AccountActionInput) (pact.AccountActionResult, error) {
|
||||
return pact.AccountActionResult{Message: "Opened", URL: "https://conform.example.test/link"}, nil
|
||||
},
|
||||
}},
|
||||
}}
|
||||
}
|
||||
|
||||
func (conformPlugin) Permissions() []pact.Permission {
|
||||
return []pact.Permission{{Code: "acme.conform.access", Roles: []string{"developer"}}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user