Sort the capabilities before returning

This commit is contained in:
vishalnayak 2016-03-18 12:40:17 -04:00
parent a6f6cbd95a
commit 6831e2a8fd
2 changed files with 7 additions and 3 deletions

View File

@ -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
}

View File

@ -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)
}