remove nil response to 404 translation for PatchOperation (#13167)
* remove nil response to 404 translation for PatchOperation * go get vault-plugin-secrets-kv@master
This commit is contained in:
parent
e8c9affee1
commit
15b06780ab
2
go.mod
2
go.mod
|
@ -108,7 +108,7 @@ require (
|
|||
github.com/hashicorp/vault-plugin-secrets-azure v0.11.1
|
||||
github.com/hashicorp/vault-plugin-secrets-gcp v0.11.0
|
||||
github.com/hashicorp/vault-plugin-secrets-gcpkms v0.10.0
|
||||
github.com/hashicorp/vault-plugin-secrets-kv v0.10.1
|
||||
github.com/hashicorp/vault-plugin-secrets-kv v0.5.7-0.20211123171606-16933c88368a
|
||||
github.com/hashicorp/vault-plugin-secrets-mongodbatlas v0.5.1
|
||||
github.com/hashicorp/vault-plugin-secrets-openldap v0.6.0
|
||||
github.com/hashicorp/vault-plugin-secrets-terraform v0.3.0
|
||||
|
|
2
go.sum
2
go.sum
|
@ -966,6 +966,8 @@ github.com/hashicorp/vault-plugin-secrets-gcp v0.11.0 h1:3i2uXY/n4jJv71baXeS1q19
|
|||
github.com/hashicorp/vault-plugin-secrets-gcp v0.11.0/go.mod h1:ndpmRkIPHW5UYqv2nn2AJNVZsucJ8lY2bp5i5Ngvhuc=
|
||||
github.com/hashicorp/vault-plugin-secrets-gcpkms v0.10.0 h1:0Vi5WEIpZctk/ZoRClodV9WCnM/lCzw9XekMhRZdo8k=
|
||||
github.com/hashicorp/vault-plugin-secrets-gcpkms v0.10.0/go.mod h1:6DPwGu8oGR1sZRpjwkcAnrQZWQuAJ/Ph+rQHfUo1Yf4=
|
||||
github.com/hashicorp/vault-plugin-secrets-kv v0.5.7-0.20211123171606-16933c88368a h1:GVA3sY+FRhQrMexWGMCsIfVVMgcdru36WMKvDtKed5I=
|
||||
github.com/hashicorp/vault-plugin-secrets-kv v0.5.7-0.20211123171606-16933c88368a/go.mod h1:TNPRoB53Twd9tYvlhqqEhMsQPiVN604kZw9jr2zUzDk=
|
||||
github.com/hashicorp/vault-plugin-secrets-kv v0.10.1 h1:88a6YkbU0FCboZoFdB5uv6ukBf3gc3zDLKM4z64dWxo=
|
||||
github.com/hashicorp/vault-plugin-secrets-kv v0.10.1/go.mod h1:TNPRoB53Twd9tYvlhqqEhMsQPiVN604kZw9jr2zUzDk=
|
||||
github.com/hashicorp/vault-plugin-secrets-mongodbatlas v0.5.1 h1:Maewon4nu0KL1ALBOvL6Rsj+Qyr9hdULWflyMz7+9nk=
|
||||
|
|
|
@ -914,54 +914,6 @@ func kvRequestWithRetry(t *testing.T, req func() (*api.Secret, error)) (*api.Sec
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandler_Patch_NotFound(t *testing.T) {
|
||||
coreConfig := &vault.CoreConfig{
|
||||
LogicalBackends: map[string]logical.Factory{
|
||||
"kv": kv.VersionedKVFactory,
|
||||
},
|
||||
}
|
||||
|
||||
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
|
||||
HandlerFunc: Handler,
|
||||
})
|
||||
|
||||
cluster.Start()
|
||||
defer cluster.Cleanup()
|
||||
|
||||
cores := cluster.Cores
|
||||
|
||||
core := cores[0].Core
|
||||
c := cluster.Cores[0].Client
|
||||
vault.TestWaitActive(t, core)
|
||||
|
||||
// Mount a KVv2 backend
|
||||
err := c.Sys().Mount("kv", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
kvData := map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"bar": "a",
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := kvRequestWithRetry(t, func() (*api.Secret, error) {
|
||||
return c.Logical().JSONMergePatch(context.Background(), "kv/data/foo", kvData)
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("expected PATCH request to fail, resp: %#v\n", resp)
|
||||
}
|
||||
|
||||
responseError := err.(*api.ResponseError)
|
||||
if responseError.StatusCode != http.StatusNotFound {
|
||||
t.Fatalf("expected PATCH request to fail with %d status code - err: %#v, resp: %#v\n", http.StatusNotFound, responseError, resp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandler_Patch_Audit(t *testing.T) {
|
||||
coreConfig := &vault.CoreConfig{
|
||||
LogicalBackends: map[string]logical.Factory{
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
func RespondErrorCommon(req *Request, resp *Response, err error) (int, error) {
|
||||
if err == nil && (resp == nil || !resp.IsError()) {
|
||||
switch {
|
||||
case req.Operation == ReadOperation, req.Operation == PatchOperation:
|
||||
case req.Operation == ReadOperation:
|
||||
if resp == nil {
|
||||
return http.StatusNotFound, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue