style: gofmt

This commit is contained in:
Jakub Zych
2026-11-05 01:00:36 +01:00
parent 9c11b7064d
commit 6d14f71ae5
15 changed files with 116 additions and 115 deletions

View File

@@ -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
}{

View File

@@ -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"},

View File

@@ -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 }

View File

@@ -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) {

View File

@@ -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,
},
{