Sort the capabilities before returning
This commit is contained in:
parent
a6f6cbd95a
commit
6831e2a8fd
|
@ -1,5 +1,7 @@
|
|||
package vault
|
||||
|
||||
import "sort"
|
||||
|
||||
// Struct to identify user input errors.
|
||||
// This is helpful in responding the appropriate status codes to clients
|
||||
// from the HTTP endpoints.
|
||||
|
@ -52,5 +54,7 @@ func (c *Core) Capabilities(token, path string) ([]string, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return acl.Capabilities(path), nil
|
||||
capabilities := acl.Capabilities(path)
|
||||
sort.Strings(capabilities)
|
||||
return capabilities, nil
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ func testCapabilities(t *testing.T, endpoint string) {
|
|||
}
|
||||
|
||||
actual = resp.Data["capabilities"]
|
||||
expected = []string{"sudo", "update", "create"}
|
||||
expected = []string{"create", "sudo", "update"}
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: got\n%#v\nexpected\n%#v\n", actual, expected)
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ func TestSystemBackend_CapabilitiesAccessor(t *testing.T) {
|
|||
}
|
||||
|
||||
actual = resp.Data["capabilities"]
|
||||
expected = []string{"sudo", "update", "create"}
|
||||
expected = []string{"create", "sudo", "update"}
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: got\n%#v\nexpected\n%#v\n", actual, expected)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue