mirror of https://github.com/hashicorp/consul
Make sure IngressHosts isn't parsed during JSON decode
parent
c44f877758
commit
f9672f9bf1
|
@ -249,7 +249,8 @@ type Upstream struct {
|
|||
MeshGateway MeshGatewayConfig `json:",omitempty"`
|
||||
|
||||
// IngressHosts are a list of hosts that should route to this upstream from
|
||||
// an ingress gateway
|
||||
// an ingress gateway. This cannot and should not be set by a user, it is
|
||||
// used internally to store the association of hosts to an upstream service.
|
||||
IngressHosts []string `json:"-" bexpr:"-"`
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ func TestUpstream_MarshalJSON(t *testing.T) {
|
|||
DestinationName: "foo",
|
||||
Datacenter: "dc1",
|
||||
LocalBindPort: 1234,
|
||||
// Test IngressHosts does not marshal
|
||||
IngressHosts: []string{"test.example.com"},
|
||||
},
|
||||
want: `{
|
||||
"DestinationType": "service",
|
||||
|
@ -179,6 +181,22 @@ func TestUpstream_UnmarshalJSON(t *testing.T) {
|
|||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "ingress-hosts-do-not-unmarshal",
|
||||
json: `{
|
||||
"DestinationType": "service",
|
||||
"DestinationName": "foo",
|
||||
"Datacenter": "dc1",
|
||||
"IngressHosts": ["asdf"]
|
||||
}`,
|
||||
want: Upstream{
|
||||
DestinationType: UpstreamDestTypeService,
|
||||
DestinationName: "foo",
|
||||
Datacenter: "dc1",
|
||||
IngressHosts: nil, // Make sure this doesn't get parsed
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue