Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button check to validateUILayout #11

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/brokers/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ func validateUILayout(layout map[string]string) (r map[string]string, err error)
if !slices.Contains([]string{"true", "false", ""}, wait) {
return nil, fmt.Errorf("'wait' does not match allowed values for this type: %v", wait)
}
if button != "" && wait != "true" {
return nil, errors.New("button is not allowed if wait is not true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit, do you mind aligning to fmt.Errorf since it's used throughout the function? Or changing the other calls with no interpolations to use errors.New as well (in a separate commit obviously).

}
r["label"] = label
r["entry"] = entry
r["button"] = button
Expand Down
1 change: 1 addition & 0 deletions internal/brokers/examplebroker/examplebroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func (b *Broker) GetAuthenticationModes(ctx context.Context, sessionID string, s
"label": "Enter your one time credential",
"entry": "chars",
"button": "Resend sms",
"wait": "true",
}),
}
} else {
Expand Down