Skip to content

Commit

Permalink
test: fix linter warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Flavio Castelli <[email protected]>
  • Loading branch information
flavio committed Sep 17, 2024
1 parent bb28084 commit 969b3aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func main() {
//nolint: mnd
if len(os.Args) != 2 {
log.Fatalln("Wrong usage, expected either 'validate' or `validate-settings'")
}
Expand Down
4 changes: 4 additions & 0 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func validate(input []byte) []byte {
decoder.DisallowUnknownFields()
err := decoder.Decode(&validationRequest)
if err != nil {
//nolint: mnd
return marshalValidationResponseOrFail(
RejectRequest(
Message(fmt.Sprintf("Error deserializing validation request: %v", err)),
Expand All @@ -47,18 +48,21 @@ func validateRequest(settings Settings, request Request) ValidationResponse {
}

if !settings.ValidUsers.Contains(request.User) {
//nolint: mnd
return RejectRequest(
Message(fmt.Sprintf("User '%s' is not allowed", request.User)),
Code(403))
}

if !settings.ValidActions.Contains(request.Action) {
//nolint: mnd
return RejectRequest(
Message(fmt.Sprintf("Action '%s' is not allowed", request.Action)),
Code(403))
}

if !settings.ValidResources.Contains(request.Resource) {
//nolint: mnd
return RejectRequest(
Message(fmt.Sprintf("Resource '%s' is not allowed", request.Resource)),
Code(403))
Expand Down

0 comments on commit 969b3aa

Please sign in to comment.