style: gofmt
This commit is contained in:
@@ -50,7 +50,7 @@ type console struct {
|
||||
// errStream is the stream the root's error block goes to, when the
|
||||
// console belongs to a root (ErrWriter); nil means err.
|
||||
errStream io.Writer
|
||||
lookup func(string) string
|
||||
lookup func(string) string
|
||||
// tty is true when stdout is a terminal; it picks animated widgets
|
||||
// and boxed tables.
|
||||
tty bool
|
||||
|
||||
@@ -155,8 +155,8 @@ func TestAccountTokens(t *testing.T) {
|
||||
|
||||
// 422 rules with server message text.
|
||||
cases := []struct {
|
||||
name string
|
||||
body map[string]any
|
||||
name string
|
||||
body map[string]any
|
||||
field string
|
||||
msg string
|
||||
}{
|
||||
|
||||
@@ -48,7 +48,9 @@ func TestFieldTriggerSmoke(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
trig := func(body string) string { return base + " notes:\n type: textarea\n trigger:\n" + body }
|
||||
trig := func(body string) string {
|
||||
return base + " notes:\n type: textarea\n trigger:\n" + body
|
||||
}
|
||||
for _, tc := range []struct{ name, fields, want string }{
|
||||
{"unknown action", trig(" action: show\n field: is_admin\n condition: checked\n"), "action show is not supported"},
|
||||
{"unknown condition", trig(" action: hide\n field: is_admin\n condition: value[1]\n"), "condition value[1] is not supported"},
|
||||
|
||||
@@ -28,9 +28,9 @@ type tokenDemoWidget struct {
|
||||
Name string `gorm:"column:name"`
|
||||
}
|
||||
|
||||
func (tokenDemoWidget) TableName() string { return "cabana_token_demo_widgets" }
|
||||
func (tokenDemoWidget) Fillable() []string { return []string{"name"} }
|
||||
func (tokenDemoWidget) Rules() map[string]string { return map[string]string{} }
|
||||
func (tokenDemoWidget) TableName() string { return "cabana_token_demo_widgets" }
|
||||
func (tokenDemoWidget) Fillable() []string { return []string{"name"} }
|
||||
func (tokenDemoWidget) Rules() map[string]string { return map[string]string{} }
|
||||
|
||||
type tokenDemoPlugin struct{ fsys fs.FS }
|
||||
|
||||
|
||||
@@ -28,83 +28,83 @@ const (
|
||||
// tokenRouteClasses maps every phase09Routes key to its personal-token class.
|
||||
// Adding a route without a class fails TestTokenRouteGates.
|
||||
var tokenRouteClasses = map[string]tokenRouteClass{
|
||||
"POST /auth/login": classPublic,
|
||||
"POST /auth/login": classPublic,
|
||||
"POST /auth/refresh": classInteractive, // public to JWT, but interactive-only for tokens
|
||||
"GET /lang": classPublic,
|
||||
"POST /auth/logout": classInteractive,
|
||||
"GET /auth/me": classOpenAnyToken,
|
||||
"GET /lang": classPublic,
|
||||
"POST /auth/logout": classInteractive,
|
||||
"GET /auth/me": classOpenAnyToken,
|
||||
|
||||
"PUT /account": classInteractive,
|
||||
"GET /account/preferences": classInteractive,
|
||||
"PUT /account/preferences": classInteractive,
|
||||
"POST /account/avatar": classInteractive,
|
||||
"DELETE /account/avatar": classInteractive,
|
||||
"GET /account/tokens": classInteractive,
|
||||
"POST /account/tokens": classInteractive,
|
||||
"GET /account/tokens/scopes": classInteractive,
|
||||
"DELETE /account/tokens/{id}": classInteractive,
|
||||
"GET /account/contributions": classInteractive,
|
||||
"PUT /account": classInteractive,
|
||||
"GET /account/preferences": classInteractive,
|
||||
"PUT /account/preferences": classInteractive,
|
||||
"POST /account/avatar": classInteractive,
|
||||
"DELETE /account/avatar": classInteractive,
|
||||
"GET /account/tokens": classInteractive,
|
||||
"POST /account/tokens": classInteractive,
|
||||
"GET /account/tokens/scopes": classInteractive,
|
||||
"DELETE /account/tokens/{id}": classInteractive,
|
||||
"GET /account/contributions": classInteractive,
|
||||
"POST /account/contributions/{name}/actions/{action}": classInteractive,
|
||||
|
||||
"GET /navigation": classAllowsNav,
|
||||
"GET /field-types": classExplicitGate,
|
||||
"GET /settings": classAllowsSettings,
|
||||
"GET /plugins": classAllowsProtect,
|
||||
"GET /plugins/marketplace": classAllowsProtect,
|
||||
"GET /settings/{code}/schema": classAllowsSettings,
|
||||
"GET /settings/{code}": classAllowsSettings,
|
||||
"PUT /settings/{code}": classAllowsSettings,
|
||||
"POST /markdown/preview": classExplicitGate,
|
||||
"GET /navigation": classAllowsNav,
|
||||
"GET /field-types": classExplicitGate,
|
||||
"GET /settings": classAllowsSettings,
|
||||
"GET /plugins": classAllowsProtect,
|
||||
"GET /plugins/marketplace": classAllowsProtect,
|
||||
"GET /settings/{code}/schema": classAllowsSettings,
|
||||
"GET /settings/{code}": classAllowsSettings,
|
||||
"PUT /settings/{code}": classAllowsSettings,
|
||||
"POST /markdown/preview": classExplicitGate,
|
||||
|
||||
"GET /{vendor}/{plugin}/{controller}/schema/list": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/schema/form": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/schema/relation/{name}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/partials/{name}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/fields/{field}/options": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/fields/{field}/dependent-options": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/filters/{scope}/options": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/bulk-delete": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/reorder": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/reorder": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/singleton": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/bulk/{action}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/widgets/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/toolbar/{action}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||
"DELETE /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/actions/{action}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/candidates": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/link": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/unlink": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/delete": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/pivot/{child}": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}/relations/{name}/pivot/{child}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/reorder": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/{file}": classAllowsProtect,
|
||||
"DELETE /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/{file}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/schema/list": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/schema/form": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/schema/relation/{name}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/partials/{name}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/fields/{field}/options": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/fields/{field}/dependent-options": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/filters/{scope}/options": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/bulk-delete": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/reorder": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/reorder": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/singleton": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/bulk/{action}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/widgets/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/toolbar/{action}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||
"DELETE /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/actions/{action}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/candidates": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/link": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/unlink": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/delete": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/pivot/{child}": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}/relations/{name}/pivot/{child}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/reorder": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/{file}": classAllowsProtect,
|
||||
"DELETE /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/{file}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/{file}/download": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/{file}/thumb": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/files/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/files/{field}/reorder": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}": classAllowsProtect,
|
||||
"DELETE /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/download": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/thumb": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/fields/{field}/upload": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/files/{field}": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/files/{field}/reorder": classAllowsProtect,
|
||||
"PUT /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}": classAllowsProtect,
|
||||
"DELETE /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/download": classAllowsProtect,
|
||||
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/thumb": classAllowsProtect,
|
||||
"POST /{vendor}/{plugin}/{controller}/{id}/fields/{field}/upload": classAllowsProtect,
|
||||
|
||||
"GET /assets/{vendor}/{plugin}/{file...}": classPublic,
|
||||
"GET ": classPublic,
|
||||
"GET /{path...}": classPublic,
|
||||
"GET ": classPublic,
|
||||
"GET /{path...}": classPublic,
|
||||
}
|
||||
|
||||
func TestTokenRouteGates(t *testing.T) {
|
||||
|
||||
@@ -91,9 +91,9 @@ func TestAllowsScope(t *testing.T) {
|
||||
p: dev, scope: &bouncer.ScopeLimit{Full: true}, required: nil, want: true,
|
||||
},
|
||||
{
|
||||
name: "plugin scope with owner grant",
|
||||
p: dev,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||
name: "plugin scope with owner grant",
|
||||
p: dev,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||
required: []string{"acme.demo.access"}, want: true,
|
||||
},
|
||||
{
|
||||
@@ -106,27 +106,27 @@ func TestAllowsScope(t *testing.T) {
|
||||
required: []string{"acme.demo.access"}, want: false,
|
||||
},
|
||||
{
|
||||
name: "superuser with scoped token limited",
|
||||
p: super,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.reports"}}},
|
||||
name: "superuser with scoped token limited",
|
||||
p: super,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.reports"}}},
|
||||
required: []string{"acme.demo.access"}, want: false,
|
||||
},
|
||||
{
|
||||
name: "superuser scoped token matching scope code",
|
||||
p: super,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.reports"}}},
|
||||
name: "superuser scoped token matching scope code",
|
||||
p: super,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.reports"}}},
|
||||
required: []string{"acme.demo.reports"}, want: true,
|
||||
},
|
||||
{
|
||||
name: "empty requirement list refused unless full",
|
||||
p: dev,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||
name: "empty requirement list refused unless full",
|
||||
p: dev,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||
required: nil, want: false,
|
||||
},
|
||||
{
|
||||
name: "multi-code literal: one scope must match every code",
|
||||
p: dev,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||
name: "multi-code literal: one scope must match every code",
|
||||
p: dev,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||
required: []string{"acme.demo.access", "acme.demo.reports"}, want: true,
|
||||
},
|
||||
{
|
||||
@@ -148,9 +148,9 @@ func TestAllowsScope(t *testing.T) {
|
||||
required: []string{"acme.demo.*"}, want: true,
|
||||
},
|
||||
{
|
||||
name: "wildcard requirement equal pattern full",
|
||||
p: dev,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||
name: "wildcard requirement equal pattern full",
|
||||
p: dev,
|
||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||
required: []string{"acme.demo.*"}, want: true,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -27,8 +27,8 @@ func TestLoadStringFromAppSection(t *testing.T) {
|
||||
|
||||
func TestOpenDefaultsEnvToProduction(t *testing.T) {
|
||||
dir := writeConfigTree(t, map[string]string{
|
||||
"app.yaml": "name: base\ndebug: false\n",
|
||||
"env/production/app.yaml": "debug: true\n",
|
||||
"app.yaml": "name: base\ndebug: false\n",
|
||||
"env/production/app.yaml": "debug: true\n",
|
||||
"env/development/app.yaml": "name: dev\n",
|
||||
})
|
||||
cfg, err := Open(Options{Dir: dir, Environ: []string{}})
|
||||
@@ -186,8 +186,8 @@ func TestEnvVarsOverridePluginDefaults(t *testing.T) {
|
||||
|
||||
func TestPriorityRuntimeSetThenPersistThenEnvThenOverlayThenBaseThenPlugin(t *testing.T) {
|
||||
dir := writeConfigTree(t, map[string]string{
|
||||
"app.yaml": "name: base\n",
|
||||
"env/development/app.yaml": "name: overlay\n",
|
||||
"app.yaml": "name: base\n",
|
||||
"env/development/app.yaml": "name: overlay\n",
|
||||
"env/development/overrides.yaml": "app:\n name: persisted\n",
|
||||
})
|
||||
cfg, err := Open(Options{
|
||||
@@ -408,7 +408,7 @@ func TestDotEnvDoesNotOverrideRealEnviron(t *testing.T) {
|
||||
|
||||
func TestDottedPluginNamespaceAndTypedSection(t *testing.T) {
|
||||
dir := writeConfigTree(t, map[string]string{
|
||||
"app.yaml": "name: hello-app\n",
|
||||
"app.yaml": "name: hello-app\n",
|
||||
"golem15.hello.yaml": "from_app: true\n",
|
||||
})
|
||||
cfg, err := Open(Options{Dir: dir, Environ: []string{}})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
func TestSetWinsOverPersistedOverrides(t *testing.T) {
|
||||
dir := writeConfigTree(t, map[string]string{
|
||||
"app.yaml": "name: base\n",
|
||||
"app.yaml": "name: base\n",
|
||||
"env/development/overrides.yaml": "app:\n name: persisted\n",
|
||||
})
|
||||
cfg, err := Open(Options{Dir: dir, Env: "development", Environ: []string{}})
|
||||
|
||||
@@ -234,7 +234,7 @@ or any send fails, after listing the common causes.`,
|
||||
{Command: TestPushCommandName + " 42", Description: "Send a test notification to user 42's browsers"},
|
||||
{Command: TestPushCommandName + " 42 -n", Description: "Send without the confirmation question"},
|
||||
},
|
||||
Args: []bonfire.Arg{{Name: "user_id", Description: "User ID to send test notification to", Required: true}},
|
||||
Args: []bonfire.Arg{{Name: "user_id", Description: "User ID to send test notification to", Required: true}},
|
||||
Flags: []bonfire.Flag{
|
||||
// Accepted for compatibility: the configuration is always shown.
|
||||
{Name: "show-config", Bare: true, Description: "Display current push configuration"},
|
||||
|
||||
@@ -483,7 +483,6 @@ func assertJSON(t *testing.T, v any, want string) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// fakeTB records CheckT's calls.
|
||||
type fakeTB struct {
|
||||
helpers int
|
||||
|
||||
@@ -55,10 +55,10 @@ func TestFlowMismatchContinuesAndCaptureSkipsRest(t *testing.T) {
|
||||
Name: "capture-skip",
|
||||
Steps: []Step{
|
||||
{
|
||||
ID: "a",
|
||||
Request: Request{Method: http.MethodGet, Path: "/two"},
|
||||
ID: "a",
|
||||
Request: Request{Method: http.MethodGet, Path: "/two"},
|
||||
Response: Response{Status: 200, Headers: jsonCT(), Body: Body(`{"data":"ok"}`)},
|
||||
Capture: []CaptureRule{{From: "response.json", Path: "$.token", As: "jwt:alice"}},
|
||||
Capture: []CaptureRule{{From: "response.json", Path: "$.token", As: "jwt:alice"}},
|
||||
},
|
||||
{
|
||||
ID: "b",
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestHeadersReplayAgainstServer(t *testing.T) {
|
||||
Version: 1,
|
||||
Name: "headers",
|
||||
Steps: []Step{{
|
||||
ID: "h",
|
||||
ID: "h",
|
||||
Request: Request{Method: http.MethodGet, Path: "/"},
|
||||
Response: Response{
|
||||
Status: 200,
|
||||
|
||||
Reference in New Issue
Block a user