CGREvent inside AttrSProcessEventReply change

This commit is contained in:
armirveliaj
2025-03-27 06:06:13 -04:00
committed by Dan Christian Bogos
parent eafde112ea
commit ab8188c923
4 changed files with 10 additions and 10 deletions

View File

@@ -125,8 +125,8 @@ func (flds *AttrSProcessEventReply) UniqueAlteredFields() (unFlds utils.StringSe
// AttrSProcessEventReply reply used for proccess event
type AttrSProcessEventReply struct {
AlteredFields []*FieldsAltered
*utils.CGREvent
blocker bool // internally used to stop further processRuns
CGREvent *utils.CGREvent
blocker bool // internally used to stop further processRuns
}
// Digest returns serialized version of alteredFields in AttrSProcessEventReply
@@ -177,7 +177,7 @@ func (alS *AttributeS) processEvent(ctx *context.Context, tnt string, args *util
CGREvent: args,
blocker: blocker,
}
rply.Tenant = tnt
rply.CGREvent.Tenant = tnt
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 {

View File

@@ -298,7 +298,7 @@ func (rpS *RouteS) V1GetRoutes(ctx *context.Context, args *utils.CGREvent, reply
if err := rpS.connMgr.Call(ctx, rpS.cfg.RouteSCfg().AttributeSConns,
utils.AttributeSv1ProcessEvent, args, &rplyEv); err == nil && len(rplyEv.AlteredFields) != 0 {
args = rplyEv.CGREvent
args.APIOpts = rplyEv.APIOpts
args.APIOpts = rplyEv.CGREvent.APIOpts
} else if err = utils.CastRPCErr(err); err != utils.ErrNotFound {
return utils.NewErrRouteS(err)
}

View File

@@ -5461,11 +5461,11 @@ func TestAttributesProcessEventPasswordAttribute(t *testing.T) {
t.Fatalf("expected: <%+v>,\nreceived: <%+v>",
utils.ToJSON(exp.AlteredFields), utils.ToJSON(reply.AlteredFields))
} else {
hashedPw = utils.IfaceAsString(reply.Event["Password"])
hashedPw = utils.IfaceAsString(reply.CGREvent.Event["Password"])
if !utils.VerifyHash(hashedPw, "abcd123") {
t.Fatalf("expected: <%+v>, \nreceived: <%+v>", "abcd123", hashedPw)
}
exp.Event["Password"] = hashedPw
exp.CGREvent.Event["Password"] = hashedPw
if !reflect.DeepEqual(reply.CGREvent, exp.CGREvent) {
t.Fatalf("expected: <%+v>, \nreceived: <%+v>",
utils.ToJSON(exp.CGREvent), utils.ToJSON(reply.CGREvent))

View File

@@ -121,7 +121,7 @@ func TestAnzDocIT(t *testing.T) {
anzStringQuery(t, client, 7, "", "*lte:~*hdr.RequestID:2")
anzStringQuery(t, client, -1, "", "*gt:~*hdr.RequestDuration:1ms")
anzStringQuery(t, client, 1, `+RequestMethod:"AttributeSv1.ProcessEvent"`, "*notstring:~*rep.Event.Cost:0")
anzStringQuery(t, client, 1, `+RequestMethod:"AttributeSv1.ProcessEvent"`, "*notstring:~*rep.CGREvent.Event.Cost:0")
anzStringQuery(t, client, 1, `+RequestMethod:"CoreSv1.Status"`, "*gt:~*rep.goroutines:47")
}
@@ -432,7 +432,7 @@ func attrProcessEvents(t *testing.T, client *birpc.Client) {
utils.Cost: 2.01,
},
}
expectedReply := `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_1001","Fields":["*req.RequestType"]}],"Tenant":"cgrates.org","ID":"call1001to1002","Event":{"Account":"1001","AnswerTime":"2013-11-07T08:42:28Z","Category":"call","Cost":1.01,"Destination":"1002","OriginHost":"192.168.1.1","OriginID":"abcdef","RequestType":"*rated","RunID":"*default","SetupTime":"2013-11-07T08:42:25Z","Subject":"1001","Tenant":"cgrates.org","ToR":"*voice","Usage":10000000000},"APIOpts":{}}`
expectedReply := `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_1001","Fields":["*req.RequestType"]}],"CGREvent":{"Tenant":"cgrates.org","ID":"call1001to1002","Event":{"Account":"1001","AnswerTime":"2013-11-07T08:42:28Z","Category":"call","Cost":1.01,"Destination":"1002","OriginHost":"192.168.1.1","OriginID":"abcdef","RequestType":"*rated","RunID":"*default","SetupTime":"2013-11-07T08:42:25Z","Subject":"1001","Tenant":"cgrates.org","ToR":"*voice","Usage":10000000000},"APIOpts":{}}}`
var rplyEv engine.AttrSProcessEventReply
if err := client.Call(context.Background(), utils.AttributeSv1ProcessEvent,
eventCall1001to1002, &rplyEv); err != nil {
@@ -441,7 +441,7 @@ func attrProcessEvents(t *testing.T, client *birpc.Client) {
t.Errorf("expected: <%+v>, \nreceived: <%+v>",
expectedReply, jsonReply)
}
expectedReply = `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_PRF_11","Fields":["*req.Cost"]},{"MatchedProfileID":"cgrates.org:ATTR_1101","Fields":["*req.RequestType"]}],"Tenant":"cgrates.org","ID":"call1011to1002","Event":{"Account":"1101","AnswerTime":"2013-11-07T08:42:35Z","Category":"call","Cost":"0","Destination":"1002","OriginHost":"192.168.1.1","OriginID":"ghijkl","RequestType":"*prepaid","RunID":"*default","SetupTime":"2013-11-07T08:42:28Z","Subject":"1101","Tenant":"cgrates.org","ToR":"*voice","Usage":15000000000},"APIOpts":{}}`
expectedReply = `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_PRF_11","Fields":["*req.Cost"]},{"MatchedProfileID":"cgrates.org:ATTR_1101","Fields":["*req.RequestType"]}],"CGREvent":{"Tenant":"cgrates.org","ID":"call1011to1002","Event":{"Account":"1101","AnswerTime":"2013-11-07T08:42:35Z","Category":"call","Cost":"0","Destination":"1002","OriginHost":"192.168.1.1","OriginID":"ghijkl","RequestType":"*prepaid","RunID":"*default","SetupTime":"2013-11-07T08:42:28Z","Subject":"1101","Tenant":"cgrates.org","ToR":"*voice","Usage":15000000000},"APIOpts":{}}}`
if err := client.Call(context.Background(), utils.AttributeSv1ProcessEvent,
eventCall1101to1002, &rplyEv); err != nil {
t.Error(err)
@@ -449,7 +449,7 @@ func attrProcessEvents(t *testing.T, client *birpc.Client) {
t.Errorf("expected: <%+v>, \nreceived: <%+v>",
expectedReply, jsonReply)
}
expectedReply = `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_PRF_11","Fields":["*req.Cost"]},{"MatchedProfileID":"cgrates.org:ATTR_1102","Fields":["*req.RequestType"]}],"Tenant":"cgrates.org","ID":"call1102to1001","Event":{"Account":"1102","AnswerTime":"2013-11-07T08:42:42Z","Category":"call","Cost":"0","Destination":"1001","OriginHost":"192.168.1.1","OriginID":"uvwxyz","RequestType":"*pseudoprepaid","RunID":"*default","SetupTime":"2013-11-07T08:42:35Z","Subject":"1102","Tenant":"cgrates.org","ToR":"*voice","Usage":20000000000},"APIOpts":{}}`
expectedReply = `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_PRF_11","Fields":["*req.Cost"]},{"MatchedProfileID":"cgrates.org:ATTR_1102","Fields":["*req.RequestType"]}],"CGREvent":{"Tenant":"cgrates.org","ID":"call1102to1001","Event":{"Account":"1102","AnswerTime":"2013-11-07T08:42:42Z","Category":"call","Cost":"0","Destination":"1001","OriginHost":"192.168.1.1","OriginID":"uvwxyz","RequestType":"*pseudoprepaid","RunID":"*default","SetupTime":"2013-11-07T08:42:35Z","Subject":"1102","Tenant":"cgrates.org","ToR":"*voice","Usage":20000000000},"APIOpts":{}}}`
if err := client.Call(context.Background(), utils.AttributeSv1ProcessEvent,
eventCall1102to1001, &rplyEv); err != nil {
t.Error(err)