VAULT-8519 fix spurious "unknown or unsupported fields" warnings for JSON config (#17660)
* VAULT-8519 add tests for HCL unknown field bug * VAULT-8519 upversion hcl * VAULT-8519 include correct comitts in tag * VAULT-8519 Add changelog
This commit is contained in:
parent
a9dcc45f72
commit
6d9ea2862e
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
core: Fixes spurious warnings being emitted relating to "unknown or unsupported fields" for JSON config
|
||||
```
|
|
@ -56,6 +56,14 @@ func TestUnknownFieldValidation(t *testing.T) {
|
|||
testUnknownFieldValidation(t)
|
||||
}
|
||||
|
||||
func TestUnknownFieldValidationJson(t *testing.T) {
|
||||
testUnknownFieldValidationJson(t)
|
||||
}
|
||||
|
||||
func TestUnknownFieldValidationHcl(t *testing.T) {
|
||||
testUnknownFieldValidationHcl(t)
|
||||
}
|
||||
|
||||
func TestUnknownFieldValidationListenerAndStorage(t *testing.T) {
|
||||
testUnknownFieldValidationStorageAndListener(t)
|
||||
}
|
||||
|
|
|
@ -534,6 +534,37 @@ func testUnknownFieldValidation(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// testUnknownFieldValidationJson tests that this valid json config does not result in
|
||||
// errors. Prior to VAULT-8519, it reported errors even with a valid config that was
|
||||
// parsed properly.
|
||||
func testUnknownFieldValidationJson(t *testing.T) {
|
||||
config, err := LoadConfigFile("./test-fixtures/config_small.json")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
errors := config.Validate("./test-fixtures/config_small.json")
|
||||
if errors != nil {
|
||||
t.Fatal(errors)
|
||||
}
|
||||
}
|
||||
|
||||
// testUnknownFieldValidationHcl tests that this valid hcl config does not result in
|
||||
// errors. Prior to VAULT-8519, the json version of this config reported errors even
|
||||
// with a valid config that was parsed properly.
|
||||
// In short, this ensures the same for HCL as we test in testUnknownFieldValidationJson
|
||||
func testUnknownFieldValidationHcl(t *testing.T) {
|
||||
config, err := LoadConfigFile("./test-fixtures/config_small.hcl")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
errors := config.Validate("./test-fixtures/config_small.hcl")
|
||||
if errors != nil {
|
||||
t.Fatal(errors)
|
||||
}
|
||||
}
|
||||
|
||||
func testLoadConfigFile_json(t *testing.T) {
|
||||
config, err := LoadConfigFile("./test-fixtures/config.hcl.json")
|
||||
if err != nil {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
storage "raft" {
|
||||
path = "/path/to/raft"
|
||||
node_id = "raft_node_1"
|
||||
}
|
||||
listener "tcp" {
|
||||
address = "127.0.0.1:8200"
|
||||
tls_cert_file = "/path/to/cert.pem"
|
||||
tls_key_file = "/path/to/key.key"
|
||||
}
|
||||
seal "awskms" {
|
||||
kms_key_id = "alias/kms-unseal-key"
|
||||
}
|
||||
service_registration "consul" {
|
||||
address = "127.0.0.1:8500"
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"listener": {
|
||||
"tcp": {
|
||||
"address": "0.0.0.0:8200",
|
||||
"tls_cert_file": "/path/to/cert.pem",
|
||||
"tls_key_file": "/path/to/key.key"
|
||||
}
|
||||
},
|
||||
|
||||
"seal": {
|
||||
"awskms": {
|
||||
"kms_key_id": "alias/kms-unseal-key"
|
||||
}
|
||||
},
|
||||
|
||||
"storage": {
|
||||
"raft": {
|
||||
"path": "/path/to/raft",
|
||||
"node_id": "raft_node_1"
|
||||
}
|
||||
},
|
||||
|
||||
"cluster_addr": "http://127.0.0.1:8201",
|
||||
"api_addr": "http://127.0.0.1:8200",
|
||||
|
||||
"service_registration": {
|
||||
"consul": {
|
||||
"address": "127.0.0.1:8500"
|
||||
}
|
||||
}
|
||||
}
|
2
go.mod
2
go.mod
|
@ -97,7 +97,7 @@ require (
|
|||
github.com/hashicorp/go-uuid v1.0.3
|
||||
github.com/hashicorp/go-version v1.6.0
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/hashicorp/hcl v1.0.1-vault-3
|
||||
github.com/hashicorp/hcl v1.0.1-vault-5
|
||||
github.com/hashicorp/hcp-sdk-go v0.22.0
|
||||
github.com/hashicorp/nomad/api v0.0.0-20220707195938-75f4c2237b28
|
||||
github.com/hashicorp/raft v1.3.10
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1066,8 +1066,8 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/hcl v1.0.1-vault-3 h1:V95v5KSTu6DB5huDSKiq4uAfILEuNigK/+qPET6H/Mg=
|
||||
github.com/hashicorp/hcl v1.0.1-vault-3/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM=
|
||||
github.com/hashicorp/hcl v1.0.1-vault-5 h1:kI3hhbbyzr4dldA8UdTb7ZlVVlI2DACdCfz31RPDgJM=
|
||||
github.com/hashicorp/hcl v1.0.1-vault-5/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM=
|
||||
github.com/hashicorp/hcp-sdk-go v0.22.0 h1:LWkLOkJFYWSojBM3IkwvYK6nrwrL+p4Fw8zEaoCQG10=
|
||||
github.com/hashicorp/hcp-sdk-go v0.22.0/go.mod h1:mM3nYdVHuv2X2tv88MGVKRf/o2k3zF8jUZSMkwICQ28=
|
||||
github.com/hashicorp/jsonapi v0.0.0-20210826224640-ee7dae0fb22d h1:9ARUJJ1VVynB176G1HCwleORqCaXm/Vx0uUi0dL26I0=
|
||||
|
|
Loading…
Reference in New Issue