diff --git a/agent/consul/config_endpoint_test.go b/agent/consul/config_endpoint_test.go index e1ab202729..ec32be119b 100644 --- a/agent/consul/config_endpoint_test.go +++ b/agent/consul/config_endpoint_test.go @@ -23,11 +23,13 @@ func TestConfigEntry_Apply(t *testing.T) { codec := rpcClient(t, s1) defer codec.Close() + updated := &structs.ServiceConfigEntry{ + Name: "foo", + } + args := structs.ConfigEntryRequest{ Datacenter: "dc1", - Entry: &structs.ServiceConfigEntry{ - Name: "foo", - }, + Entry: updated, } out := false require.NoError(msgpackrpc.CallWithCodec(codec, "ConfigEntry.Apply", &args, &out)) @@ -42,13 +44,17 @@ func TestConfigEntry_Apply(t *testing.T) { require.Equal("foo", serviceConf.Name) require.Equal(structs.ServiceDefaults, serviceConf.Kind) + updated = &structs.ServiceConfigEntry{ + Name: "foo", + MeshGateway: structs.MeshGatewayConfig{ + Mode: structs.MeshGatewayModeLocal, + }, + } + args = structs.ConfigEntryRequest{ Datacenter: "dc1", Op: structs.ConfigEntryUpsertCAS, - Entry: &structs.ServiceConfigEntry{ - Name: "foo", - Protocol: "tcp", - }, + Entry: updated, } require.NoError(msgpackrpc.CallWithCodec(codec, "ConfigEntry.Apply", &args, &out)) @@ -64,9 +70,10 @@ func TestConfigEntry_Apply(t *testing.T) { serviceConf, ok = entry.(*structs.ServiceConfigEntry) require.True(ok) - require.Equal("foo", serviceConf.Name) - require.Equal("tcp", serviceConf.Protocol) - require.Equal(structs.ServiceDefaults, serviceConf.Kind) + + updated.Kind = structs.ServiceDefaults // the server adds this + updated.RaftIndex = serviceConf.RaftIndex // these will always be different + require.Equal(updated, serviceConf) } func TestConfigEntry_ProxyDefaultsMeshGateway(t *testing.T) { diff --git a/agent/structs/config_entry.go b/agent/structs/config_entry.go index aa5458cf31..293a5efa71 100644 --- a/agent/structs/config_entry.go +++ b/agent/structs/config_entry.go @@ -79,11 +79,7 @@ func (e *ServiceConfigEntry) Normalize() error { } e.Kind = ServiceDefaults - if e.Protocol == "" { - e.Protocol = DefaultServiceProtocol - } else { - e.Protocol = strings.ToLower(e.Protocol) - } + e.Protocol = strings.ToLower(e.Protocol) return nil }