mirror of
https://github.com/hashicorp/vault.git
synced 2026-04-29 02:01:35 -04:00
secret/kv: Sort keys during list operation (#4845)
This commit is contained in:
parent
c2f8c0f4cd
commit
6607b425be
2 changed files with 4 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"math/big"
|
||||
paths "path"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/golang-lru"
|
||||
|
|
@ -205,6 +206,7 @@ func (s *encryptedKeyStorage) List(ctx context.Context, prefix string) ([]string
|
|||
decryptedKeys[i] = plaintext
|
||||
}
|
||||
|
||||
sort.Strings(decryptedKeys)
|
||||
return decryptedKeys, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ func TestEncryptedKeysStorage_List(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(keys) != 2 || !strutil.StrListContains(keys, "foo1/") || !strutil.StrListContains(keys, "foo") {
|
||||
if len(keys) != 2 || keys[1] != "foo1/" || keys[0] != "foo" {
|
||||
t.Fatalf("bad keys: %#v", keys)
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ func TestEncryptedKeysStorage_List(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(keys) != 2 || !strutil.StrListContains(keys, "test") || !strutil.StrListContains(keys, "test/") {
|
||||
if len(keys) != 2 || keys[0] != "test" || keys[1] != "test/" {
|
||||
t.Fatalf("bad keys: %#v", keys)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue