Template field with blocker option, test HTTPAgent OutboundAuth with dryRun option

This commit is contained in:
DanB
2018-07-06 18:20:55 +02:00
parent c5f61e8727
commit 4c768e95f9
5 changed files with 35 additions and 9 deletions

View File

@@ -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
}

View File

@@ -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(`<?xml version="1.0" encoding="UTF-8"?>
<response>
<Allow>1</Allow>
<MaxDuration>1200</MaxDuration>
</response>`)
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()
}

View File

@@ -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) {

View File

@@ -164,6 +164,7 @@ type CdrFieldJsonCfg struct {
Mask_length *int
Break_on_success *bool
New_branch *bool
Blocker *bool
}
// Cdre config section

View File

@@ -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},
],
},
{