-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 [MTA-1455] Fix typo in tackle-migrator role yaml (#566)
The migrator role was not able to access the `targets` resource correctly due to a keyname typo in `roles.yaml`. The incorrectly named `verb` key was ignored by the unmarshaller, which resulted in there being no verbs permitted for the resource. This fixes the typo in the yaml, turns on strict unmarshalling in the `LoadUsers` and `LoadRoles` functions, and then adds a unit test to catch future typos. The tests will catch key typos, typos in http verbs, and typos in user role mappings. Fixes https://issues.redhat.com/browse/MTA-1455 --------- Signed-off-by: Sam Lucidi <[email protected]>
- Loading branch information
Showing
3 changed files
with
46 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package auth | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/go-playground/validator/v10" | ||
"github.com/onsi/gomega" | ||
) | ||
|
||
func TestLoadYaml(t *testing.T) { | ||
g := gomega.NewGomegaWithT(t) | ||
roles, err := LoadRoles("./roles.yaml") | ||
g.Expect(err).To(gomega.BeNil()) | ||
users, err := LoadUsers("./users.yaml") | ||
g.Expect(err).To(gomega.BeNil()) | ||
|
||
validate := validator.New() | ||
var roleNames []string | ||
for _, role := range roles { | ||
err = validate.Struct(role) | ||
g.Expect(err).To(gomega.BeNil()) | ||
for _, resource := range role.Resources { | ||
err = validate.Struct(resource) | ||
g.Expect(err).To(gomega.BeNil()) | ||
} | ||
roleNames = append(roleNames, role.Name) | ||
} | ||
|
||
for _, user := range users { | ||
err = validate.Struct(user) | ||
g.Expect(err).To(gomega.BeNil()) | ||
for _, role := range user.Roles { | ||
g.Expect(role).To(gomega.BeElementOf(roleNames)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -496,7 +496,7 @@ | |
verbs: | ||
- get | ||
- name: targets | ||
verb: | ||
verbs: | ||
- get | ||
- name: analyses | ||
verbs: | ||
|