mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
cfg: rename diameter json obj fields to camel case
This commit is contained in:
committed by
Dan Christian Bogos
parent
301f57e3bc
commit
7017ada853
@@ -1076,22 +1076,22 @@ func TestAsteriskAgentJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDiameterAgentJsonCfg(t *testing.T) {
|
||||
eCfg := &DiameterAgentJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Listen: utils.StringPointer("127.0.0.1:3868"),
|
||||
Listen_net: utils.StringPointer(utils.TCP),
|
||||
Dictionaries_path: utils.StringPointer("/usr/share/cgrates/diameter/dict/"),
|
||||
Sessions_conns: &[]string{rpcclient.BiRPCInternal},
|
||||
StatSConns: &[]string{},
|
||||
ThresholdSConns: &[]string{},
|
||||
Origin_host: utils.StringPointer("CGR-DA"),
|
||||
Origin_realm: utils.StringPointer("cgrates.org"),
|
||||
Vendor_id: utils.IntPointer(0),
|
||||
Product_name: utils.StringPointer("CGRateS"),
|
||||
Synced_conn_requests: utils.BoolPointer(false),
|
||||
Asr_template: utils.StringPointer(""),
|
||||
Rar_template: utils.StringPointer(""),
|
||||
Forced_disconnect: utils.StringPointer(utils.MetaNone),
|
||||
Request_processors: &[]*ReqProcessorJsnCfg{},
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Listen: utils.StringPointer("127.0.0.1:3868"),
|
||||
ListenNet: utils.StringPointer(utils.TCP),
|
||||
DictionariesPath: utils.StringPointer("/usr/share/cgrates/diameter/dict/"),
|
||||
SessionSConns: &[]string{rpcclient.BiRPCInternal},
|
||||
StatSConns: &[]string{},
|
||||
ThresholdSConns: &[]string{},
|
||||
OriginHost: utils.StringPointer("CGR-DA"),
|
||||
OriginRealm: utils.StringPointer("cgrates.org"),
|
||||
VendorID: utils.IntPointer(0),
|
||||
ProductName: utils.StringPointer("CGRateS"),
|
||||
SyncedConnRequests: utils.BoolPointer(false),
|
||||
ASRTemplate: utils.StringPointer(""),
|
||||
RARTemplate: utils.StringPointer(""),
|
||||
ForcedDisconnect: utils.StringPointer(utils.MetaNone),
|
||||
RequestProcessors: &[]*ReqProcessorJsnCfg{},
|
||||
}
|
||||
dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON))
|
||||
if err != nil {
|
||||
|
||||
@@ -1286,7 +1286,7 @@ func TestLoadDiameterAgentCfgError(t *testing.T) {
|
||||
]
|
||||
}
|
||||
}`
|
||||
expected := "json: cannot unmarshal number into Go struct field ReqProcessorJsnCfg.Request_processors.ID of type string"
|
||||
expected := "json: cannot unmarshal number into Go struct field ReqProcessorJsnCfg.request_processors.ID of type string"
|
||||
cgrConfig := NewDefaultCGRConfig()
|
||||
if cgrCfgJSON, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -56,19 +56,19 @@ func (da *DiameterAgentCfg) loadFromJSONCfg(jsnCfg *DiameterAgentJsonCfg, separa
|
||||
if jsnCfg.Listen != nil {
|
||||
da.Listen = *jsnCfg.Listen
|
||||
}
|
||||
if jsnCfg.Listen_net != nil {
|
||||
da.ListenNet = *jsnCfg.Listen_net
|
||||
if jsnCfg.ListenNet != nil {
|
||||
da.ListenNet = *jsnCfg.ListenNet
|
||||
}
|
||||
if jsnCfg.Dictionaries_path != nil {
|
||||
da.DictionariesPath = *jsnCfg.Dictionaries_path
|
||||
if jsnCfg.DictionariesPath != nil {
|
||||
da.DictionariesPath = *jsnCfg.DictionariesPath
|
||||
}
|
||||
if jsnCfg.Ce_applications != nil {
|
||||
da.CeApplications = make([]string, len(*jsnCfg.Ce_applications))
|
||||
copy(da.CeApplications, *jsnCfg.Ce_applications)
|
||||
if jsnCfg.CeApplications != nil {
|
||||
da.CeApplications = make([]string, len(*jsnCfg.CeApplications))
|
||||
copy(da.CeApplications, *jsnCfg.CeApplications)
|
||||
}
|
||||
if jsnCfg.Sessions_conns != nil {
|
||||
da.SessionSConns = make([]string, len(*jsnCfg.Sessions_conns))
|
||||
for idx, attrConn := range *jsnCfg.Sessions_conns {
|
||||
if jsnCfg.SessionSConns != nil {
|
||||
da.SessionSConns = make([]string, len(*jsnCfg.SessionSConns))
|
||||
for idx, attrConn := range *jsnCfg.SessionSConns {
|
||||
// if we have the connection internal we change the name so we can have internal rpc for each subsystem
|
||||
da.SessionSConns[idx] = attrConn
|
||||
if attrConn == utils.MetaInternal ||
|
||||
@@ -83,32 +83,32 @@ func (da *DiameterAgentCfg) loadFromJSONCfg(jsnCfg *DiameterAgentJsonCfg, separa
|
||||
if jsnCfg.ThresholdSConns != nil {
|
||||
da.ThresholdSConns = tagInternalConns(*jsnCfg.ThresholdSConns, utils.MetaThresholds)
|
||||
}
|
||||
if jsnCfg.Origin_host != nil {
|
||||
da.OriginHost = *jsnCfg.Origin_host
|
||||
if jsnCfg.OriginHost != nil {
|
||||
da.OriginHost = *jsnCfg.OriginHost
|
||||
}
|
||||
if jsnCfg.Origin_realm != nil {
|
||||
da.OriginRealm = *jsnCfg.Origin_realm
|
||||
if jsnCfg.OriginRealm != nil {
|
||||
da.OriginRealm = *jsnCfg.OriginRealm
|
||||
}
|
||||
if jsnCfg.Vendor_id != nil {
|
||||
da.VendorID = *jsnCfg.Vendor_id
|
||||
if jsnCfg.VendorID != nil {
|
||||
da.VendorID = *jsnCfg.VendorID
|
||||
}
|
||||
if jsnCfg.Product_name != nil {
|
||||
da.ProductName = *jsnCfg.Product_name
|
||||
if jsnCfg.ProductName != nil {
|
||||
da.ProductName = *jsnCfg.ProductName
|
||||
}
|
||||
if jsnCfg.Synced_conn_requests != nil {
|
||||
da.SyncedConnReqs = *jsnCfg.Synced_conn_requests
|
||||
if jsnCfg.SyncedConnRequests != nil {
|
||||
da.SyncedConnReqs = *jsnCfg.SyncedConnRequests
|
||||
}
|
||||
if jsnCfg.Asr_template != nil {
|
||||
da.ASRTemplate = *jsnCfg.Asr_template
|
||||
if jsnCfg.ASRTemplate != nil {
|
||||
da.ASRTemplate = *jsnCfg.ASRTemplate
|
||||
}
|
||||
if jsnCfg.Rar_template != nil {
|
||||
da.RARTemplate = *jsnCfg.Rar_template
|
||||
if jsnCfg.RARTemplate != nil {
|
||||
da.RARTemplate = *jsnCfg.RARTemplate
|
||||
}
|
||||
if jsnCfg.Forced_disconnect != nil {
|
||||
da.ForcedDisconnect = *jsnCfg.Forced_disconnect
|
||||
if jsnCfg.ForcedDisconnect != nil {
|
||||
da.ForcedDisconnect = *jsnCfg.ForcedDisconnect
|
||||
}
|
||||
if jsnCfg.Request_processors != nil {
|
||||
for _, reqProcJsn := range *jsnCfg.Request_processors {
|
||||
if jsnCfg.RequestProcessors != nil {
|
||||
for _, reqProcJsn := range *jsnCfg.RequestProcessors {
|
||||
rp := new(RequestProcessor)
|
||||
var haveID bool
|
||||
for _, rpSet := range da.RequestProcessors {
|
||||
|
||||
@@ -27,23 +27,23 @@ import (
|
||||
|
||||
func TestDiameterAgentCfgloadFromJsonCfg(t *testing.T) {
|
||||
jsonCFG := &DiameterAgentJsonCfg{
|
||||
Enabled: utils.BoolPointer(true),
|
||||
Listen_net: utils.StringPointer("tcp"),
|
||||
Listen: utils.StringPointer("127.0.0.1:3868"),
|
||||
Ce_applications: utils.SliceStringPointer([]string{"Base"}),
|
||||
Dictionaries_path: utils.StringPointer("/usr/share/cgrates/diameter/dict/"),
|
||||
Sessions_conns: &[]string{utils.MetaInternal, "*conn1"},
|
||||
StatSConns: &[]string{utils.MetaInternal, "*conn1"},
|
||||
ThresholdSConns: &[]string{utils.MetaInternal, "*conn1"},
|
||||
Origin_host: utils.StringPointer("CGR-DA"),
|
||||
Origin_realm: utils.StringPointer("cgrates.org"),
|
||||
Vendor_id: utils.IntPointer(0),
|
||||
Product_name: utils.StringPointer("randomName"),
|
||||
Synced_conn_requests: utils.BoolPointer(true),
|
||||
Asr_template: utils.StringPointer("randomTemplate"),
|
||||
Rar_template: utils.StringPointer("randomTemplate"),
|
||||
Forced_disconnect: utils.StringPointer("forced"),
|
||||
Request_processors: &[]*ReqProcessorJsnCfg{
|
||||
Enabled: utils.BoolPointer(true),
|
||||
ListenNet: utils.StringPointer("tcp"),
|
||||
Listen: utils.StringPointer("127.0.0.1:3868"),
|
||||
CeApplications: utils.SliceStringPointer([]string{"Base"}),
|
||||
DictionariesPath: utils.StringPointer("/usr/share/cgrates/diameter/dict/"),
|
||||
SessionSConns: &[]string{utils.MetaInternal, "*conn1"},
|
||||
StatSConns: &[]string{utils.MetaInternal, "*conn1"},
|
||||
ThresholdSConns: &[]string{utils.MetaInternal, "*conn1"},
|
||||
OriginHost: utils.StringPointer("CGR-DA"),
|
||||
OriginRealm: utils.StringPointer("cgrates.org"),
|
||||
VendorID: utils.IntPointer(0),
|
||||
ProductName: utils.StringPointer("randomName"),
|
||||
SyncedConnRequests: utils.BoolPointer(true),
|
||||
ASRTemplate: utils.StringPointer("randomTemplate"),
|
||||
RARTemplate: utils.StringPointer("randomTemplate"),
|
||||
ForcedDisconnect: utils.StringPointer("forced"),
|
||||
RequestProcessors: &[]*ReqProcessorJsnCfg{
|
||||
{
|
||||
ID: utils.StringPointer(utils.CGRateSLwr),
|
||||
Timezone: utils.StringPointer("Local"),
|
||||
@@ -84,7 +84,7 @@ func TestDiameterAgentCfgloadFromJsonCfg(t *testing.T) {
|
||||
|
||||
func TestRequestProcessorloadFromJsonCfg1(t *testing.T) {
|
||||
cfgJSON := &DiameterAgentJsonCfg{
|
||||
Request_processors: &[]*ReqProcessorJsnCfg{
|
||||
RequestProcessors: &[]*ReqProcessorJsnCfg{
|
||||
{
|
||||
Tenant: utils.StringPointer("a{*"),
|
||||
},
|
||||
@@ -108,7 +108,7 @@ func TestRequestProcessorloadFromJsonCfg2(t *testing.T) {
|
||||
}
|
||||
}`
|
||||
cfgJSON := &DiameterAgentJsonCfg{
|
||||
Request_processors: &[]*ReqProcessorJsnCfg{
|
||||
RequestProcessors: &[]*ReqProcessorJsnCfg{
|
||||
{
|
||||
ID: utils.StringPointer("random"),
|
||||
},
|
||||
|
||||
@@ -543,23 +543,23 @@ type OsipsConnJsonCfg struct {
|
||||
|
||||
// DiameterAgent configuration
|
||||
type DiameterAgentJsonCfg struct {
|
||||
Enabled *bool
|
||||
Listen *string
|
||||
Listen_net *string
|
||||
Dictionaries_path *string
|
||||
Ce_applications *[]string
|
||||
Sessions_conns *[]string
|
||||
StatSConns *[]string `json:"stats_conns"`
|
||||
ThresholdSConns *[]string `json:"thresholds_conns"`
|
||||
Origin_host *string
|
||||
Origin_realm *string
|
||||
Vendor_id *int
|
||||
Product_name *string
|
||||
Synced_conn_requests *bool
|
||||
Asr_template *string
|
||||
Rar_template *string
|
||||
Forced_disconnect *string
|
||||
Request_processors *[]*ReqProcessorJsnCfg
|
||||
Enabled *bool `json:"enabled"`
|
||||
Listen *string `json:"listen"`
|
||||
ListenNet *string `json:"listen_net"`
|
||||
DictionariesPath *string `json:"dictionaries_path"`
|
||||
CeApplications *[]string `json:"ce_applications"`
|
||||
SessionSConns *[]string `json:"sessions_conns"`
|
||||
StatSConns *[]string `json:"stats_conns"`
|
||||
ThresholdSConns *[]string `json:"thresholds_conns"`
|
||||
OriginHost *string `json:"origin_host"`
|
||||
OriginRealm *string `json:"origin_realm"`
|
||||
VendorID *int `json:"vendor_id"`
|
||||
ProductName *string `json:"product_name"`
|
||||
SyncedConnRequests *bool `json:"synced_conn_requests"`
|
||||
ASRTemplate *string `json:"asr_template"`
|
||||
RARTemplate *string `json:"rar_template"`
|
||||
ForcedDisconnect *string `json:"forced_disconnect"`
|
||||
RequestProcessors *[]*ReqProcessorJsnCfg `json:"request_processors"`
|
||||
}
|
||||
|
||||
type RadiListenerJsnCfg struct {
|
||||
|
||||
Reference in New Issue
Block a user