File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,29 @@ func (k *KVv1) Read(key string) (*KVv1ReadResponse, error) {
61
61
return readRes , nil
62
62
}
63
63
64
+ type KVv1ListResponse struct {
65
+ Data struct {
66
+ Keys []string `json:"keys"`
67
+ } `json:"data"`
68
+ }
69
+
70
+ func (k * KVv1 ) List (key string ) (* KVv1ListResponse , error ) {
71
+ listRes := & KVv1ListResponse {}
72
+
73
+ err := k .client .List (
74
+ []string {
75
+ pathPrefix ,
76
+ k .MountPoint ,
77
+ url .PathEscape (key ),
78
+ }, nil , listRes , nil ,
79
+ )
80
+ if err != nil {
81
+ return nil , err
82
+ }
83
+
84
+ return listRes , nil
85
+ }
86
+
64
87
func (k * KVv1 ) Delete (key string ) error {
65
88
err := k .client .Delete (
66
89
[]string {
Original file line number Diff line number Diff line change @@ -79,3 +79,19 @@ func (s *KVv1TestSuite) TestCreateAndDelete() {
79
79
_ , readErr := s .client .Read ("2b7ff26d-30b7-43ba-96d5-79b4baba9b39" )
80
80
require .Error (s .T (), readErr )
81
81
}
82
+
83
+ func (s * KVv1TestSuite ) TestCreateAndList () {
84
+ testKeyValues := make (map [string ]string )
85
+ testKeyValues ["PrivateKey" ] = "abcde"
86
+
87
+ require .NoError (s .T (), s .client .Create ("foo" , testKeyValues ))
88
+ require .NoError (s .T (), s .client .Create ("foo2" , testKeyValues ))
89
+
90
+ list , listErr := s .client .List ("" )
91
+ require .NoError (s .T (), listErr )
92
+
93
+ require .Contains (s .T (), list .Data .Keys , "foo" )
94
+ require .Contains (s .T (), list .Data .Keys , "foo2" )
95
+ require .Len (s .T (), list .Data .Keys , 2 )
96
+
97
+ }
You can’t perform that action at this time.
0 commit comments