mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added test for prefix filter
This commit is contained in:
committed by
Dan Christian Bogos
parent
81a4cdd3a1
commit
3ae4971967
@@ -65,6 +65,7 @@
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields": ["*req.CustomField"],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields": ["*req.CustomField"],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"prefix_indexed_fields": ["*req.CustomField"],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -25,4 +25,5 @@ cgrates.org,FLTR_SPP_QOS_2,*string,~*req.DistinctMatch,*qos_filtred2,2014-07-29T
|
||||
cgrates.org,FLTR_QOS_SP1_2,*gte,~*vars.Cost,0.1,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_QOS_SP2_2,*gte,~*vars.Cost,0.2,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_TEST,*string,~*req.Subject,TEST,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_SPP_LOAD_DIST,*string,~*req.DistinctMatch,LoadDistStrategy,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_SPP_LOAD_DIST,*string,~*req.DistinctMatch,LoadDistStrategy,2014-07-29T15:00:00Z
|
||||
cgrates.new,FLTR_1,*prefix,~*req.Destination,207;1207;+1207,
|
||||
|
||||
|
@@ -54,6 +54,7 @@ var (
|
||||
testV1FltrPopulateResources,
|
||||
testV1FltrAccounts,
|
||||
testV1FltrAccountsExistsDynamicaly,
|
||||
testV1FltrAttributesPrefix,
|
||||
testV1FltrInitDataDb,
|
||||
testV1FltrChargerSuffix,
|
||||
testV1FltrStopEngine,
|
||||
@@ -861,6 +862,69 @@ func testV1FltrChargerSuffix(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testV1FltrAttributesPrefix(t *testing.T) {
|
||||
chargerProfile := &v1.AttributeWithCache{
|
||||
AttributeProfile: &engine.AttributeProfile{
|
||||
Tenant: "cgrates.new",
|
||||
ID: "ATTR_1001",
|
||||
FilterIDs: []string{"*prefix:~*req.CustomField:2007;+2007", "*prefix:~*req.CustomField2:2007;+2007", "FLTR_1"},
|
||||
Contexts: []string{"prefix"},
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
FilterIDs: []string{},
|
||||
Path: utils.MetaReq + utils.NestingSep + "CustomField",
|
||||
Type: utils.META_CONSTANT,
|
||||
Value: config.NewRSRParsersMustCompile("2007", utils.INFIELD_SEP),
|
||||
},
|
||||
},
|
||||
Weight: 20.0,
|
||||
},
|
||||
}
|
||||
var result string
|
||||
if err := fltrRpc.Call(utils.APIerSv1SetAttributeProfile, chargerProfile, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
}
|
||||
|
||||
processedEv := &engine.AttrSProcessEventReply{
|
||||
AlteredFields: []string{"*req.CustomField"},
|
||||
MatchedProfiles: []string{"ATTR_1001"},
|
||||
CGREventWithOpts: &utils.CGREventWithOpts{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.new",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
"CustomField": "2007",
|
||||
"CustomField2": "+2007",
|
||||
utils.Destination: "+1207",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
cgrEv := &engine.AttrArgsProcessEvent{
|
||||
CGREventWithOpts: &utils.CGREventWithOpts{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.new",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
"CustomField": "+2007",
|
||||
"CustomField2": "+2007",
|
||||
utils.Destination: "+1207",
|
||||
},
|
||||
},
|
||||
},
|
||||
Context: utils.StringPointer("prefix"),
|
||||
}
|
||||
var result2 *engine.AttrSProcessEventReply
|
||||
if err := fltrRpc.Call(utils.AttributeSv1ProcessEvent, cgrEv, &result2); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(result2, processedEv) {
|
||||
t.Errorf("Expecting : %s, \n received: %s", utils.ToJSON(processedEv), utils.ToJSON(result2))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func testV1FltrStopEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(accDelay); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user