mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Default requestType in agents
This commit is contained in:
committed by
Dan Christian Bogos
parent
db672ba0e5
commit
348dcb5d6a
@@ -144,7 +144,7 @@ func (smaEv *SMAsteriskEvent) Destination() string {
|
||||
}
|
||||
|
||||
func (smaEv *SMAsteriskEvent) RequestType() string {
|
||||
return smaEv.cachedFields[utils.CGRReqType]
|
||||
return utils.FirstNonEmpty(smaEv.cachedFields[utils.CGRReqType], config.CgrConfig().GeneralCfg().DefaultReqType)
|
||||
}
|
||||
|
||||
func (smaEv *SMAsteriskEvent) Tenant() string {
|
||||
|
||||
@@ -211,7 +211,7 @@ func TestSMAEventRequestType(t *testing.T) {
|
||||
}
|
||||
ev = make(map[string]interface{}) // Clear previous data
|
||||
smaEv = NewSMAsteriskEvent(ev, "127.0.0.1", "")
|
||||
if smaEv.RequestType() != "" {
|
||||
if smaEv.RequestType() != config.CgrConfig().GeneralCfg().DefaultReqType {
|
||||
t.Error("Received:", smaEv.RequestType())
|
||||
}
|
||||
}
|
||||
@@ -459,3 +459,19 @@ func TestSMAEventV1TerminateSessionArgs(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(exp2), utils.ToJSON(rcv))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestType(t *testing.T) {
|
||||
var ev map[string]interface{}
|
||||
if err := json.Unmarshal([]byte(stasisStart), &ev); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
smaEv := NewSMAsteriskEvent(ev, "127.0.0.1", "")
|
||||
if smaEv.RequestType() != "*prepaid" {
|
||||
t.Error("Received:", smaEv.RequestType())
|
||||
}
|
||||
ev = make(map[string]interface{}) // Clear previous data
|
||||
smaEv = NewSMAsteriskEvent(ev, "127.0.0.1", "")
|
||||
if smaEv.RequestType() != config.CgrConfig().GeneralCfg().DefaultReqType {
|
||||
t.Error("Received:", smaEv.RequestType())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +147,9 @@ func (kev KamEvent) AsMapStringInterface() (mp map[string]interface{}) {
|
||||
if _, has := mp[utils.Source]; !has {
|
||||
mp[utils.Source] = utils.KamailioAgent
|
||||
}
|
||||
if _, has := mp[utils.RequestType]; !has {
|
||||
mp[utils.RequestType] = config.CgrConfig().GeneralCfg().DefaultReqType
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ func TestKamEvAsMapStringInterface(t *testing.T) {
|
||||
expMp["from_tag"] = "bf71ad59"
|
||||
expMp["to_tag"] = "7351fecf"
|
||||
expMp["cgr_reqtype"] = utils.MetaPostpaid
|
||||
expMp[utils.RequestType] = utils.MetaRated
|
||||
expMp[utils.Source] = utils.KamailioAgent
|
||||
rcv := kamEv.AsMapStringInterface()
|
||||
if !reflect.DeepEqual(expMp, rcv) {
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
# Install and config CGRateS
|
||||
- name: Install and config CGRateS
|
||||
include: cgrates.yaml
|
||||
|
||||
|
||||
# Configure Asterisk
|
||||
- name: Download Asterisk
|
||||
become: yes
|
||||
|
||||
Reference in New Issue
Block a user