Exemple #1
0
func TestSmFsJsonCfg(t *testing.T) {
	eCfg := &SmFsJsonCfg{
		Enabled:                utils.BoolPointer(false),
		Rater:                  utils.StringPointer("internal"),
		Cdrs:                   utils.StringPointer("internal"),
		Create_cdr:             utils.BoolPointer(false),
		Extra_fields:           utils.StringSlicePointer([]string{}),
		Debit_interval:         utils.StringPointer("10s"),
		Min_call_duration:      utils.StringPointer("0s"),
		Max_call_duration:      utils.StringPointer("3h"),
		Min_dur_low_balance:    utils.StringPointer("5s"),
		Low_balance_ann_file:   utils.StringPointer(""),
		Empty_balance_context:  utils.StringPointer(""),
		Empty_balance_ann_file: utils.StringPointer(""),
		Subscribe_park:         utils.BoolPointer(true),
		Channel_sync_interval:  utils.StringPointer("5m"),
		Connections: &[]*FsConnJsonCfg{
			&FsConnJsonCfg{
				Server:     utils.StringPointer("127.0.0.1:8021"),
				Password:   utils.StringPointer("ClueCon"),
				Reconnects: utils.IntPointer(5),
			}},
	}
	if cfg, err := dfCgrJsonCfg.SmFsJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #2
0
func TestSmKamJsonCfg(t *testing.T) {
	eCfg := &SmKamJsonCfg{
		Enabled: utils.BoolPointer(false),
		Rals_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
		Cdrs_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
		Create_cdr:        utils.BoolPointer(false),
		Debit_interval:    utils.StringPointer("10s"),
		Min_call_duration: utils.StringPointer("0s"),
		Max_call_duration: utils.StringPointer("3h"),
		Evapi_conns: &[]*KamConnJsonCfg{
			&KamConnJsonCfg{
				Address:    utils.StringPointer("127.0.0.1:8448"),
				Reconnects: utils.IntPointer(5),
			},
		},
	}
	if cfg, err := dfCgrJsonCfg.SmKamJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #3
0
func TestSmOsipsJsonCfg(t *testing.T) {
	eCfg := &SmOsipsJsonCfg{
		Enabled:    utils.BoolPointer(false),
		Listen_udp: utils.StringPointer("127.0.0.1:2020"),
		Rals_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
		Cdrs_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
		Create_cdr:                utils.BoolPointer(false),
		Debit_interval:            utils.StringPointer("10s"),
		Min_call_duration:         utils.StringPointer("0s"),
		Max_call_duration:         utils.StringPointer("3h"),
		Events_subscribe_interval: utils.StringPointer("60s"),
		Mi_addr:                   utils.StringPointer("127.0.0.1:8020"),
	}
	if cfg, err := dfCgrJsonCfg.SmOsipsJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #4
0
func TesSmFsConfigLoadFromJsonCfg(t *testing.T) {
	smFsJsnCfg := &SmFsJsonCfg{
		Enabled:        utils.BoolPointer(true),
		Create_cdr:     utils.BoolPointer(true),
		Subscribe_park: utils.BoolPointer(true),
		Connections: &[]*FsConnJsonCfg{
			&FsConnJsonCfg{
				Server:     utils.StringPointer("1.2.3.4:8021"),
				Password:   utils.StringPointer("ClueCon"),
				Reconnects: utils.IntPointer(5),
			},
			&FsConnJsonCfg{
				Server:     utils.StringPointer("2.3.4.5:8021"),
				Password:   utils.StringPointer("ClueCon"),
				Reconnects: utils.IntPointer(5),
			},
		},
	}
	eSmFsConfig := &SmFsConfig{Enabled: true,
		CreateCdr:     true,
		SubscribePark: true,
		Connections: []*FsConnConfig{
			&FsConnConfig{Server: "1.2.3.4:8021", Password: "******", Reconnects: 5},
			&FsConnConfig{Server: "1.2.3.4:8021", Password: "******", Reconnects: 5},
		},
	}
	smFsCfg := new(SmFsConfig)
	if err := smFsCfg.loadFromJsonCfg(smFsJsnCfg); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eSmFsConfig, smFsCfg) {
		t.Error("Received: ", smFsCfg)
	}
}
Exemple #5
0
func TestNewCgrJsonCfgFromFile(t *testing.T) {
	cgrJsonCfg, err := NewCgrJsonCfgFromFile("cfg_data.json")
	if err != nil {
		t.Error(err)
	}
	eCfg := &GeneralJsonCfg{Default_reqtype: utils.StringPointer(utils.META_PSEUDOPREPAID)}
	if gCfg, err := cgrJsonCfg.GeneralJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, gCfg) {
		t.Error("Received: ", gCfg)
	}
	cdrFields := []*CdrFieldJsonCfg{
		&CdrFieldJsonCfg{Cdr_field_id: utils.StringPointer(utils.TOR), Value: utils.StringPointer("~7:s/^(voice|data|sms|generic)$/*$1/")},
		&CdrFieldJsonCfg{Cdr_field_id: utils.StringPointer(utils.ANSWER_TIME), Value: utils.StringPointer("1")},
		&CdrFieldJsonCfg{Cdr_field_id: utils.StringPointer(utils.USAGE), Value: utils.StringPointer(`~9:s/^(\d+)$/${1}s/`)},
	}
	eCfgCdrc := map[string]*CdrcJsonCfg{
		"CDRC-CSV1": &CdrcJsonCfg{
			Enabled:       utils.BoolPointer(true),
			Cdr_in_dir:    utils.StringPointer("/tmp/cgrates/cdrc1/in"),
			Cdr_out_dir:   utils.StringPointer("/tmp/cgrates/cdrc1/out"),
			Cdr_source_id: utils.StringPointer("csv1"),
		},
		"CDRC-CSV2": &CdrcJsonCfg{
			Enabled:                    utils.BoolPointer(true),
			Data_usage_multiply_factor: utils.Float64Pointer(0.000976563),
			Run_delay:                  utils.IntPointer(1),
			Cdr_in_dir:                 utils.StringPointer("/tmp/cgrates/cdrc2/in"),
			Cdr_out_dir:                utils.StringPointer("/tmp/cgrates/cdrc2/out"),
			Cdr_source_id:              utils.StringPointer("csv2"),
			Content_fields:             &cdrFields,
		},
	}
	if cfg, err := cgrJsonCfg.CdrcJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfgCdrc, cfg) {
		t.Error("Received: ", cfg["CDRC-CSV2"])
	}
	eCfgSmFs := &SmFsJsonCfg{
		Enabled: utils.BoolPointer(true),
		Connections: &[]*FsConnJsonCfg{
			&FsConnJsonCfg{
				Server:     utils.StringPointer("1.2.3.4:8021"),
				Password:   utils.StringPointer("ClueCon"),
				Reconnects: utils.IntPointer(5),
			},
			&FsConnJsonCfg{
				Server:     utils.StringPointer("2.3.4.5:8021"),
				Password:   utils.StringPointer("ClueCon"),
				Reconnects: utils.IntPointer(5),
			},
		},
	}
	if smFsCfg, err := cgrJsonCfg.SmFsJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfgSmFs, smFsCfg) {
		t.Error("Received: ", smFsCfg)
	}
}
Exemple #6
0
func TestDfRalsJsonCfg(t *testing.T) {
	eCfg := &RalsJsonCfg{Enabled: utils.BoolPointer(false), Balancer: utils.StringPointer(""), Cdrstats_conns: &[]*HaPoolJsonCfg{},
		Historys_conns: &[]*HaPoolJsonCfg{}, Pubsubs_conns: &[]*HaPoolJsonCfg{}, Users_conns: &[]*HaPoolJsonCfg{}, Aliases_conns: &[]*HaPoolJsonCfg{},
		Rp_subject_prefix_matching: utils.BoolPointer(false), Lcr_subject_prefix_matching: utils.BoolPointer(false)}
	if cfg, err := dfCgrJsonCfg.RalsJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Errorf("Received: %+v", cfg)
	}
}
Exemple #7
0
func testOnStorITCacheActions(t *testing.T) {
	acts := Actions{
		&Action{
			Id:               "MINI",
			ActionType:       TOPUP_RESET,
			ExpirationString: UNLIMITED,
			Weight:           10,
			Balance: &BalanceFilter{
				Type:       utils.StringPointer(utils.MONETARY),
				Uuid:       utils.StringPointer(utils.GenUUID()),
				Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT)),
				Value: &utils.ValueFormula{Static: 10,
					Params: make(map[string]interface{})},
				Weight:   utils.Float64Pointer(10),
				Disabled: utils.BoolPointer(false),
				Timings:  make([]*RITiming, 0),
				Blocker:  utils.BoolPointer(false),
			},
		},
		&Action{
			Id:               "MINI",
			ActionType:       TOPUP,
			ExpirationString: UNLIMITED,
			Weight:           10,
			Balance: &BalanceFilter{
				Type:       utils.StringPointer(utils.VOICE),
				Uuid:       utils.StringPointer(utils.GenUUID()),
				Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT)),
				Value: &utils.ValueFormula{Static: 100,
					Params: make(map[string]interface{})},
				Weight:         utils.Float64Pointer(10),
				RatingSubject:  utils.StringPointer("test"),
				DestinationIDs: utils.StringMapPointer(utils.NewStringMap("NAT")),
				Disabled:       utils.BoolPointer(false),
				Timings:        make([]*RITiming, 0),
				Blocker:        utils.BoolPointer(false),
			},
		},
	}
	if err := onStor.SetActions(acts[0].Id, acts, utils.NonTransactional); err != nil {
		t.Error(err)
	}
	if _, hasIt := cache.Get(utils.ACTION_PREFIX + acts[0].Id); hasIt {
		t.Error("Already in cache")
	}
	if err := onStor.CacheDataFromDB(utils.ACTION_PREFIX, []string{acts[0].Id}, false); err != nil {
		t.Error(err)
	}
	if itm, hasIt := cache.Get(utils.ACTION_PREFIX + acts[0].Id); !hasIt {
		t.Error("Did not cache")
	} else if rcv := itm.(Actions); !reflect.DeepEqual(acts, rcv) {
		t.Errorf("Expecting: %+v, received: %+v", acts, rcv)
	}
}
Exemple #8
0
func TestDfGeneralJsonCfg(t *testing.T) {
	eCfg := &GeneralJsonCfg{
		Instance_id:          utils.StringPointer(""),
		Log_level:            utils.IntPointer(utils.LOGLEVEL_INFO),
		Http_skip_tls_verify: utils.BoolPointer(false),
		Rounding_decimals:    utils.IntPointer(5),
		Dbdata_encoding:      utils.StringPointer("msgpack"),
		Tpexport_dir:         utils.StringPointer("/var/spool/cgrates/tpe"),
		Httpposter_attempts:  utils.IntPointer(3),
		Http_failed_dir:      utils.StringPointer("/var/spool/cgrates/http_failed"),
		Default_request_type: utils.StringPointer(utils.META_RATED),
		Default_category:     utils.StringPointer("call"),
		Default_tenant:       utils.StringPointer("cgrates.org"),
		Default_timezone:     utils.StringPointer("Local"),
		Connect_attempts:     utils.IntPointer(3),
		Reconnects:           utils.IntPointer(-1),
		Connect_timeout:      utils.StringPointer("1s"),
		Reply_timeout:        utils.StringPointer("2s"),
		Response_cache_ttl:   utils.StringPointer("0s"),
		Internal_ttl:         utils.StringPointer("2m"),
		Locking_timeout:      utils.StringPointer("5s"),
	}
	if gCfg, err := dfCgrJsonCfg.GeneralJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, gCfg) {
		t.Error("Received: ", utils.ToIJSON(gCfg))
	}
}
Exemple #9
0
func TestSmGenericJsonCfg(t *testing.T) {
	eCfg := &SmGenericJsonCfg{
		Enabled:       utils.BoolPointer(false),
		Listen_bijson: utils.StringPointer("127.0.0.1:2014"),
		Rals_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
		Cdrs_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
		Smg_replication_conns: &[]*HaPoolJsonCfg{},
		Debit_interval:        utils.StringPointer("0s"),
		Min_call_duration:     utils.StringPointer("0s"),
		Max_call_duration:     utils.StringPointer("3h"),
		Session_ttl:           utils.StringPointer("0s"),
		Session_indexes:       utils.StringSlicePointer([]string{}),
	}
	if cfg, err := dfCgrJsonCfg.SmGenericJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #10
0
func TestDfSureTaxJsonCfg(t *testing.T) {
	eCfg := &SureTaxJsonCfg{
		Url:                     utils.StringPointer(""),
		Client_number:           utils.StringPointer(""),
		Validation_key:          utils.StringPointer(""),
		Business_unit:           utils.StringPointer(""),
		Timezone:                utils.StringPointer("Local"),
		Include_local_cost:      utils.BoolPointer(false),
		Return_file_code:        utils.StringPointer("0"),
		Response_group:          utils.StringPointer("03"),
		Response_type:           utils.StringPointer("D4"),
		Regulatory_code:         utils.StringPointer("03"),
		Client_tracking:         utils.StringPointer(utils.CGRID),
		Customer_number:         utils.StringPointer("Subject"),
		Orig_number:             utils.StringPointer("Subject"),
		Term_number:             utils.StringPointer("Destination"),
		Bill_to_number:          utils.StringPointer(""),
		Zipcode:                 utils.StringPointer(""),
		Plus4:                   utils.StringPointer(""),
		P2PZipcode:              utils.StringPointer(""),
		P2PPlus4:                utils.StringPointer(""),
		Units:                   utils.StringPointer("^1"),
		Unit_type:               utils.StringPointer("^00"),
		Tax_included:            utils.StringPointer("^0"),
		Tax_situs_rule:          utils.StringPointer("^04"),
		Trans_type_code:         utils.StringPointer("^010101"),
		Sales_type_code:         utils.StringPointer("^R"),
		Tax_exemption_code_list: utils.StringPointer(""),
	}
	if cfg, err := dfCgrJsonCfg.SureTaxJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #11
0
func TestSmAsteriskJsonCfg(t *testing.T) {
	eCfg := &SMAsteriskJsonCfg{
		Enabled: utils.BoolPointer(false),
		Sm_generic_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
		Session_terminate_subscriber: &HaPoolJsonCfg{Address: utils.StringPointer(utils.MetaInternal)},
		Debit_interval:               utils.StringPointer("10s"),
		Min_call_duration:            utils.StringPointer("0s"),
		Max_call_duration:            utils.StringPointer("3h"),
		Asterisk_conns: &[]*AstConnJsonCfg{
			&AstConnJsonCfg{
				Address:          utils.StringPointer("127.0.0.1:8088"),
				User:             utils.StringPointer("cgrates"),
				Password:         utils.StringPointer("CGRateS.org"),
				Connect_attempts: utils.IntPointer(3),
				Reconnects:       utils.IntPointer(5),
			},
		},
	}
	if cfg, err := dfCgrJsonCfg.SmAsteriskJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #12
0
func TestDfSchedulerJsonCfg(t *testing.T) {
	eCfg := &SchedulerJsonCfg{Enabled: utils.BoolPointer(false)}
	if cfg, err := dfCgrJsonCfg.SchedulerJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #13
0
func TestDfCdrsJsonCfg(t *testing.T) {
	eCfg := &CdrsJsonCfg{
		Enabled:         utils.BoolPointer(false),
		Extra_fields:    utils.StringSlicePointer([]string{}),
		Store_cdrs:      utils.BoolPointer(true),
		Rater:           utils.StringPointer("internal"),
		Pubsubs:         utils.StringPointer(""),
		Users:           utils.StringPointer(""),
		Aliases:         utils.StringPointer(""),
		Cdrstats:        utils.StringPointer(""),
		Cdr_replication: &[]*CdrReplicationJsonCfg{},
	}
	if cfg, err := dfCgrJsonCfg.CdrsJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Errorf("Received: %+v", *cfg)
	}
}
Exemple #14
0
func TestDfRaterJsonCfg(t *testing.T) {
	eCfg := &RaterJsonCfg{Enabled: utils.BoolPointer(false), Balancer: utils.StringPointer(""), Cdrstats: utils.StringPointer(""),
		Historys: utils.StringPointer(""), Pubsubs: utils.StringPointer(""), Users: utils.StringPointer(""), Aliases: utils.StringPointer("")}
	if cfg, err := dfCgrJsonCfg.RaterJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Errorf("Received: %+v", cfg)
	}
}
Exemple #15
0
func TestDfCdrStatsJsonCfg(t *testing.T) {
	eCfg := &CdrStatsJsonCfg{
		Enabled:       utils.BoolPointer(false),
		Save_Interval: utils.StringPointer("1m"),
	}
	if cfg, err := dfCgrJsonCfg.CdrStatsJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", *cfg)
	}
}
Exemple #16
0
func TestSmAsteriskJsonCfg(t *testing.T) {
	eCfg := &SMAsteriskJsonCfg{
		Enabled:    utils.BoolPointer(false),
		Create_cdr: utils.BoolPointer(false),
		Asterisk_conns: &[]*AstConnJsonCfg{
			&AstConnJsonCfg{
				Address:          utils.StringPointer("127.0.0.1:8088"),
				User:             utils.StringPointer("cgrates"),
				Password:         utils.StringPointer("CGRateS.org"),
				Connect_attempts: utils.IntPointer(3),
				Reconnects:       utils.IntPointer(5),
			},
		},
	}
	if cfg, err := dfCgrJsonCfg.SmAsteriskJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #17
0
func TestDfUserServJsonCfg(t *testing.T) {
	eCfg := &UserServJsonCfg{
		Enabled: utils.BoolPointer(false),
		Indexes: utils.StringSlicePointer([]string{}),
	}
	if cfg, err := dfCgrJsonCfg.UserServJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #18
0
func TestDfHistServJsonCfg(t *testing.T) {
	eCfg := &HistServJsonCfg{
		Enabled:       utils.BoolPointer(false),
		History_dir:   utils.StringPointer("/var/lib/cgrates/history"),
		Save_interval: utils.StringPointer("1s"),
	}
	if cfg, err := dfCgrJsonCfg.HistServJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #19
0
func TestDfCdrsJsonCfg(t *testing.T) {
	eCfg := &CdrsJsonCfg{
		Enabled:             utils.BoolPointer(false),
		Extra_fields:        utils.StringSlicePointer([]string{}),
		Store_cdrs:          utils.BoolPointer(true),
		Cdr_account_summary: utils.BoolPointer(false),
		Rals_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer("*internal"),
			}},
		Pubsubs_conns:   &[]*HaPoolJsonCfg{},
		Users_conns:     &[]*HaPoolJsonCfg{},
		Aliases_conns:   &[]*HaPoolJsonCfg{},
		Cdrstats_conns:  &[]*HaPoolJsonCfg{},
		Cdr_replication: &[]*CdrReplicationJsonCfg{},
	}
	if cfg, err := dfCgrJsonCfg.CdrsJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Errorf("Received: %+v", *cfg)
	}
}
Exemple #20
0
func TestDfResourceLimiterSJsonCfg(t *testing.T) {
	eCfg := &ResourceLimiterServJsonCfg{
		Enabled:             utils.BoolPointer(false),
		Cdrstats_conns:      &[]*HaPoolJsonCfg{},
		Cache_dump_interval: utils.StringPointer("0s"),
		Usage_ttl:           utils.StringPointer("3h"),
	}
	if cfg, err := dfCgrJsonCfg.ResourceLimiterJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
func TestSmGenericJsonCfg(t *testing.T) {
	eCfg := &SmGenericJsonCfg{
		Enabled:           utils.BoolPointer(false),
		Listen_bijson:     utils.StringPointer("127.0.0.1:2014"),
		Rater:             utils.StringPointer("internal"),
		Cdrs:              utils.StringPointer("internal"),
		Debit_interval:    utils.StringPointer("0s"),
		Min_call_duration: utils.StringPointer("0s"),
		Max_call_duration: utils.StringPointer("3h"),
	}
	if cfg, err := dfCgrJsonCfg.SmGenericJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #22
0
func TestDfSureTaxJsonCfg(t *testing.T) {
	eCfg := &SureTaxJsonCfg{
		Url:                utils.StringPointer(""),
		Client_number:      utils.StringPointer(""),
		Validation_key:     utils.StringPointer(""),
		Timezone:           utils.StringPointer("Local"),
		Include_local_cost: utils.BoolPointer(false),
		Origination_number: utils.StringPointer("Subject"),
		Termination_number: utils.StringPointer("Destination"),
	}
	if cfg, err := dfCgrJsonCfg.SureTaxJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg)
	}
}
Exemple #23
0
func TestDfGeneralJsonCfg(t *testing.T) {
	eCfg := &GeneralJsonCfg{
		Http_skip_tls_verify: utils.BoolPointer(false),
		Rounding_decimals:    utils.IntPointer(10),
		Dbdata_encoding:      utils.StringPointer("msgpack"),
		Tpexport_dir:         utils.StringPointer("/var/log/cgrates/tpe"),
		Default_reqtype:      utils.StringPointer(utils.META_RATED),
		Default_category:     utils.StringPointer("call"),
		Default_tenant:       utils.StringPointer("cgrates.org"),
		Default_subject:      utils.StringPointer("cgrates"),
		Default_timezone:     utils.StringPointer("Local"),
		Connect_attempts:     utils.IntPointer(3),
		Reconnects:           utils.IntPointer(-1),
		Response_cache_ttl:   utils.StringPointer("3s"),
		Internal_ttl:         utils.StringPointer("2m")}
	if gCfg, err := dfCgrJsonCfg.GeneralJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, gCfg) {
		t.Error("Received: ", gCfg)
	}
}
Exemple #24
0
func TestApierV2itFraudMitigation(t *testing.T) {
	if !*testIT {
		return
	}
	attrs := &utils.AttrSetBalance{
		Tenant:      "cgrates.org",
		Account:     "dan",
		BalanceType: utils.MONETARY,
		BalanceID:   utils.StringPointer(utils.META_DEFAULT),
		Value:       utils.Float64Pointer(60.0),
		Weight:      utils.Float64Pointer(10.0),
	}
	var reply string
	if err := apierRPC.Call("ApierV2.SetBalance", attrs, &reply); err != nil {
		t.Fatal(err)
	}
	var acnt engine.Account
	if err := apierRPC.Call("ApierV2.GetAccount", &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan"}, &acnt); err != nil {
		t.Error(err)
	} else if len(acnt.BalanceMap) != 1 || acnt.BalanceMap[utils.MONETARY][0].Value != 60.0 {
		t.Errorf("Unexpected balance received: %+v", acnt.BalanceMap[utils.MONETARY][0])
	} else if !acnt.Disabled {
		t.Fatalf("Received account: %+v", acnt)
	}
	attrSetAcnt := AttrSetAccount{
		Tenant:   "cgrates.org",
		Account:  "dan",
		Disabled: utils.BoolPointer(false),
	}
	if err := apierRPC.Call("ApierV2.SetAccount", attrSetAcnt, &reply); err != nil {
		t.Fatal(err)
	}
	if err := apierRPC.Call("ApierV2.GetAccount", &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan"}, &acnt); err != nil {
		t.Error(err)
	} else if len(acnt.BalanceMap) != 1 || acnt.BalanceMap[utils.MONETARY][0].Value != 60.0 {
		t.Errorf("Unexpected balance received: %+v", acnt.BalanceMap[utils.MONETARY][0])
	} else if acnt.Disabled {
		t.Fatalf("Received account: %+v", acnt)
	}
}
Exemple #25
0
func TestCacheJsonCfg(t *testing.T) {
	eCfg := &CacheJsonCfg{
		Destinations: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Reverse_destinations: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Rating_plans: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(true)},
		Rating_profiles: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Lcr: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Cdr_stats: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Actions: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Action_plans: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Action_triggers: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Shared_groups: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Aliases: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
		Reverse_aliases: &CacheParamJsonCfg{Limit: utils.IntPointer(10000),
			Ttl: utils.StringPointer("0s"), Precache: utils.BoolPointer(false)},
	}
	if gCfg, err := dfCgrJsonCfg.CacheJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, gCfg) {
		t.Error("Received: ", utils.ToIJSON(gCfg))
	}
}
Exemple #26
0
func TestDiameterAgentJsonCfg(t *testing.T) {
	eCfg := &DiameterAgentJsonCfg{
		Enabled:          utils.BoolPointer(false),
		Listen:           utils.StringPointer("127.0.0.1:3868"),
		Dictionaries_dir: utils.StringPointer("/usr/share/cgrates/diameter/dict/"),
		Sm_generic_conns: &[]*HaPoolJsonCfg{
			&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
		Pubsubs_conns:        &[]*HaPoolJsonCfg{},
		Create_cdr:           utils.BoolPointer(true),
		Cdr_requires_session: utils.BoolPointer(true),
		Debit_interval:       utils.StringPointer("5m"),
		Timezone:             utils.StringPointer(""),
		Origin_host:          utils.StringPointer("CGR-DA"),
		Origin_realm:         utils.StringPointer("cgrates.org"),
		Vendor_id:            utils.IntPointer(0),
		Product_name:         utils.StringPointer("CGRateS"),
		Request_processors: &[]*DARequestProcessorJsnCfg{
			&DARequestProcessorJsnCfg{
				Id:                  utils.StringPointer("*default"),
				Dry_run:             utils.BoolPointer(false),
				Publish_event:       utils.BoolPointer(false),
				Request_filter:      utils.StringPointer("Subscription-Id>Subscription-Id-Type(0)"),
				Flags:               utils.StringSlicePointer([]string{}),
				Continue_on_success: utils.BoolPointer(false),
				Append_cca:          utils.BoolPointer(true),
				CCR_fields: &[]*CdrFieldJsonCfg{
					&CdrFieldJsonCfg{Tag: utils.StringPointer("TOR"), Field_id: utils.StringPointer(utils.TOR), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("^*voice"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("OriginID"), Field_id: utils.StringPointer(utils.ACCID), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("Session-Id"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("RequestType"), Field_id: utils.StringPointer(utils.REQTYPE), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("^*users"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("Direction"), Field_id: utils.StringPointer(utils.DIRECTION), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("^*out"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("Tenant"), Field_id: utils.StringPointer(utils.TENANT), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("^*users"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("Category"), Field_id: utils.StringPointer(utils.CATEGORY), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("^call"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("Account"), Field_id: utils.StringPointer(utils.ACCOUNT), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("^*users"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("Subject"), Field_id: utils.StringPointer(utils.SUBJECT), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("^*users"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("Destination"), Field_id: utils.StringPointer(utils.DESTINATION), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("Service-Information>IN-Information>Real-Called-Number"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("SetupTime"), Field_id: utils.StringPointer(utils.SETUP_TIME), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("Event-Timestamp"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("AnswerTime"), Field_id: utils.StringPointer(utils.ANSWER_TIME), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("Event-Timestamp"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("Usage"), Field_id: utils.StringPointer(utils.USAGE), Type: utils.StringPointer(utils.META_HANDLER),
						Handler_id: utils.StringPointer("*ccr_usage"), Mandatory: utils.BoolPointer(true)},
					&CdrFieldJsonCfg{Tag: utils.StringPointer("SubscriberID"), Field_id: utils.StringPointer("SubscriberId"), Type: utils.StringPointer(utils.META_COMPOSED),
						Value: utils.StringPointer("Subscription-Id>Subscription-Id-Data"), Mandatory: utils.BoolPointer(true)},
				},
				CCA_fields: &[]*CdrFieldJsonCfg{
					&CdrFieldJsonCfg{Tag: utils.StringPointer("GrantedUnits"), Type: utils.StringPointer(utils.META_HANDLER), Handler_id: utils.StringPointer("*cca_usage"),
						Field_id: utils.StringPointer("Granted-Service-Unit>CC-Time"), Mandatory: utils.BoolPointer(true)},
				},
			},
		},
	}
	if cfg, err := dfCgrJsonCfg.DiameterAgentJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		rcv := *cfg.Request_processors
		t.Errorf("Received: %+v", rcv[0].CCA_fields)
	}
}
Exemple #27
0
func TestDfCdrcJsonCfg(t *testing.T) {
	eFields := []*CdrFieldJsonCfg{}
	cdrFields := []*CdrFieldJsonCfg{
		&CdrFieldJsonCfg{Tag: utils.StringPointer("tor"), Cdr_field_id: utils.StringPointer(utils.TOR), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("2"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("accid"), Cdr_field_id: utils.StringPointer(utils.ACCID), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("3"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("reqtype"), Cdr_field_id: utils.StringPointer(utils.REQTYPE), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("4"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("direction"), Cdr_field_id: utils.StringPointer(utils.DIRECTION), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("5"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("tenant"), Cdr_field_id: utils.StringPointer(utils.TENANT), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("6"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("category"), Cdr_field_id: utils.StringPointer(utils.CATEGORY), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("7"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("account"), Cdr_field_id: utils.StringPointer(utils.ACCOUNT), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("8"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("subject"), Cdr_field_id: utils.StringPointer(utils.SUBJECT), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("9"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("destination"), Cdr_field_id: utils.StringPointer(utils.DESTINATION), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("10"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("setup_time"), Cdr_field_id: utils.StringPointer(utils.SETUP_TIME), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("11"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("answer_time"), Cdr_field_id: utils.StringPointer(utils.ANSWER_TIME), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("12"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("usage"), Cdr_field_id: utils.StringPointer(utils.USAGE), Type: utils.StringPointer(utils.CDRFIELD),
			Value: utils.StringPointer("13"), Mandatory: utils.BoolPointer(true)},
	}
	eCfg := map[string]*CdrcJsonCfg{
		"*default": &CdrcJsonCfg{
			Enabled:                    utils.BoolPointer(false),
			Dry_run:                    utils.BoolPointer(false),
			Cdrs:                       utils.StringPointer("internal"),
			Cdr_format:                 utils.StringPointer("csv"),
			Field_separator:            utils.StringPointer(","),
			Timezone:                   utils.StringPointer(""),
			Run_delay:                  utils.IntPointer(0),
			Max_open_files:             utils.IntPointer(1024),
			Data_usage_multiply_factor: utils.Float64Pointer(1024.0),
			Cdr_in_dir:                 utils.StringPointer("/var/log/cgrates/cdrc/in"),
			Cdr_out_dir:                utils.StringPointer("/var/log/cgrates/cdrc/out"),
			Failed_calls_prefix:        utils.StringPointer("missed_calls"),
			Cdr_source_id:              utils.StringPointer("freeswitch_csv"),
			Cdr_filter:                 utils.StringPointer(""),
			Partial_record_cache:       utils.StringPointer("10s"),
			Header_fields:              &eFields,
			Content_fields:             &cdrFields,
			Trailer_fields:             &eFields,
		},
	}
	if cfg, err := dfCgrJsonCfg.CdrcJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Error("Received: ", cfg["*default"])
	}
}
// Test adding the account via API, using the data previously devined in .csv
func TestTutLocalSetAccount(t *testing.T) {
	if !*testLocal {
		return
	}
	var reply string
	attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Direction: "*out", Account: "tutacnt1", ActionPlanId: "PACKAGE_10", ActionTriggersId: "STANDARD_TRIGGERS"}
	if err := tutLocalRpc.Call("ApierV1.SetAccount", attrs, &reply); err != nil {
		t.Error("Got error on ApierV1.SetAccount: ", err.Error())
	} else if reply != "OK" {
		t.Errorf("Calling ApierV1.SetAccount received: %s", reply)
	}
	type AttrGetAccounts struct {
		Tenant     string
		Direction  string
		AccountIds []string
		Offset     int // Set the item offset
		Limit      int // Limit number of items retrieved
	}
	var acnts []*engine.Account
	if err := tutLocalRpc.Call("ApierV1.GetAccounts", utils.AttrGetAccounts{Tenant: attrs.Tenant, Direction: attrs.Direction, AccountIds: []string{attrs.Account}}, &acnts); err != nil {
		t.Error(err)
	} else if len(acnts) != 1 {
		t.Errorf("Accounts received: %+v", acnts)
	} else {
		acnt := acnts[0]
		dta, _ := utils.NewDTAFromAccountKey(acnt.Id)
		if dta.Direction != attrs.Direction || dta.Tenant != attrs.Tenant || dta.Account != attrs.Account {
			t.Error("Unexpected account id received: ", acnt.Id)
		}
		if balances := acnt.BalanceMap["*monetary*out"]; len(balances) != 1 {
			t.Errorf("Unexpected balances found: %+v", balances)
		}
		if len(acnt.ActionTriggers) != 4 {
			t.Errorf("Unexpected action triggers for account: %+v", acnt.ActionTriggers)
		}
		if acnt.AllowNegative {
			t.Error("AllowNegative should not be set")
		}
		if acnt.Disabled {
			t.Error("Disabled should not be set")
		}
	}
	attrs = &utils.AttrSetAccount{Tenant: "cgrates.org", Direction: "*out", Account: "tutacnt1", AllowNegative: utils.BoolPointer(true), Disabled: utils.BoolPointer(true)}
	if err := tutLocalRpc.Call("ApierV1.SetAccount", attrs, &reply); err != nil {
		t.Error("Got error on ApierV1.SetAccount: ", err.Error())
	} else if reply != "OK" {
		t.Errorf("Calling ApierV1.SetAccount received: %s", reply)
	}
	if err := tutLocalRpc.Call("ApierV1.GetAccounts", utils.AttrGetAccounts{Tenant: attrs.Tenant, Direction: attrs.Direction, AccountIds: []string{attrs.Account}}, &acnts); err != nil {
		t.Error(err)
	} else if len(acnts) != 1 {
		t.Errorf("Accounts received: %+v", acnts)
	} else {
		acnt := acnts[0]
		dta, _ := utils.NewDTAFromAccountKey(acnt.Id)
		if dta.Direction != attrs.Direction || dta.Tenant != attrs.Tenant || dta.Account != attrs.Account {
			t.Error("Unexpected account id received: ", acnt.Id)
		}
		if balances := acnt.BalanceMap["*monetary*out"]; len(balances) != 1 {
			t.Errorf("Unexpected balances found: %+v", balances)
		}
		if len(acnt.ActionTriggers) != 4 {
			t.Errorf("Unexpected action triggers for account: %+v", acnt.ActionTriggers)
		}
		if !acnt.AllowNegative {
			t.Error("AllowNegative should be set")
		}
		if !acnt.Disabled {
			t.Error("Disabled should be set")
		}
	}

}
Exemple #29
0
func TestLoadActions(t *testing.T) {
	if len(csvr.actions) != 15 {
		t.Error("Failed to load actions: ", len(csvr.actions))
	}
	as1 := csvr.actions["MINI"]
	expected := []*Action{
		&Action{
			Id:               "MINI",
			ActionType:       TOPUP_RESET,
			ExpirationString: UNLIMITED,
			ExtraParameters:  "",
			Weight:           10,
			Balance: &BalanceFilter{
				Type:           utils.StringPointer(utils.MONETARY),
				Uuid:           as1[0].Balance.Uuid,
				Directions:     utils.StringMapPointer(utils.NewStringMap(utils.OUT)),
				Value:          &utils.ValueFormula{Static: 10},
				Weight:         utils.Float64Pointer(10),
				DestinationIDs: nil,
				TimingIDs:      nil,
				SharedGroups:   nil,
				Categories:     nil,
				Disabled:       utils.BoolPointer(false),
				Blocker:        utils.BoolPointer(false),
			},
		},
		&Action{
			Id:               "MINI",
			ActionType:       TOPUP,
			ExpirationString: UNLIMITED,
			ExtraParameters:  "",
			Weight:           10,
			Balance: &BalanceFilter{
				Type:           utils.StringPointer(utils.VOICE),
				Uuid:           as1[1].Balance.Uuid,
				Directions:     utils.StringMapPointer(utils.NewStringMap(utils.OUT)),
				Value:          &utils.ValueFormula{Static: 100},
				Weight:         utils.Float64Pointer(10),
				RatingSubject:  utils.StringPointer("test"),
				DestinationIDs: utils.StringMapPointer(utils.NewStringMap("NAT")),
				TimingIDs:      nil,
				SharedGroups:   nil,
				Categories:     nil,
				Disabled:       utils.BoolPointer(false),
				Blocker:        utils.BoolPointer(false),
			},
		},
	}
	if !reflect.DeepEqual(as1, expected) {
		t.Errorf("Error loading action1: %s", utils.ToIJSON(as1))
	}
	as2 := csvr.actions["SHARED"]
	expected = []*Action{
		&Action{
			Id:               "SHARED",
			ActionType:       TOPUP,
			ExpirationString: UNLIMITED,
			Weight:           10,
			Balance: &BalanceFilter{
				Type:           utils.StringPointer(utils.MONETARY),
				Directions:     utils.StringMapPointer(utils.NewStringMap(utils.OUT)),
				DestinationIDs: nil,
				Uuid:           as2[0].Balance.Uuid,
				Value:          &utils.ValueFormula{Static: 100},
				Weight:         utils.Float64Pointer(10),
				SharedGroups:   utils.StringMapPointer(utils.NewStringMap("SG1")),
				TimingIDs:      nil,
				Categories:     nil,
				Disabled:       utils.BoolPointer(false),
				Blocker:        utils.BoolPointer(false),
			},
		},
	}
	if !reflect.DeepEqual(as2, expected) {
		t.Errorf("Error loading action: %s", utils.ToIJSON(as2))
	}
	as3 := csvr.actions["DEFEE"]
	expected = []*Action{
		&Action{
			Id:              "DEFEE",
			ActionType:      CDRLOG,
			ExtraParameters: `{"Category":"^ddi","MediationRunId":"^did_run"}`,
			Weight:          10,
			Balance: &BalanceFilter{
				Uuid:           as3[0].Balance.Uuid,
				Directions:     nil,
				DestinationIDs: nil,
				TimingIDs:      nil,
				Categories:     nil,
				SharedGroups:   nil,
				Blocker:        utils.BoolPointer(false),
				Disabled:       utils.BoolPointer(false),
			},
		},
	}
	if !reflect.DeepEqual(as3, expected) {
		t.Errorf("Error loading action: %+v", as3[0].Balance)
	}
}
Exemple #30
0
func TestDfCdrcJsonCfg(t *testing.T) {
	eFields := []*CdrFieldJsonCfg{}
	cdrFields := []*CdrFieldJsonCfg{
		&CdrFieldJsonCfg{Tag: utils.StringPointer("TOR"), Field_id: utils.StringPointer(utils.TOR), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("2"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("OriginID"), Field_id: utils.StringPointer(utils.ACCID), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("3"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("RequestType"), Field_id: utils.StringPointer(utils.REQTYPE), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("4"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Direction"), Field_id: utils.StringPointer(utils.DIRECTION), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("5"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Tenant"), Field_id: utils.StringPointer(utils.TENANT), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("6"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Category"), Field_id: utils.StringPointer(utils.CATEGORY), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("7"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Account"), Field_id: utils.StringPointer(utils.ACCOUNT), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("8"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Subject"), Field_id: utils.StringPointer(utils.SUBJECT), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("9"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Destination"), Field_id: utils.StringPointer(utils.DESTINATION), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("10"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("SetupTime"), Field_id: utils.StringPointer(utils.SETUP_TIME), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("11"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("AnswerTime"), Field_id: utils.StringPointer(utils.ANSWER_TIME), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("12"), Mandatory: utils.BoolPointer(true)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Usage"), Field_id: utils.StringPointer(utils.USAGE), Type: utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer("13"), Mandatory: utils.BoolPointer(true)},
	}
	cacheDumpFields := []*CdrFieldJsonCfg{
		&CdrFieldJsonCfg{Tag: utils.StringPointer("CGRID"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.CGRID)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("RunID"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.MEDI_RUNID)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("TOR"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.TOR)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("OriginID"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.ACCID)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("RequestType"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.REQTYPE)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Direction"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.DIRECTION)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Tenant"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.TENANT)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Category"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.CATEGORY)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Account"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.ACCOUNT)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Subject"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.SUBJECT)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Destination"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.DESTINATION)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("SetupTime"),
			Type:   utils.StringPointer(utils.META_COMPOSED),
			Value:  utils.StringPointer(utils.SETUP_TIME),
			Layout: utils.StringPointer("2006-01-02T15:04:05Z07:00")},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("AnswerTime"),
			Type:   utils.StringPointer(utils.META_COMPOSED),
			Value:  utils.StringPointer(utils.ANSWER_TIME),
			Layout: utils.StringPointer("2006-01-02T15:04:05Z07:00")},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Usage"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.USAGE)},
		&CdrFieldJsonCfg{Tag: utils.StringPointer("Cost"),
			Type:  utils.StringPointer(utils.META_COMPOSED),
			Value: utils.StringPointer(utils.COST)},
	}
	eCfg := []*CdrcJsonCfg{
		&CdrcJsonCfg{
			Id:      utils.StringPointer(utils.META_DEFAULT),
			Enabled: utils.BoolPointer(false),
			Dry_run: utils.BoolPointer(false),
			Cdrs_conns: &[]*HaPoolJsonCfg{&HaPoolJsonCfg{
				Address: utils.StringPointer(utils.MetaInternal),
			}},
			Cdr_format:                  utils.StringPointer("csv"),
			Field_separator:             utils.StringPointer(","),
			Timezone:                    utils.StringPointer(""),
			Run_delay:                   utils.IntPointer(0),
			Max_open_files:              utils.IntPointer(1024),
			Data_usage_multiply_factor:  utils.Float64Pointer(1024.0),
			Cdr_in_dir:                  utils.StringPointer("/var/spool/cgrates/cdrc/in"),
			Cdr_out_dir:                 utils.StringPointer("/var/spool/cgrates/cdrc/out"),
			Failed_calls_prefix:         utils.StringPointer("missed_calls"),
			Cdr_path:                    utils.StringPointer(""),
			Cdr_source_id:               utils.StringPointer("freeswitch_csv"),
			Cdr_filter:                  utils.StringPointer(""),
			Continue_on_success:         utils.BoolPointer(false),
			Partial_record_cache:        utils.StringPointer("10s"),
			Partial_cache_expiry_action: utils.StringPointer(utils.MetaDumpToFile),
			Header_fields:               &eFields,
			Content_fields:              &cdrFields,
			Trailer_fields:              &eFields,
			Cache_dump_fields:           &cacheDumpFields,
		},
	}
	if cfg, err := dfCgrJsonCfg.CdrcJsonCfg(); err != nil {
		t.Error(err)
	} else if !reflect.DeepEqual(eCfg, cfg) {
		t.Errorf("Expecting: \n%s\n, received: \n%s\n: ", utils.ToIJSON(eCfg), utils.ToIJSON(cfg))
	}
}