Merge pull request #2261 from MonsantoCo/github-map-list

Support LIST on auth/github/map/teams and /users
This commit is contained in:
Vishal Nayak 2017-01-11 19:58:06 -05:00 committed by GitHub
commit 8f5c7bc950
2 changed files with 16 additions and 2 deletions

View File

@ -106,7 +106,7 @@ func (p *PathMap) Paths() []*Path {
return []*Path{
&Path{
Pattern: fmt.Sprintf("%s/%s$", p.Prefix, p.Name),
Pattern: fmt.Sprintf("%s/%s/?$", p.Prefix, p.Name),
Callbacks: map[logical.Operation]OperationFunc{
logical.ListOperation: p.pathList,
@ -137,7 +137,7 @@ func (p *PathMap) Paths() []*Path {
func (p *PathMap) pathList(
req *logical.Request, d *FieldData) (*logical.Response, error) {
keys, err := req.Storage.List(req.Path)
keys, err := p.List(req.Storage, "")
if err != nil {
return nil, err
}

View File

@ -65,6 +65,20 @@ func TestPathMap(t *testing.T) {
t.Fatalf("bad: %#v", keys)
}
// LIST via HTTP
resp, err = b.HandleRequest(&logical.Request{
Operation: logical.ListOperation,
Path: "map/foo/",
Storage: storage,
})
if err != nil {
t.Fatalf("bad: %#v", err)
}
if len(resp.Data) != 1 || len(resp.Data["keys"].([]string)) != 1 ||
resp.Data["keys"].([]string)[0] != "a" {
t.Fatalf("bad: %#v", resp)
}
// Delete via HTTP
resp, err = b.HandleRequest(&logical.Request{
Operation: logical.DeleteOperation,