Return nil instead of empty list when returning a PermissionDenied error, updated unit test
This commit is contained in:
parent
da29b74d03
commit
307049e17f
|
@ -26,7 +26,7 @@ func FilterDirEnt(acl acl.ACL, ent structs.DirEntries) (structs.DirEntries, erro
|
||||||
df := dirEntFilter{acl: acl, ent: ent}
|
df := dirEntFilter{acl: acl, ent: ent}
|
||||||
filtered := ent[:FilterEntries(&df)]
|
filtered := ent[:FilterEntries(&df)]
|
||||||
if len(filtered) == 0 {
|
if len(filtered) == 0 {
|
||||||
return filtered, errPermissionDenied
|
return nil, errPermissionDenied
|
||||||
}
|
}
|
||||||
return filtered, nil
|
return filtered, nil
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func FilterKeys(acl acl.ACL, keys []string) ([]string, error) {
|
||||||
kf := keyFilter{acl: acl, keys: keys}
|
kf := keyFilter{acl: acl, keys: keys}
|
||||||
filteredKeys := keys[:FilterEntries(&kf)]
|
filteredKeys := keys[:FilterEntries(&kf)]
|
||||||
if len(filteredKeys) == 0 {
|
if len(filteredKeys) == 0 {
|
||||||
return filteredKeys, errPermissionDenied
|
return nil, errPermissionDenied
|
||||||
}
|
}
|
||||||
return filteredKeys, nil
|
return filteredKeys, nil
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ func FilterTxnResults(acl acl.ACL, results structs.TxnResults) (structs.TxnResul
|
||||||
rf := txnResultsFilter{acl: acl, results: results}
|
rf := txnResultsFilter{acl: acl, results: results}
|
||||||
filtered := results[:FilterEntries(&rf)]
|
filtered := results[:FilterEntries(&rf)]
|
||||||
if len(filtered) == 0 {
|
if len(filtered) == 0 {
|
||||||
return filtered, errPermissionDenied
|
return nil, errPermissionDenied
|
||||||
}
|
}
|
||||||
return filtered, nil
|
return filtered, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,6 @@ func TestFilter_Keys(t *testing.T) {
|
||||||
},
|
},
|
||||||
tcase{
|
tcase{
|
||||||
in: []string{"abe", "lincoln"},
|
in: []string{"abe", "lincoln"},
|
||||||
out: []string{},
|
|
||||||
err: errPermissionDenied,
|
err: errPermissionDenied,
|
||||||
},
|
},
|
||||||
tcase{
|
tcase{
|
||||||
|
|
Loading…
Reference in New Issue