diff --git a/config/janusagntcfg_test.go b/config/janusagntcfg_test.go index bb2dbc186..6c9e6942f 100644 --- a/config/janusagntcfg_test.go +++ b/config/janusagntcfg_test.go @@ -18,7 +18,12 @@ along with this program. If not, see package config -import "testing" +import ( + "reflect" + "testing" + + "github.com/cgrates/cgrates/utils" +) func TestLoadFromJSONCfgNil(t *testing.T) { var jc JanusConn @@ -28,3 +33,19 @@ func TestLoadFromJSONCfgNil(t *testing.T) { } } + +func TestJanusConnAsMapInterface(t *testing.T) { + js := &JanusConn{ + Address: "127.001", + Type: "ws", + } + exp := map[string]any{ + utils.AddressCfg: "127.001", + utils.TypeCfg: "ws", + } + val := js.AsMapInterface() + if !reflect.DeepEqual(val, exp) { + t.Errorf("expected %+v received %+v", exp, val) + } + +} diff --git a/config/radiuscfg_test.go b/config/radiuscfg_test.go index c9dd3eec4..0217ca2c4 100644 --- a/config/radiuscfg_test.go +++ b/config/radiuscfg_test.go @@ -59,6 +59,15 @@ func TestRadiusAgentCfgloadFromJsonCfgCase1(t *testing.T) { }, }, }, + ClientDaAddresses: map[string]DAClientOptsJson{ + + "fsfdsz": { + Transport: utils.StringPointer("http"), + Host: utils.StringPointer("localhost"), + Port: utils.IntPointer(6768), + Flags: []string{"*sessions", "*routes"}, + }, + }, } expected := &RadiusAgentCfg{ Enabled: true, @@ -74,6 +83,17 @@ func TestRadiusAgentCfgloadFromJsonCfgCase1(t *testing.T) { SessionSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaSessionS)}, DMRTemplate: "*dmr", CoATemplate: "*coa", + ClientDaAddresses: map[string]DAClientOpts{ + "fsfdsz": { + Transport: "http", + Host: "localhost", + Port: 6768, + Flags: utils.FlagsWithParams{ + utils.MetaSessionS: utils.FlagParams{}, + utils.MetaRoutes: utils.FlagParams{}, + }, + }, + }, RequestProcessors: []*RequestProcessor{ { ID: "OutboundAUTHDryRun", @@ -313,3 +333,30 @@ func TestRadiusAgentCfgClone(t *testing.T) { t.Errorf("Expected clone to not modify the cloned") } } + +func TestAsMapInterface01(t *testing.T) { + + expectedMap := map[string]any{ + utils.TransportCfg: "http", + utils.HostCfg: "localhost", + utils.PortCfg: 6768, + utils.FlagsCfg: []string{utils.MetaSessionS, + utils.MetaRoutes}, + } + + opts := &DAClientOpts{ + Transport: "http", + Host: "localhost", + Port: 6768, + Flags: utils.FlagsWithParams{ + utils.MetaSessionS: utils.FlagParams{}, + utils.MetaRoutes: utils.FlagParams{}, + }, + } + + actualMap := opts.AsMapInterface() + + if !reflect.DeepEqual(expectedMap, actualMap) { + t.Errorf("Expected map: %v, Actual map: %v", expectedMap, actualMap) + } +}