Skip to content

Commit aa946ce

Browse files
authored
fix allowlist case-insensitive lookup (#642)
1 parent 7b9bdb8 commit aa946ce

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

app/allowlist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func SetAllowlist(name string, callers []CallerConfig) error {
113113
// GetAllowlist retrieves the allowlist for an integration.
114114
func GetAllowlist(name string) []CallerConfig {
115115
allowlists.RLock()
116-
m := allowlists.m[name]
116+
m := allowlists.m[strings.ToLower(name)]
117117
res := make([]CallerConfig, 0, len(m))
118118
for _, c := range m {
119119
res = append(res, c)

app/allowlist_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,21 @@ func TestSetAllowlistIndexing(t *testing.T) {
193193
}
194194
}
195195

196+
func TestGetAllowlistCaseInsensitive(t *testing.T) {
197+
allowlists.Lock()
198+
allowlists.m = make(map[string]map[string]CallerConfig)
199+
allowlists.Unlock()
200+
201+
if err := SetAllowlist("MiXeD", []CallerConfig{{ID: "caller"}}); err != nil {
202+
t.Fatalf("failed to set allowlist: %v", err)
203+
}
204+
205+
got := GetAllowlist("MIXED")
206+
if len(got) != 1 || got[0].ID != "caller" {
207+
t.Fatalf("expected case-insensitive allowlist lookup, got %#v", got)
208+
}
209+
}
210+
196211
func TestFindConstraintWildcard(t *testing.T) {
197212
allowlists.Lock()
198213
allowlists.m = make(map[string]map[string]CallerConfig)

0 commit comments

Comments
 (0)