style: gofmt
This commit is contained in:
@@ -155,7 +155,7 @@ overwritten.`,
|
|||||||
{Command: "make:model acme.blog Post", Description: "A Post model and its create-table migration"},
|
{Command: "make:model acme.blog Post", Description: "A Post model and its create-table migration"},
|
||||||
{Command: "make:model Post --no-migration", Description: "Inside plugins/acme/blog: only the model"},
|
{Command: "make:model Post --no-migration", Description: "Inside plugins/acme/blog: only the model"},
|
||||||
},
|
},
|
||||||
Args: makeArtifactArgs(),
|
Args: makeArtifactArgs(),
|
||||||
Flags: []bonfire.Flag{{
|
Flags: []bonfire.Flag{{
|
||||||
Name: "no-migration",
|
Name: "no-migration",
|
||||||
Description: "Omit the create-table migration",
|
Description: "Omit the create-table migration",
|
||||||
@@ -192,7 +192,7 @@ to apply it.`,
|
|||||||
{Command: "make:migration acme.blog AddSlugToPosts", Description: "An empty migration in acme.blog"},
|
{Command: "make:migration acme.blog AddSlugToPosts", Description: "An empty migration in acme.blog"},
|
||||||
{Command: "make:migration AddSlugToPosts", Description: "The same from inside plugins/acme/blog"},
|
{Command: "make:migration AddSlugToPosts", Description: "The same from inside plugins/acme/blog"},
|
||||||
},
|
},
|
||||||
Args: makeArtifactArgs(),
|
Args: makeArtifactArgs(),
|
||||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -226,7 +226,7 @@ from the plugin's Commands by hand.`,
|
|||||||
{Command: "make:command acme.blog Publish", Description: "A blog:publish command in acme.blog"},
|
{Command: "make:command acme.blog Publish", Description: "A blog:publish command in acme.blog"},
|
||||||
{Command: "make:command Publish", Description: "The same from inside plugins/acme/blog"},
|
{Command: "make:command Publish", Description: "The same from inside plugins/acme/blog"},
|
||||||
},
|
},
|
||||||
Args: makeArtifactArgs(),
|
Args: makeArtifactArgs(),
|
||||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -257,7 +257,7 @@ conga.Manager.Dispatch; queue:work or serve runs it.`,
|
|||||||
{Command: "make:job acme.blog SendDigest", Description: "A SendDigest job in acme.blog"},
|
{Command: "make:job acme.blog SendDigest", Description: "A SendDigest job in acme.blog"},
|
||||||
{Command: "make:job SendDigest", Description: "The same from inside plugins/acme/blog"},
|
{Command: "make:job SendDigest", Description: "The same from inside plugins/acme/blog"},
|
||||||
},
|
},
|
||||||
Args: makeArtifactArgs(),
|
Args: makeArtifactArgs(),
|
||||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func delegateCommands() []bonfire.Command {
|
|||||||
ex := func(cmd, desc string) bonfire.Example { return bonfire.Example{Command: cmd, Description: desc} }
|
ex := func(cmd, desc string) bonfire.Example { return bonfire.Example{Command: cmd, Description: desc} }
|
||||||
rows := []struct {
|
rows := []struct {
|
||||||
name, description, hint string
|
name, description, hint string
|
||||||
examples []bonfire.Example
|
examples []bonfire.Example
|
||||||
}{
|
}{
|
||||||
{"migrate", "Run plugin migrations in the app binary", "--pretend, --force", []bonfire.Example{
|
{"migrate", "Run plugin migrations in the app binary", "--pretend, --force", []bonfire.Example{
|
||||||
ex("migrate", "Apply every pending migration"),
|
ex("migrate", "Apply every pending migration"),
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ func TestDelegateCommandsPassArgs(t *testing.T) {
|
|||||||
|
|
||||||
func TestDelegateCommandsHelp(t *testing.T) {
|
func TestDelegateCommandsHelp(t *testing.T) {
|
||||||
hints := map[string][]string{
|
hints := map[string][]string{
|
||||||
"migrate:rollback": {"--plugin"},
|
"migrate:rollback": {"--plugin"},
|
||||||
"queue:work": {"--queue"},
|
"queue:work": {"--queue"},
|
||||||
"schedule:run": {"--once"},
|
"schedule:run": {"--once"},
|
||||||
"serve": {"--addr"},
|
"serve": {"--addr"},
|
||||||
"admin:create": {"--email", "--superuser"},
|
"admin:create": {"--email", "--superuser"},
|
||||||
"admin:token:create": {"--name", "--scope", "--expires"},
|
"admin:token:create": {"--name", "--scope", "--expires"},
|
||||||
}
|
}
|
||||||
cmds := delegateCommands()
|
cmds := delegateCommands()
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ type console struct {
|
|||||||
// errStream is the stream the root's error block goes to, when the
|
// errStream is the stream the root's error block goes to, when the
|
||||||
// console belongs to a root (ErrWriter); nil means err.
|
// console belongs to a root (ErrWriter); nil means err.
|
||||||
errStream io.Writer
|
errStream io.Writer
|
||||||
lookup func(string) string
|
lookup func(string) string
|
||||||
// tty is true when stdout is a terminal; it picks animated widgets
|
// tty is true when stdout is a terminal; it picks animated widgets
|
||||||
// and boxed tables.
|
// and boxed tables.
|
||||||
tty bool
|
tty bool
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ func TestAccountTokens(t *testing.T) {
|
|||||||
|
|
||||||
// 422 rules with server message text.
|
// 422 rules with server message text.
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
name string
|
name string
|
||||||
body map[string]any
|
body map[string]any
|
||||||
field string
|
field string
|
||||||
msg 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 }{
|
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 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"},
|
{"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"`
|
Name string `gorm:"column:name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tokenDemoWidget) TableName() string { return "cabana_token_demo_widgets" }
|
func (tokenDemoWidget) TableName() string { return "cabana_token_demo_widgets" }
|
||||||
func (tokenDemoWidget) Fillable() []string { return []string{"name"} }
|
func (tokenDemoWidget) Fillable() []string { return []string{"name"} }
|
||||||
func (tokenDemoWidget) Rules() map[string]string { return map[string]string{} }
|
func (tokenDemoWidget) Rules() map[string]string { return map[string]string{} }
|
||||||
|
|
||||||
type tokenDemoPlugin struct{ fsys fs.FS }
|
type tokenDemoPlugin struct{ fsys fs.FS }
|
||||||
|
|
||||||
|
|||||||
@@ -28,83 +28,83 @@ const (
|
|||||||
// tokenRouteClasses maps every phase09Routes key to its personal-token class.
|
// tokenRouteClasses maps every phase09Routes key to its personal-token class.
|
||||||
// Adding a route without a class fails TestTokenRouteGates.
|
// Adding a route without a class fails TestTokenRouteGates.
|
||||||
var tokenRouteClasses = map[string]tokenRouteClass{
|
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
|
"POST /auth/refresh": classInteractive, // public to JWT, but interactive-only for tokens
|
||||||
"GET /lang": classPublic,
|
"GET /lang": classPublic,
|
||||||
"POST /auth/logout": classInteractive,
|
"POST /auth/logout": classInteractive,
|
||||||
"GET /auth/me": classOpenAnyToken,
|
"GET /auth/me": classOpenAnyToken,
|
||||||
|
|
||||||
"PUT /account": classInteractive,
|
"PUT /account": classInteractive,
|
||||||
"GET /account/preferences": classInteractive,
|
"GET /account/preferences": classInteractive,
|
||||||
"PUT /account/preferences": classInteractive,
|
"PUT /account/preferences": classInteractive,
|
||||||
"POST /account/avatar": classInteractive,
|
"POST /account/avatar": classInteractive,
|
||||||
"DELETE /account/avatar": classInteractive,
|
"DELETE /account/avatar": classInteractive,
|
||||||
"GET /account/tokens": classInteractive,
|
"GET /account/tokens": classInteractive,
|
||||||
"POST /account/tokens": classInteractive,
|
"POST /account/tokens": classInteractive,
|
||||||
"GET /account/tokens/scopes": classInteractive,
|
"GET /account/tokens/scopes": classInteractive,
|
||||||
"DELETE /account/tokens/{id}": classInteractive,
|
"DELETE /account/tokens/{id}": classInteractive,
|
||||||
"GET /account/contributions": classInteractive,
|
"GET /account/contributions": classInteractive,
|
||||||
"POST /account/contributions/{name}/actions/{action}": classInteractive,
|
"POST /account/contributions/{name}/actions/{action}": classInteractive,
|
||||||
|
|
||||||
"GET /navigation": classAllowsNav,
|
"GET /navigation": classAllowsNav,
|
||||||
"GET /field-types": classExplicitGate,
|
"GET /field-types": classExplicitGate,
|
||||||
"GET /settings": classAllowsSettings,
|
"GET /settings": classAllowsSettings,
|
||||||
"GET /plugins": classAllowsProtect,
|
"GET /plugins": classAllowsProtect,
|
||||||
"GET /plugins/marketplace": classAllowsProtect,
|
"GET /plugins/marketplace": classAllowsProtect,
|
||||||
"GET /settings/{code}/schema": classAllowsSettings,
|
"GET /settings/{code}/schema": classAllowsSettings,
|
||||||
"GET /settings/{code}": classAllowsSettings,
|
"GET /settings/{code}": classAllowsSettings,
|
||||||
"PUT /settings/{code}": classAllowsSettings,
|
"PUT /settings/{code}": classAllowsSettings,
|
||||||
"POST /markdown/preview": classExplicitGate,
|
"POST /markdown/preview": classExplicitGate,
|
||||||
|
|
||||||
"GET /{vendor}/{plugin}/{controller}/schema/list": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/schema/list": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/schema/form": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/schema/form": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/schema/relation/{name}": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/schema/relation/{name}": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/partials/{name}": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/partials/{name}": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/fields/{field}/options": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/fields/{field}/options": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/fields/{field}/dependent-options": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/fields/{field}/dependent-options": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/filters/{scope}/options": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/filters/{scope}/options": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/bulk-delete": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/bulk-delete": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/reorder": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/reorder": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/reorder": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/reorder": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/singleton": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/singleton": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/bulk/{action}": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/bulk/{action}": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/widgets/{field}": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/widgets/{field}": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/toolbar/{action}": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/toolbar/{action}": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||||
"PUT /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
"PUT /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||||
"DELETE /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
"DELETE /{vendor}/{plugin}/{controller}/{id}": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/{id}/actions/{action}": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/{id}/actions/{action}": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/candidates": 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}/link": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/unlink": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/unlink": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}": classAllowsProtect,
|
||||||
"PUT /{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,
|
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/delete": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/pivot/{child}": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/pivot/{child}": classAllowsProtect,
|
||||||
"PUT /{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,
|
"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}": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/reorder": 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,
|
"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,
|
"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}/download": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/{file}/thumb": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/{id}/relations/{name}/records/{child}/files/{field}/{file}/thumb": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/{id}/files/{field}": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/{id}/files/{field}": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/{id}/files/{field}/reorder": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/{id}/files/{field}/reorder": classAllowsProtect,
|
||||||
"PUT /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}": classAllowsProtect,
|
"PUT /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}": classAllowsProtect,
|
||||||
"DELETE /{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}/download": classAllowsProtect,
|
||||||
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/thumb": classAllowsProtect,
|
"GET /{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/thumb": classAllowsProtect,
|
||||||
"POST /{vendor}/{plugin}/{controller}/{id}/fields/{field}/upload": classAllowsProtect,
|
"POST /{vendor}/{plugin}/{controller}/{id}/fields/{field}/upload": classAllowsProtect,
|
||||||
|
|
||||||
"GET /assets/{vendor}/{plugin}/{file...}": classPublic,
|
"GET /assets/{vendor}/{plugin}/{file...}": classPublic,
|
||||||
"GET ": classPublic,
|
"GET ": classPublic,
|
||||||
"GET /{path...}": classPublic,
|
"GET /{path...}": classPublic,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTokenRouteGates(t *testing.T) {
|
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,
|
p: dev, scope: &bouncer.ScopeLimit{Full: true}, required: nil, want: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "plugin scope with owner grant",
|
name: "plugin scope with owner grant",
|
||||||
p: dev,
|
p: dev,
|
||||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||||
required: []string{"acme.demo.access"}, want: true,
|
required: []string{"acme.demo.access"}, want: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -106,27 +106,27 @@ func TestAllowsScope(t *testing.T) {
|
|||||||
required: []string{"acme.demo.access"}, want: false,
|
required: []string{"acme.demo.access"}, want: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "superuser with scoped token limited",
|
name: "superuser with scoped token limited",
|
||||||
p: super,
|
p: super,
|
||||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.reports"}}},
|
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.reports"}}},
|
||||||
required: []string{"acme.demo.access"}, want: false,
|
required: []string{"acme.demo.access"}, want: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "superuser scoped token matching scope code",
|
name: "superuser scoped token matching scope code",
|
||||||
p: super,
|
p: super,
|
||||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.reports"}}},
|
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.reports"}}},
|
||||||
required: []string{"acme.demo.reports"}, want: true,
|
required: []string{"acme.demo.reports"}, want: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "empty requirement list refused unless full",
|
name: "empty requirement list refused unless full",
|
||||||
p: dev,
|
p: dev,
|
||||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||||
required: nil, want: false,
|
required: nil, want: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "multi-code literal: one scope must match every code",
|
name: "multi-code literal: one scope must match every code",
|
||||||
p: dev,
|
p: dev,
|
||||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||||
required: []string{"acme.demo.access", "acme.demo.reports"}, want: true,
|
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,
|
required: []string{"acme.demo.*"}, want: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "wildcard requirement equal pattern full",
|
name: "wildcard requirement equal pattern full",
|
||||||
p: dev,
|
p: dev,
|
||||||
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
scope: &bouncer.ScopeLimit{Scopes: [][]string{{"acme.demo.*"}}},
|
||||||
required: []string{"acme.demo.*"}, want: true,
|
required: []string{"acme.demo.*"}, want: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ func TestLoadStringFromAppSection(t *testing.T) {
|
|||||||
|
|
||||||
func TestOpenDefaultsEnvToProduction(t *testing.T) {
|
func TestOpenDefaultsEnvToProduction(t *testing.T) {
|
||||||
dir := writeConfigTree(t, map[string]string{
|
dir := writeConfigTree(t, map[string]string{
|
||||||
"app.yaml": "name: base\ndebug: false\n",
|
"app.yaml": "name: base\ndebug: false\n",
|
||||||
"env/production/app.yaml": "debug: true\n",
|
"env/production/app.yaml": "debug: true\n",
|
||||||
"env/development/app.yaml": "name: dev\n",
|
"env/development/app.yaml": "name: dev\n",
|
||||||
})
|
})
|
||||||
cfg, err := Open(Options{Dir: dir, Environ: []string{}})
|
cfg, err := Open(Options{Dir: dir, Environ: []string{}})
|
||||||
@@ -186,8 +186,8 @@ func TestEnvVarsOverridePluginDefaults(t *testing.T) {
|
|||||||
|
|
||||||
func TestPriorityRuntimeSetThenPersistThenEnvThenOverlayThenBaseThenPlugin(t *testing.T) {
|
func TestPriorityRuntimeSetThenPersistThenEnvThenOverlayThenBaseThenPlugin(t *testing.T) {
|
||||||
dir := writeConfigTree(t, map[string]string{
|
dir := writeConfigTree(t, map[string]string{
|
||||||
"app.yaml": "name: base\n",
|
"app.yaml": "name: base\n",
|
||||||
"env/development/app.yaml": "name: overlay\n",
|
"env/development/app.yaml": "name: overlay\n",
|
||||||
"env/development/overrides.yaml": "app:\n name: persisted\n",
|
"env/development/overrides.yaml": "app:\n name: persisted\n",
|
||||||
})
|
})
|
||||||
cfg, err := Open(Options{
|
cfg, err := Open(Options{
|
||||||
@@ -408,7 +408,7 @@ func TestDotEnvDoesNotOverrideRealEnviron(t *testing.T) {
|
|||||||
|
|
||||||
func TestDottedPluginNamespaceAndTypedSection(t *testing.T) {
|
func TestDottedPluginNamespaceAndTypedSection(t *testing.T) {
|
||||||
dir := writeConfigTree(t, map[string]string{
|
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",
|
"golem15.hello.yaml": "from_app: true\n",
|
||||||
})
|
})
|
||||||
cfg, err := Open(Options{Dir: dir, Environ: []string{}})
|
cfg, err := Open(Options{Dir: dir, Environ: []string{}})
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func TestSetWinsOverPersistedOverrides(t *testing.T) {
|
func TestSetWinsOverPersistedOverrides(t *testing.T) {
|
||||||
dir := writeConfigTree(t, map[string]string{
|
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",
|
"env/development/overrides.yaml": "app:\n name: persisted\n",
|
||||||
})
|
})
|
||||||
cfg, err := Open(Options{Dir: dir, Env: "development", Environ: []string{}})
|
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", Description: "Send a test notification to user 42's browsers"},
|
||||||
{Command: TestPushCommandName + " 42 -n", Description: "Send without the confirmation question"},
|
{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{
|
Flags: []bonfire.Flag{
|
||||||
// Accepted for compatibility: the configuration is always shown.
|
// Accepted for compatibility: the configuration is always shown.
|
||||||
{Name: "show-config", Bare: true, Description: "Display current push configuration"},
|
{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.
|
// fakeTB records CheckT's calls.
|
||||||
type fakeTB struct {
|
type fakeTB struct {
|
||||||
helpers int
|
helpers int
|
||||||
|
|||||||
@@ -55,10 +55,10 @@ func TestFlowMismatchContinuesAndCaptureSkipsRest(t *testing.T) {
|
|||||||
Name: "capture-skip",
|
Name: "capture-skip",
|
||||||
Steps: []Step{
|
Steps: []Step{
|
||||||
{
|
{
|
||||||
ID: "a",
|
ID: "a",
|
||||||
Request: Request{Method: http.MethodGet, Path: "/two"},
|
Request: Request{Method: http.MethodGet, Path: "/two"},
|
||||||
Response: Response{Status: 200, Headers: jsonCT(), Body: Body(`{"data":"ok"}`)},
|
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",
|
ID: "b",
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func TestHeadersReplayAgainstServer(t *testing.T) {
|
|||||||
Version: 1,
|
Version: 1,
|
||||||
Name: "headers",
|
Name: "headers",
|
||||||
Steps: []Step{{
|
Steps: []Step{{
|
||||||
ID: "h",
|
ID: "h",
|
||||||
Request: Request{Method: http.MethodGet, Path: "/"},
|
Request: Request{Method: http.MethodGet, Path: "/"},
|
||||||
Response: Response{
|
Response: Response{
|
||||||
Status: 200,
|
Status: 200,
|
||||||
|
|||||||
Reference in New Issue
Block a user