VAULT-7698 Fix ignored parameter warnings for endpoint arbitrary data options (#16794)
* VAULT-7698 Fix warnings for endpoint arbitrary data options * VAULT-7698 Add changelog
This commit is contained in:
parent
96084c7cf4
commit
0b3d7fdf10
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
api: Fixed erroneous warnings of unrecognized parameters when unwrapping data.
|
||||
```
|
|
@ -146,6 +146,9 @@ func TestHTTP_Wrapping(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if secret.Warnings != nil {
|
||||
t.Fatalf("Warnings found: %v", secret.Warnings)
|
||||
}
|
||||
if secret == nil || secret.Data == nil {
|
||||
t.Fatal("secret or secret data is nil")
|
||||
}
|
||||
|
@ -222,6 +225,9 @@ func TestHTTP_Wrapping(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if secret.Warnings != nil {
|
||||
t.Fatalf("Warnings found: %v", secret.Warnings)
|
||||
}
|
||||
ret4 := secret
|
||||
// Should be expired and fail
|
||||
_, err = client.Logical().Unwrap(wrapInfo.Token)
|
||||
|
@ -286,10 +292,16 @@ func TestHTTP_Wrapping(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if secret.Warnings != nil {
|
||||
t.Fatalf("Warnings found: %v", secret.Warnings)
|
||||
}
|
||||
secret, err = client.Logical().Unwrap(secret.WrapInfo.Token)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if secret.Warnings != nil {
|
||||
t.Fatalf("Warnings found: %v", secret.Warnings)
|
||||
}
|
||||
if !reflect.DeepEqual(data, secret.Data) {
|
||||
t.Fatalf("custom wrap did not match expected: %#v", secret.Data)
|
||||
}
|
||||
|
@ -320,6 +332,9 @@ func TestHTTP_Wrapping(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if secret.Warnings != nil {
|
||||
t.Fatalf("Warnings found: %v", secret.Warnings)
|
||||
}
|
||||
|
||||
// Check for correct Creation path after rewrap
|
||||
if wrapInfo.CreationPath != "secret/foo" {
|
||||
|
|
|
@ -221,7 +221,7 @@ func (b *Backend) HandleRequest(ctx context.Context, req *logical.Request) (*log
|
|||
var ignored []string
|
||||
for k, v := range req.Data {
|
||||
raw[k] = v
|
||||
if path.Fields[k] == nil {
|
||||
if !path.TakesArbitraryInput && path.Fields[k] == nil {
|
||||
ignored = append(ignored, k)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,6 +116,12 @@ type Path struct {
|
|||
// DisplayAttrs provides hints for UI and documentation generators. They
|
||||
// will be included in OpenAPI output if set.
|
||||
DisplayAttrs *DisplayAttributes
|
||||
|
||||
// TakesArbitraryInput is used for endpoints that take arbitrary input, instead
|
||||
// of or as well as their Fields. This is taken into account when printing
|
||||
// warnings about ignored fields. If this is set, we will not warn when data is
|
||||
// provided that is not part of the Fields declaration.
|
||||
TakesArbitraryInput bool
|
||||
}
|
||||
|
||||
// OperationHandler defines and describes a specific operation handler.
|
||||
|
|
|
@ -1795,6 +1795,8 @@ func (b *SystemBackend) wrappingPaths() []*framework.Path {
|
|||
|
||||
HelpSynopsis: strings.TrimSpace(sysHelp["wrap"][0]),
|
||||
HelpDescription: strings.TrimSpace(sysHelp["wrap"][1]),
|
||||
|
||||
TakesArbitraryInput: true,
|
||||
},
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue