diff --git a/apier/v1/sessions_process_event_it_test.go b/apier/v1/sessions_process_event_it_test.go index 2f461cf9c..aa73ff037 100644 --- a/apier/v1/sessions_process_event_it_test.go +++ b/apier/v1/sessions_process_event_it_test.go @@ -43,12 +43,12 @@ var sTestSessionSv1ProcessEvent = []func(t *testing.T){ testSSv1ItRpcConn, testSSv1ItPing, testSSv1ItTPFromFolder, - // testSSv1ItProcessEventAuth, + testSSv1ItProcessEventAuth, testSSv1ItProcessEventInitiateSession, - // testSSv1ItProcessEventUpdateSession, - // testSSv1ItProcessEventTerminateSession, - // testSSv1ItProcessCDRForSessionFromProcessEvent, - // testSSv1ItGetCDRs, + testSSv1ItProcessEventUpdateSession, + testSSv1ItProcessEventTerminateSession, + testSSv1ItProcessCDRForSessionFromProcessEvent, + testSSv1ItGetCDRs, testSSv1ItStopCgrEngine, } diff --git a/data/conf/samples/dispatchers/dispatchers_internal/cgrates.json b/data/conf/samples/dispatchers/dispatchers_internal/cgrates.json index c31e657ac..7c4efb2f7 100644 --- a/data/conf/samples/dispatchers/dispatchers_internal/cgrates.json +++ b/data/conf/samples/dispatchers/dispatchers_internal/cgrates.json @@ -50,19 +50,13 @@ "enabled": true, }, - "rpc_conns": { - "conn1": { - "strategy": "*first", - "conns": [{"address": "127.0.0.1:2012", "transport":"*json"}], - }, - }, "sessions": { "enabled": true, - "attributes_conns": ["conn1"], - "rals_conns": ["conn1"], - "resources_conns": ["conn1"], - "chargers_conns": ["conn1"], + "attributes_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "resources_conns": ["*localhost"], + "chargers_conns": ["*localhost"], "listen_bijson": ":3014", }, diff --git a/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json b/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json index a991c2a98..a61e81682 100644 --- a/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json +++ b/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json @@ -53,19 +53,12 @@ "enabled": true, }, -"rpc_conns": { - "conn1": { - "strategy": "*first", - "conns": [{"address": "127.0.0.1:2012", "transport":"*json"}], - }, -}, - "sessions": { "enabled": true, - "attributes_conns": ["conn1"], - "rals_conns": ["conn1"], - "resources_conns": ["conn1"], - "chargers_conns": ["conn1"], + "attributes_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "resources_conns": ["*localhost"], + "chargers_conns": ["*localhost"], "listen_bijson": ":3014", }, diff --git a/data/conf/samples/dispatchers/dispatchers_mysql/cgrates.json b/data/conf/samples/dispatchers/dispatchers_mysql/cgrates.json index 386e45435..1fd1c9de9 100755 --- a/data/conf/samples/dispatchers/dispatchers_mysql/cgrates.json +++ b/data/conf/samples/dispatchers/dispatchers_mysql/cgrates.json @@ -44,19 +44,12 @@ "enabled": true, }, -"rpc_conns": { - "conn1": { - "strategy": "*first", - "conns": [{"address": "127.0.0.1:2012", "transport":"*json"}], - }, -}, - "sessions": { "enabled": true, - "attributes_conns": ["conn1"], - "rals_conns": ["conn1"], - "resources_conns": ["conn1"], - "chargers_conns": ["conn1"], + "attributes_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "resources_conns": ["*localhost"], + "chargers_conns": ["*localhost"], "listen_bijson": ":3014", }, diff --git a/data/tariffplans/dispatchers/Attributes.csv b/data/tariffplans/dispatchers/Attributes.csv index a07ee0570..5f004a8e6 100644 --- a/data/tariffplans/dispatchers/Attributes.csv +++ b/data/tariffplans/dispatchers/Attributes.csv @@ -1,6 +1,6 @@ #Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,FieldName,Type,Value,Blocker,Weight cgrates.org,ATTR_1001_SIMPLEAUTH,*any,*string:~*req.Account:1001,,,*req.Password,*constant,CGRateS.org,false,20 -cgrates.org,ATTR_1001_SIMPLEAUTH,*any,,,,EventName,*constant,*remove,false,20 +cgrates.org,ATTR_1001_SIMPLEAUTH,*any,,,,*req.EventName,*constant,*remove,false,20 cgrates.org,ATTR_1003_SIMPLEAUTH,*any,*string:~*req.Account:1003,,,*req.Password,*constant,CGRateS.com,false,20 cgrates.org,ATTR_API_ATTR_FAKE_AUTH,*auth,*string:~*req.APIKey:12345,,,*req.APIMethods,*constant,,false,20 cgrates.org,ATTR_API_ATTR_AUTH,*auth,*string:~*req.APIKey:attr12345,,,*req.APIMethods,*constant,AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent,false,20 diff --git a/engine/attributes.go b/engine/attributes.go index 998101680..0a4c5cc84 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -168,14 +168,9 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent) ( } rply = &AttrSProcessEventReply{ MatchedProfiles: []string{attrPrf.ID}, - CGREvent: &utils.CGREvent{ - Tenant: args.Tenant, - ID: args.ID, - Time: args.Time, - Event: make(map[string]interface{}), - }, - blocker: attrPrf.Blocker} - evNm := config.NewNavigableMap(map[string]interface{}{utils.MetaReq: args.Event}) + CGREvent: args.CGREvent, + blocker: attrPrf.Blocker} + evNm := config.NewNavigableMap(map[string]interface{}{utils.MetaReq: rply.CGREvent.Event}) for _, attribute := range attrPrf.Attributes { //in case that we have filter for attribute send them to FilterS to be processed if len(attribute.FilterIDs) != 0 { @@ -265,9 +260,9 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent) ( } if attribute.FieldName == utils.MetaTenant { if attribute.Type == utils.META_COMPOSED { - args.CGREvent.Tenant += substitute + rply.CGREvent.Tenant += substitute } else { - args.CGREvent.Tenant = substitute + rply.CGREvent.Tenant = substitute } continue } @@ -282,18 +277,6 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent) ( } evNm.Set(strings.Split(attribute.FieldName, utils.NestingSep), substitute, false, false) } - var ev interface{} - ev, err = evNm.FieldAsInterface([]string{utils.MetaReq}) - if err != nil { - if err.Error() == utils.ErrNotFound.Error() { - return - } - return nil, err - } - var ok bool - if rply.CGREvent.Event, ok = ev.(map[string]interface{}); !ok { - return nil, fmt.Errorf("invalid event") - } return } @@ -327,6 +310,7 @@ func (alS *AttributeService) V1ProcessEvent(args *AttrArgsProcessEvent, args.ProcessRuns = utils.IntPointer(alS.cgrcfg.AttributeSCfg().ProcessRuns) } var apiRply *AttrSProcessEventReply // aggregate response here + args.CGREvent = args.CGREvent.Clone() for i := 0; i < *args.ProcessRuns; i++ { var evRply *AttrSProcessEventReply evRply, err = alS.processEvent(args) @@ -338,9 +322,6 @@ func (alS *AttributeService) V1ProcessEvent(args *AttrArgsProcessEvent, } break } - if len(evRply.AlteredFields) != 0 { - args.CGREvent = evRply.CGREvent // for next loop - } if apiRply == nil { // first reply apiRply = evRply if apiRply.blocker {