From 3fd9ed1886fa4f9a9f0f7a40ba02fa320ab13ba9 Mon Sep 17 00:00:00 2001 From: TeoV Date: Thu, 23 Aug 2018 11:07:43 -0400 Subject: [PATCH] Update HttpAgent + RadAgent config --- agents/librad.go | 1 - agents/radagent_it_test.go | 4 +- data/conf/samples/httpagent/httpagent.json | 62 ++++++++-------- data/conf/samples/radagent/cgrates.json | 82 +++++++++++----------- 4 files changed, 74 insertions(+), 75 deletions(-) diff --git a/agents/librad.go b/agents/librad.go index 72268ec12..6f908cedf 100644 --- a/agents/librad.go +++ b/agents/librad.go @@ -53,7 +53,6 @@ func radComposedFieldValue(pkt *radigo.Packet, outVal += out continue } - for _, avp := range pkt.AttributesWithName( attrVendorFromPath(rsrTpl.Rules)) { if parsed, err := rsrTpl.ParseValue(avp.GetStringValue()); err != nil { diff --git a/agents/radagent_it_test.go b/agents/radagent_it_test.go index bb5be8d99..6631d193e 100644 --- a/agents/radagent_it_test.go +++ b/agents/radagent_it_test.go @@ -273,10 +273,10 @@ func TestRAitAcctStop(t *testing.T) { t.Error("Unexpected number of CDRs returned: ", len(cdrs)) } else { if cdrs[0].Usage != "4s" { - t.Errorf("Unexpected CDR Usage received, cdr: %v %+v ", cdrs[0].Usage, cdrs[0]) + t.Errorf("Unexpected CDR Usage received, cdr: %v ", cdrs[0].Usage) } if cdrs[0].CostSource != utils.MetaSessionS { - t.Errorf("Unexpected CDR CostSource received for CDR: %v", cdrs[0]) + t.Errorf("Unexpected CDR CostSource received for CDR: %v", cdrs[0].CostSource) } if cdrs[0].Cost != 0.01 { t.Errorf("Unexpected CDR Cost received for CDR: %v", cdrs[0].Cost) diff --git a/data/conf/samples/httpagent/httpagent.json b/data/conf/samples/httpagent/httpagent.json index 223ddebe2..60773ab69 100644 --- a/data/conf/samples/httpagent/httpagent.json +++ b/data/conf/samples/httpagent/httpagent.json @@ -8,7 +8,7 @@ "sessions_conns": [ {"address": "*internal"} ], - "tenant": "^cgrates.org", + "tenant": "cgrates.org", "timezone": "", "request_payload": "*url", "reply_payload": "*xml", @@ -21,11 +21,11 @@ "request_fields":[ ], "reply_fields":[ - {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + {"id": "Allow", "field_id": "response.Allow", "type": "*constant", "value": "1", "mandatory": true}, - {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + {"id": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", "value": "1200", "blocker": true}, - {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + {"id": "Unused", "field_id": "response.Unused", "type": "*constant", "value": "0"}, ], }, @@ -35,22 +35,22 @@ "flags": [ "*auth", "*accounts", "*attributes"], "continue_on_success": false, "request_fields":[ - {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + {"id": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*pseudoprepaid", "mandatory": true}, - {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", - "value": "*req.CallID", "mandatory": true}, - {"tag": "Account", "field_id": "Account", "type": "*composed", - "value": "*req.Msisdn", "mandatory": true}, - {"tag": "Destination", "field_id": "Destination", "type": "*composed", - "value": "*req.Destination", "mandatory": true}, - {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + {"id": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"id": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"id": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"id": "SetupTime", "field_id": "SetupTime", "type": "*constant", "value": "*now", "mandatory": true}, ], "reply_fields":[ - {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + {"id": "Allow", "field_id": "response.Allow", "type": "*constant", "value": "1", "mandatory": true}, - {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", - "value": "*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + {"id": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, ], }, { @@ -59,25 +59,25 @@ "flags": ["*dryrun", "*cdrs"], "continue_on_success": false, "request_fields":[ - {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + {"id": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*pseudoprepaid", "mandatory": true}, - {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", - "value": "*req.CDR_ID", "mandatory": true}, - {"tag": "Account", "field_id": "Account", "type": "*composed", - "value": "*req.msisdn", "mandatory": true}, - {"tag": "Destination", "field_id": "Destination", "type": "*composed", - "value": "*req.destination", "mandatory": true}, - {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", - "value": "*req.timestamp", "mandatory": true}, - {"tag": "AnswerTime", "field_id": "SetupTime", "type": "*composed", - "value": "*req.timestamp", "mandatory": true}, - {"tag": "Usage", "field_id": "Usage", "type": "*composed", - "value": "*req.leg_duration;^s", "mandatory": true}, + {"id": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"id": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"id": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"id": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"id": "AnswerTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"id": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;^s", "mandatory": true}, ], "reply_fields":[ - {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", - "value": "*req.CDR_ID", "mandatory": true}, - {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + {"id": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"id": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", "value": "1", "mandatory": true}, ], } diff --git a/data/conf/samples/radagent/cgrates.json b/data/conf/samples/radagent/cgrates.json index 5eea84182..34d46171f 100644 --- a/data/conf/samples/radagent/cgrates.json +++ b/data/conf/samples/radagent/cgrates.json @@ -83,22 +83,22 @@ "flags": ["*auth", "*accounts",], "continue_on_success": false, "request_fields":[ - {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + {"id": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid", "mandatory": true}, - {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", - "value": "*req.Acct-Session-Id;^-;*req.Sip-From-Tag", "mandatory": true}, - {"tag": "Account", "field_id": "Account", "type": "*composed", - "value": "*req.User-Name", "mandatory": true}, - {"tag": "Destination", "field_id": "Destination", "type": "*composed", - "value": "*req.Called-Station-Id", "mandatory": true}, - {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", - "value": "*req.Event-Timestamp", "mandatory": true}, - {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", - "value": "*req.Event-Timestamp", "mandatory": true}, + {"id": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true}, + {"id": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"id": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"id": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, + {"id": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Event-Timestamp", "mandatory": true}, ], "reply_fields":[ - {"tag": "MaxUsage", "field_id": "SIP-AVP", "type": "*composed", - "value": "^session_max_time#;*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + {"id": "MaxUsage", "field_id": "SIP-AVP", "type": "*composed", + "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, ], }, { @@ -107,20 +107,20 @@ "flags": ["*initiate","*attributes","*resources","*accounts"], "continue_on_success": false, "request_fields":[ - {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + {"id": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid", "mandatory": true}, - {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", - "value": "*req.Acct-Session-Id;^-;*req.Sip-From-Tag;^-;*req.Sip-To-Tag", "mandatory": true}, - {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", - "value": "*req.NAS-IP-Address", "mandatory": true}, - {"tag": "Account", "field_id": "Account", "type": "*composed", - "value": "*req.User-Name", "mandatory": true}, - {"tag": "Destination", "field_id": "Destination", "type": "*composed", - "value": "*req.Called-Station-Id", "mandatory": true}, - {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", - "value": "*req.Ascend-User-Acct-Time", "mandatory": true}, - {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", - "value": "*req.Ascend-User-Acct-Time", "mandatory": true}, + {"id": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"id": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"id": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"id": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"id": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"id": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, ], "reply_fields":[], }, @@ -130,22 +130,22 @@ "flags": ["*terminate","*resources","*accounts","*cdrs"], "continue_on_success": false, "request_fields":[ - {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + {"id": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid", "mandatory": true}, - {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", - "value": "*req.Acct-Session-Id;^-;*req.Sip-From-Tag;^-;*req.Sip-To-Tag", "mandatory": true}, - {"tag": "OriginHost", "field_id": "OriginHost", "type": "*composed", - "value": "*req.NAS-IP-Address", "mandatory": true}, - {"tag": "Account", "field_id": "Account", "type": "*composed", - "value": "*req.User-Name", "mandatory": true}, - {"tag": "Destination", "field_id": "Destination", "type": "*composed", - "value": "*req.Called-Station-Id", "mandatory": true}, - {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", - "value": "*req.Ascend-User-Acct-Time", "mandatory": true}, - {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", - "value": "*req.Ascend-User-Acct-Time", "mandatory": true}, - {"tag": "Usage", "field_id": "Usage", "type": "*usage_difference", - "value": "*req.Event-Timestamp;*req.Ascend-User-Acct-Time", "mandatory": true}, + {"id": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true}, + {"id": "OriginHost", "field_id": "OriginHost", "type": "*composed", + "value": "~*req.NAS-IP-Address", "mandatory": true}, + {"id": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.User-Name", "mandatory": true}, + {"id": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Called-Station-Id", "mandatory": true}, + {"id": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"id": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.Ascend-User-Acct-Time", "mandatory": true}, + {"id": "Usage", "field_id": "Usage", "type": "*usage_difference", + "value": "~*req.Event-Timestamp;~*req.Ascend-User-Acct-Time", "mandatory": true}, ], "reply_fields":[], },