Skip to content

Commit 389a404

Browse files
authored
Merge pull request #3 from segmentio/list-stop-matching-prefix
List should match service exactly
2 parents 68969f1 + 07103ba commit 389a404

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

store/ssmstore.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (s *SSMStore) List(service string, includeValues bool) ([]Secret, error) {
172172
Filters: []*ssm.ParametersFilter{
173173
{
174174
Key: aws.String("Name"),
175-
Values: []*string{aws.String(service)},
175+
Values: []*string{aws.String(service + ".")},
176176
},
177177
},
178178
NextToken: nextToken,

store/ssmstore_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,16 @@ func TestList(t *testing.T) {
292292
assert.Equal(t, "value", *secret.Value)
293293
}
294294
})
295+
296+
t.Run("List should only return exact matches on service name", func(t *testing.T) {
297+
store.Write(SecretId{Service: "match", Key: "a"}, "val")
298+
store.Write(SecretId{Service: "matchlonger", Key: "a"}, "val")
299+
300+
s, err := store.List("match", false)
301+
assert.Nil(t, err)
302+
assert.Equal(t, 1, len(s))
303+
assert.Equal(t, "match.a", s[0].Meta.Key)
304+
})
295305
}
296306

297307
func TestHistory(t *testing.T) {

0 commit comments

Comments
 (0)