diff --git a/data/conf/samples/ees/cgrates.json b/data/conf/samples/ees/cgrates.json index 532c1e6d0..0fc8c50a3 100644 --- a/data/conf/samples/ees/cgrates.json +++ b/data/conf/samples/ees/cgrates.json @@ -345,7 +345,7 @@ {"tag": "ToR", "path": "*exp.ToR", "type": "*variable", "value": "~*req.ToR"}, {"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value": "~*req.OriginID"}, {"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value": "~*req.RequestType"}, - {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*tenant.Tenant"}, + {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*vars.*tenant"}, {"tag": "Category", "path": "*exp.Category", "type": "*variable", "value": "~*req.Category"}, {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value": "~*req.Account"}, {"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value": "~*req.Subject"}, @@ -391,7 +391,7 @@ {"tag": "ToR", "path": "*exp.ToR", "type": "*variable", "value": "~*req.ToR"}, {"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value": "~*req.OriginID"}, {"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value": "~*req.RequestType"}, - {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*tenant.Tenant"}, + {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*vars.*tenant"}, {"tag": "Category", "path": "*exp.Category", "type": "*variable", "value": "~*req.Category"}, {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value": "~*req.Account"}, {"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value": "~*req.Subject"}, @@ -439,7 +439,7 @@ {"tag": "ToR", "path": "*exp.ToR", "type": "*variable", "value": "~*req.ToR"}, {"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value": "~*req.OriginID"}, {"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value": "~*req.RequestType"}, - {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*tenant.Tenant"}, + {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*vars.*tenant"}, {"tag": "Category", "path": "*exp.Category", "type": "*variable", "value": "~*req.Category"}, {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value": "~*req.Account"}, {"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value": "~*req.Subject"}, @@ -490,7 +490,7 @@ {"tag": "ToR", "path": "*exp.ToR", "type": "*variable", "value": "~*req.ToR"}, {"tag": "OriginID", "path": "*exp.OriginID", "type": "*variable", "value": "~*req.OriginID"}, {"tag": "RequestType", "path": "*exp.RequestType", "type": "*variable", "value": "~*req.RequestType"}, - {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*tenant.Tenant"}, + {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*vars.*tenant"}, {"tag": "Category", "path": "*exp.Category", "type": "*variable", "value": "~*req.Category"}, {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value": "~*req.Account"}, {"tag": "Subject", "path": "*exp.Subject", "type": "*variable", "value": "~*req.Subject"}, diff --git a/ees/ee_test.go b/ees/ee_test.go index 6b31e23ab..db7a9f04f 100644 --- a/ees/ee_test.go +++ b/ees/ee_test.go @@ -290,3 +290,35 @@ func TestEEPrepareOrderMap(t *testing.T) { t.Errorf("Expected %v \n but received \n %v", utils.IfaceAsString(body), utils.IfaceAsString(rcv)) } } + +func TestExportRequestTenant(t *testing.T) { + bP := new(bytePreparing) + inData := map[string]utils.DataStorage{ + utils.MetaVars: utils.MapStorage{ + utils.MetaTenant: "cgrates.org"}, + } + expNM := utils.NewOrderedNavigableMap() + tpFields := []*config.FCTemplate{ + { + Tag: "Tenant", + Path: utils.MetaExp + utils.NestingSep + utils.Tenant, + Type: utils.MetaVariable, + Value: config.NewRSRParsersMustCompile(utils.DynamicDataPrefix+utils.MetaVars+utils.NestingSep+utils.MetaTenant, utils.InfieldSep), + }, + } + tpFields[0].ComputePath() + if err := engine.NewExportRequest(inData, "cgrates.org", nil, map[string]*utils.OrderedNavigableMap{utils.MetaExp: expNM}).SetFields(tpFields); err != nil { + t.Error(err) + } + rcv, err := bP.PrepareOrderMap(expNM) + if err != nil { + t.Error(err) + } + valMp := map[string]any{ + "Tenant": "cgrates.org", + } + body, _ := json.Marshal(valMp) + if !reflect.DeepEqual(rcv, body) { + t.Errorf("Expected %v \n but received \n %v", utils.IfaceAsString(body), utils.IfaceAsString(rcv)) + } +} diff --git a/ees/ees.go b/ees/ees.go index 67e03ce5c..7774bd61c 100644 --- a/ees/ees.go +++ b/ees/ees.go @@ -266,12 +266,12 @@ func exportEventWithExporter(exp EventExporter, ev *utils.CGREvent, oneTime bool } else { expNM := utils.NewOrderedNavigableMap() err = engine.NewExportRequest(map[string]utils.DataStorage{ - utils.MetaReq: utils.MapStorage(ev.Event), - utils.MetaDC: exp.GetMetrics(), - utils.MetaOpts: utils.MapStorage(ev.APIOpts), - utils.MetaCfg: cfg.GetDataProvider(), - utils.MetaEC: utils.MapStorage{utils.CostDetails: ev.Event[utils.CostDetails]}, - utils.MetaTenant: utils.MapStorage{utils.Tenant: ev.Tenant}, + utils.MetaReq: utils.MapStorage(ev.Event), + utils.MetaDC: exp.GetMetrics(), + utils.MetaOpts: utils.MapStorage(ev.APIOpts), + utils.MetaCfg: cfg.GetDataProvider(), + utils.MetaEC: utils.MapStorage{utils.CostDetails: ev.Event[utils.CostDetails]}, + utils.MetaVars: utils.MapStorage{utils.MetaTenant: ev.Tenant}, }, utils.FirstNonEmpty(ev.Tenant, cfg.GeneralCfg().DefaultTenant), filterS, map[string]*utils.OrderedNavigableMap{utils.MetaExp: expNM}).SetFields(exp.Cfg().ContentFields())