open-vault/logical/plugin/mock/path_raw.go
Brian Kassouf 1cee2a1415
plugins/gRPC: fix issues with reserved keywords in response data (#3881)
* plugins/gRPC: fix issues with reserved keywords in response data

* Add the path raw file for mock plugin

* Fix panic when special paths is nil

* Add tests for Listing and raw requests from plugins

* Add json.Number case when decoding the status

* Bump the version required for gRPC defaults

* Fix test for gRPC version check
2018-02-01 14:30:17 -08:00

30 lines
691 B
Go

package mock
import (
"context"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
)
// pathRaw is used to test raw responses.
func pathRaw(b *backend) *framework.Path {
return &framework.Path{
Pattern: "raw",
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathRawRead,
},
}
}
func (b *backend) pathRawRead(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
return &logical.Response{
Data: map[string]interface{}{
logical.HTTPContentType: "text/plain",
logical.HTTPRawBody: []byte("Response"),
logical.HTTPStatusCode: 200,
},
}, nil
}