mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 23:58:44 +05:00
This commit is contained in:
@@ -73,14 +73,12 @@ func TestDiamItResetStorDb(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Start CGR Engine
|
||||
func TestDiamItStartEngine(t *testing.T) {
|
||||
if _, err := engine.StopStartEngine(daCfgPath, 4000); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestDiamItConnectDiameterClient(t *testing.T) {
|
||||
diamClnt, err = NewDiameterClient(daCfg.DiameterAgentCfg().Listen, "INTEGRATION_TESTS",
|
||||
@@ -466,5 +464,72 @@ func TestDiamItCCRTerminate(t *testing.T) {
|
||||
t.Errorf("Unexpected Usage CDR: %+v", cdrs[0])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDiamItCCRSMS(t *testing.T) {
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("TestDmtAgentSendCCRSMS"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
ccr.NewAVP(avp.OriginRealm, avp.Mbit, 0, datatype.DiameterIdentity("cgrates.org"))
|
||||
ccr.NewAVP(avp.AuthApplicationID, avp.Mbit, 0, datatype.Unsigned32(4))
|
||||
ccr.NewAVP(avp.ServiceContextID, avp.Mbit, 0, datatype.UTF8String("message@DiamItCCRSMS"))
|
||||
ccr.NewAVP(avp.CCRequestType, avp.Mbit, 0, datatype.Enumerated(4))
|
||||
ccr.NewAVP(avp.CCRequestNumber, avp.Mbit, 0, datatype.Unsigned32(0))
|
||||
ccr.NewAVP(avp.EventTimestamp, avp.Mbit, 0, datatype.Time(time.Date(2018, 10, 5, 11, 43, 10, 0, time.UTC)))
|
||||
ccr.NewAVP(avp.SubscriptionID, avp.Mbit, 0, &diam.GroupedAVP{
|
||||
AVP: []*diam.AVP{
|
||||
diam.NewAVP(avp.SubscriptionIDType, avp.Mbit, 0, datatype.Enumerated(0)),
|
||||
diam.NewAVP(avp.SubscriptionIDData, avp.Mbit, 0, datatype.UTF8String("1001")), // Subscription-Id-Data
|
||||
}})
|
||||
ccr.NewAVP(avp.SubscriptionID, avp.Mbit, 0, &diam.GroupedAVP{
|
||||
AVP: []*diam.AVP{
|
||||
diam.NewAVP(avp.SubscriptionIDType, avp.Mbit, 0, datatype.Enumerated(1)),
|
||||
diam.NewAVP(avp.SubscriptionIDData, avp.Mbit, 0, datatype.UTF8String("104502200011")), // Subscription-Id-Data
|
||||
}})
|
||||
ccr.NewAVP(avp.ServiceIdentifier, avp.Mbit, 0, datatype.Unsigned32(0))
|
||||
ccr.NewAVP(avp.RequestedAction, avp.Mbit, 0, datatype.Enumerated(0))
|
||||
ccr.NewAVP(avp.RequestedServiceUnit, avp.Mbit, 0, &diam.GroupedAVP{
|
||||
AVP: []*diam.AVP{
|
||||
diam.NewAVP(avp.CCTime, avp.Mbit, 0, datatype.Unsigned32(1))}})
|
||||
ccr.NewAVP(873, avp.Mbit, 10415, &diam.GroupedAVP{ //
|
||||
AVP: []*diam.AVP{
|
||||
diam.NewAVP(20300, avp.Mbit, 2011, &diam.GroupedAVP{ // IN-Information
|
||||
AVP: []*diam.AVP{
|
||||
diam.NewAVP(20302, avp.Mbit, 2011, datatype.UTF8String("22509")), // Calling-Vlr-Number
|
||||
diam.NewAVP(20385, avp.Mbit, 2011, datatype.UTF8String("4002")), // Called-Party-NP
|
||||
},
|
||||
}),
|
||||
diam.NewAVP(2000, avp.Mbit, 10415, &diam.GroupedAVP{ // SMS-Information
|
||||
AVP: []*diam.AVP{
|
||||
diam.NewAVP(886, avp.Mbit, 10415, &diam.GroupedAVP{ // Originator-Address
|
||||
AVP: []*diam.AVP{
|
||||
diam.NewAVP(899, avp.Mbit, 10415, datatype.Enumerated(1)), // Address-Type
|
||||
diam.NewAVP(897, avp.Mbit, 10415, datatype.UTF8String("1001")), // Address-Data
|
||||
}}),
|
||||
diam.NewAVP(1201, avp.Mbit, 10415, &diam.GroupedAVP{ // Recipient-Address
|
||||
AVP: []*diam.AVP{
|
||||
diam.NewAVP(899, avp.Mbit, 10415, datatype.Enumerated(1)), // Address-Type
|
||||
diam.NewAVP(897, avp.Mbit, 10415, datatype.UTF8String("1003")), // Address-Data
|
||||
}}),
|
||||
},
|
||||
}),
|
||||
}})
|
||||
if err := diamClnt.SendMessage(ccr); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
diamClnt.ReceivedMessage(rplyTimeout)
|
||||
|
||||
var cdrs []*engine.CDR
|
||||
args := utils.RPCCDRsFilter{RunIDs: []string{utils.MetaRaw}, ToRs: []string{utils.SMS}}
|
||||
if err := apierRpc.Call(utils.CdrsV1GetCDRs, args, &cdrs); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
} else if len(cdrs) != 1 {
|
||||
t.Error("Unexpected number of CDRs returned: ", len(cdrs))
|
||||
} else {
|
||||
if cdrs[0].Usage != 1 {
|
||||
t.Errorf("Unexpected Usage CDR: %+v", cdrs[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
],
|
||||
"reply_fields": [
|
||||
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
|
||||
{"tag": "ResultCode", "filters": ["*string:*cgrep.MaxUsage:0"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "4010", "blocker": true},
|
||||
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
],
|
||||
"reply_fields": [
|
||||
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
|
||||
{"tag": "ResultCode", "filters": ["*string:*cgrep.MaxUsage:0"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "4010", "blocker": true},
|
||||
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -90,8 +90,8 @@
|
||||
],
|
||||
"reply_fields": [
|
||||
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
|
||||
{"tag": "ResultCode", "filters": ["*string:*cgrep.MaxUsage:0"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "4010", "blocker": true},
|
||||
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
@@ -7,16 +7,15 @@
|
||||
"id": "message",
|
||||
"filters": ["*string:*vars.*cmd:CCR", "*prefix:*req.Service-Context-Id:message",
|
||||
"*string:*req.CC-Request-Type:4"],
|
||||
"flags": ["*event", "*accounts"],
|
||||
"flags": ["*event", "*accounts", "*cdrs"],
|
||||
"request_fields":[
|
||||
{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"},
|
||||
{"tag": "OriginID", "field_id": "OriginID", "type": "*composed",
|
||||
"value": "~*req.Session-Id", "mandatory": true},
|
||||
{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "sms"},
|
||||
{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*prepaid"},
|
||||
{"tag": "Account", "field_id": "Account", "type": "*composed", "mandatory": true,
|
||||
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
|
||||
{"tag": "Subject", "field_id": "Subject", "type": "*composed", "mandatory": true,
|
||||
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
|
||||
{"tag": "Destination", "field_id": "Destination", "type": "*composed", "mandatory": true,
|
||||
"value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"},
|
||||
{"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed",
|
||||
@@ -27,10 +26,8 @@
|
||||
"value": "~*req.Requested-Service-Unit.CC-Time", "mandatory": true},
|
||||
],
|
||||
"reply_fields":[
|
||||
{"tag": "ResultCode", "filters": ["*string.*cgrep.Error:ACCOUNT_NOT_FOUND"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "break": true},
|
||||
{"tag": "ResultCode", "filters": ["*string.*cgrep.Error:USER_NOT_FOUND"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "break": true},
|
||||
{"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"],
|
||||
"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
@@ -3,4 +3,5 @@ DR_1001_20CNT,DST_1001,RT_20CNT,*up,4,0,
|
||||
DR_1002_20CNT,DST_1002,RT_20CNT,*up,4,0,
|
||||
DR_1003_MAXCOST_DISC,DST_1003,RT_1CNT_PER_SEC,*up,4,0.12,*disconnect
|
||||
DR_1001_10CNT,DST_1001,RT_10CNT,*up,4,0,
|
||||
DR_SMS,*any,RT_SMS,*up,4,0,
|
||||
|
||||
|
||||
|
@@ -7,3 +7,4 @@ RT_40CNT,0.8,0.4,60s,30s,0s
|
||||
RT_40CNT,0,0.2,60s,10s,60s
|
||||
RT_1CNT,0,0.01,60s,60s,0s
|
||||
RT_1CNT_PER_SEC,0,0.01,1s,1s,0s
|
||||
RT_SMS,0,0.01,1,1,0
|
||||
|
||||
|
@@ -3,4 +3,5 @@ RP_1001,DR_1002_20CNT,*any,10
|
||||
RP_1001,DR_1003_MAXCOST_DISC,*any,10
|
||||
RP_1002,DR_1001_20CNT,*any,10
|
||||
RP_1002_LOW,DR_1001_10CNT,*any,10
|
||||
RP_1003,DR_1001_10CNT,*any,10
|
||||
RP_1003,DR_1001_10CNT,*any,10
|
||||
RP_SMS,DR_SMS,*any,0
|
||||
|
@@ -2,3 +2,4 @@
|
||||
*out,cgrates.org,call,1001,2014-01-14T00:00:00Z,RP_1001,,
|
||||
*out,cgrates.org,call,1002,2014-01-14T00:00:00Z,RP_1002,,
|
||||
*out,cgrates.org,call,1003,2014-01-14T00:00:00Z,RP_1003,,
|
||||
*out,cgrates.org,sms,*any,2014-01-14T00:00:00Z,RP_SMS,,
|
||||
|
||||
|
Reference in New Issue
Block a user