diff --git a/agents/agentreq.go b/agents/agentreq.go index a48a4416c..718c7df3b 100644 --- a/agents/agentreq.go +++ b/agents/agentreq.go @@ -127,6 +127,9 @@ func (ar *AgentRequest) AsNavigableMap(tplFlds []*config.CfgCdrField) ( } valSet = append(valSet, &engine.NMItem{Data: out, Path: fldPath, Config: tplFld}) nM.Set(fldPath, valSet, true) + if tplFld.Blocker { // useful in case of processing errors first + break + } } return } diff --git a/agents/httpagent_it_test.go b/agents/httpagent_it_test.go index 8f4a0aea6..dcbdb86e8 100644 --- a/agents/httpagent_it_test.go +++ b/agents/httpagent_it_test.go @@ -27,6 +27,7 @@ import ( "net/rpc" "net/rpc/jsonrpc" "path" + "reflect" "testing" "time" @@ -69,14 +70,12 @@ func TestHAitResetStorDb(t *testing.T) { } } -/* // Start CGR Engine func TestHAitStartEngine(t *testing.T) { if _, err := engine.StopStartEngine(haCfgPath, *waitRater); err != nil { t.Fatal(err) } } -*/ // Connect rpc client to rater func TestHAitApierRpcConn(t *testing.T) { @@ -97,17 +96,22 @@ func TestHAitTPFromFolder(t *testing.T) { time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups } -func TestHAitAuth(t *testing.T) { +func TestHAitAuthDryRun(t *testing.T) { reqUrl := fmt.Sprintf("http://%s%s?request_type=OutboundAUTH&CallID=123456&Msisdn=497700056231&Imsi=2343000000000123&Destination=491239440004&MSRN=0102220233444488999&ProfileID=1&AgentID=176&GlobalMSISDN=497700056129&GlobalIMSI=214180000175129&ICCID=8923418450000089629&MCC=234&MNC=10&calltype=callback", haCfg.HTTPListen, haCfg.HttpAgentCfg()[0].Url) rply, err := httpC.Get(reqUrl) if err != nil { t.Error(err) } + eXml := []byte(` + + 1 + 1200 +`) if body, err := ioutil.ReadAll(rply.Body); err != nil { t.Error(err) - } else { - fmt.Printf("Got reply: %s\n", string(body)) + } else if !reflect.DeepEqual(eXml, body) { + t.Errorf("expecting: %s, received: %s", string(eXml), string(body)) } rply.Body.Close() } diff --git a/config/cfgcdrfield.go b/config/cfgcdrfield.go index 50158a6bd..d3a636c83 100644 --- a/config/cfgcdrfield.go +++ b/config/cfgcdrfield.go @@ -95,6 +95,9 @@ func NewCfgCdrFieldFromCdrFieldJsonCfg(jsnCfgFld *CdrFieldJsonCfg) (*CfgCdrField if jsnCfgFld.New_branch != nil { cfgFld.NewBranch = *jsnCfgFld.New_branch } + if jsnCfgFld.Blocker != nil { + cfgFld.Blocker = *jsnCfgFld.Blocker + } return cfgFld, nil } @@ -120,6 +123,7 @@ type CfgCdrField struct { MaskLen int BreakOnSuccess bool NewBranch bool + Blocker bool } func CfgCdrFieldsFromCdrFieldsJsonCfg(jsnCfgFldss []*CdrFieldJsonCfg) ([]*CfgCdrField, error) { diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 6927e0ac7..d3bcd1096 100755 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -164,6 +164,7 @@ type CdrFieldJsonCfg struct { Mask_length *int Break_on_success *bool New_branch *bool + Blocker *bool } // Cdre config section diff --git a/data/conf/samples/httpagent/httpagent.json b/data/conf/samples/httpagent/httpagent.json index cfc8e314d..dd706ec96 100644 --- a/data/conf/samples/httpagent/httpagent.json +++ b/data/conf/samples/httpagent/httpagent.json @@ -13,6 +13,22 @@ "request_payload": "*url", "reply_payload": "*xml", "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:*request.request_type:OutboundAUTH","*string:*request.Msisdn:497700056231"], + "flags": ["*dryrun"], + "continue_on_success": false, + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "NotUsed", "field_id": "response.NotUnused", "type": "*constant", + "value": "0"}, + ], + }, { "id": "OutboundAUTH", "filters": ["*string:*request.request_type:OutboundAUTH"], @@ -33,10 +49,8 @@ "reply_fields":[ {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", "value": "1", "mandatory": true}, - //{"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", - // "value": "*cgrReply.MaxUsage{*duration_seconds}", "mandatory": true}, - {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", - "value": "1200", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "*cgrReply.MaxUsage{*duration_seconds}", "mandatory": true}, ], }, {