Updated all filters after the latest changes

This commit is contained in:
Trial97
2019-03-06 16:52:43 +02:00
committed by Dan Christian Bogos
parent 4aadf61f14
commit 7433fad5b9
9 changed files with 34 additions and 74 deletions

View File

@@ -211,7 +211,7 @@ func testAttributeSGetAttributeForEventNotFound(t *testing.T) {
eAttrPrf2 := &engine.AttributeProfile{
Tenant: ev.Tenant,
ID: "ATTR_3",
FilterIDs: []string{"*string:Account:dan"},
FilterIDs: []string{"*string:~Account:dan"},
Contexts: []string{utils.MetaSessionS},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 1, 14, 0, 0, 0, 0, time.UTC)},
@@ -413,7 +413,7 @@ func testAttributeSProcessEventWithNoneSubstitute(t *testing.T) {
},
Attributes: []*engine.Attribute{
{
FilterIDs: []string{"*string:Account:1008"},
FilterIDs: []string{"*string:~Account:1008"},
FieldName: utils.Account,
Substitute: config.NewRSRParsersMustCompile("1001", true, utils.INFIELD_SEP),
},
@@ -478,7 +478,7 @@ func testAttributeSProcessEventWithNoneSubstitute2(t *testing.T) {
},
Attributes: []*engine.Attribute{
{
FilterIDs: []string{"*string:Account:1008"},
FilterIDs: []string{"*string:~Account:1008"},
FieldName: utils.Account,
Substitute: config.NewRSRParsersMustCompile("1001", true, utils.INFIELD_SEP),
},
@@ -554,12 +554,12 @@ func testAttributeSProcessEventWithNoneSubstitute3(t *testing.T) {
},
Attributes: []*engine.Attribute{
{
FilterIDs: []string{"*string:Account:1008"},
FilterIDs: []string{"*string:~Account:1008"},
FieldName: utils.Account,
Substitute: config.NewRSRParsersMustCompile("1001", true, utils.INFIELD_SEP),
},
{
FilterIDs: []string{"*string:Subject:1008"},
FilterIDs: []string{"*string:~Subject:1008"},
FieldName: utils.Subject,
Substitute: config.NewRSRParsersMustCompile(utils.META_NONE, true, utils.INFIELD_SEP),
},

View File

@@ -247,10 +247,6 @@ func testPrecacheGetCacheStatsBeforeLoad(t *testing.T) {
Items: 0,
Groups: 0,
},
"rpc_responses": {
Items: 0,
Groups: 0,
},
}
if err := precacheRPC.Call(utils.CacheSv1GetCacheStats, cacheIDs, &reply); err != nil {
t.Error(err.Error())
@@ -415,10 +411,6 @@ func testPrecacheGetCacheStatsAfterRestart(t *testing.T) {
Items: 0,
Groups: 0,
},
"rpc_responses": {
Items: 0,
Groups: 0,
},
}
if err := precacheRPC.Call(utils.CacheSv1GetCacheStats, cacheIDs, &reply); err != nil {
t.Error(err.Error())

View File

@@ -1,12 +1,11 @@
#Tenant,ID,Contexts,FilterIDs,ActivationInterval,FieldName,Initial,Substitute,Append,Blocker,Weight
cgrates.org,ATTR_1001_SIMPLEAUTH,simpleauth,*string:~Account:1001,,Password,*any,CGRateS.org,true,false,20
cgrates.org,ATTR_API_ATTR_FAKE_AUTH,*auth,*string:~APIKey:12345,,APIMethods,*any,,true,false,20
cgrates.org,ATTR_API_ATTR_AUTH,*auth,*string:~APIKey:attr12345,,APIMethods,*any,AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent,true,false,20
cgrates.org,ATTR_API_CHRG_AUTH,*auth,*string:~APIKey:chrg12345,,APIMethods,*any,ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent,true,false,20
cgrates.org,ATTR_API_THR_AUTH,*auth,*string:~APIKey:thr12345,,APIMethods,*any,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs,true,false,20
cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~APIKey:sup12345,,APIMethods,*any,SupplierSv1.Ping&SupplierSv1.GetSuppliers,true,false,20
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:~APIKey:stat12345,,APIMethods,*any,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,true,false,20
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~APIKey:res12345,,APIMethods,*any,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,true,false,20
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:~APIKey:ses12345,,APIMethods,*any,SessionSv1.Ping&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessEvent&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.SetPassiveSession&SessionSv1.ReplicateSessions,true,false,20
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~APIKey:rsp12345,,APIMethods,*any,Responder.Status&Responder.GetTimeout&Responder.Shutdown,true,false,20
#Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,FieldName,Substitute,Blocker,Weight
cgrates.org,ATTR_1001_SIMPLEAUTH,simpleauth,*string:~Account:1001,,,Password,CGRateS.org,false,20
cgrates.org,ATTR_API_ATTR_FAKE_AUTH,*auth,*string:~APIKey:12345,,,APIMethods,,false,20
cgrates.org,ATTR_API_ATTR_AUTH,*auth,*string:~APIKey:attr12345,,,APIMethods,AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent,false,20
cgrates.org,ATTR_API_CHRG_AUTH,*auth,*string:~APIKey:chrg12345,,,APIMethods,ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent,false,20
cgrates.org,ATTR_API_THR_AUTH,*auth,*string:~APIKey:thr12345,,,APIMethods,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs,false,20
cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~APIKey:sup12345,,,APIMethods,SupplierSv1.Ping&SupplierSv1.GetSuppliers,false,20
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:~APIKey:stat12345,,,APIMethods,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,false,20
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~APIKey:res12345,,,APIMethods,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,false,20
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:~APIKey:ses12345,,,APIMethods,SessionSv1.Ping&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessEvent&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.SetPassiveSession&SessionSv1.ReplicateSessions,false,20
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~APIKey:rsp12345,,,APIMethods,Responder.Status&Responder.GetTimeout&Responder.Shutdown,false,20
1 #Tenant ID Contexts FilterIDs ActivationInterval AttributeFilterIDs Initial FieldName Substitute Append Blocker Weight
2 cgrates.org ATTR_1001_SIMPLEAUTH simpleauth *string:~Account:1001 *any Password CGRateS.org true false 20
3 cgrates.org ATTR_API_ATTR_FAKE_AUTH *auth *string:~APIKey:12345 *any APIMethods true false 20
4 cgrates.org ATTR_API_ATTR_AUTH *auth *string:~APIKey:attr12345 *any APIMethods AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent true false 20
5 cgrates.org ATTR_API_CHRG_AUTH *auth *string:~APIKey:chrg12345 *any APIMethods ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent true false 20
6 cgrates.org ATTR_API_THR_AUTH *auth *string:~APIKey:thr12345 *any APIMethods ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs true false 20
7 cgrates.org ATTR_API_SUP_AUTH *auth *string:~APIKey:sup12345 *any APIMethods SupplierSv1.Ping&SupplierSv1.GetSuppliers true false 20
8 cgrates.org ATTR_API_STAT_AUTH *auth *string:~APIKey:stat12345 *any APIMethods StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics true false 20
9 cgrates.org ATTR_API_RES_AUTH *auth *string:~APIKey:res12345 *any APIMethods ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources true false 20
10 cgrates.org ATTR_API_SES_AUTH *auth *string:~APIKey:ses12345 *any APIMethods SessionSv1.Ping&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessEvent&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.SetPassiveSession&SessionSv1.ReplicateSessions true false 20
11 cgrates.org ATTR_API_RSP_AUTH *auth *string:~APIKey:rsp12345 *any APIMethods Responder.Status&Responder.GetTimeout&Responder.Shutdown true false 20

View File

@@ -22,16 +22,13 @@ package dispatchers
import (
"fmt"
"reflect"
"testing"
"time"
"github.com/cgrates/cgrates/utils"
)
var sTestsDspRsp = []func(t *testing.T){
testDspResponderStatus,
testDspResponderGetTimeout,
testDspResponderShutdown,
testDspResponderRandom,
@@ -121,36 +118,6 @@ func testDspResponderRandom(t *testing.T) {
t.Errorf("Random strategy fail with 0.0009765625%% probability")
}
func testDspResponderGetTimeout(t *testing.T) {
var reply time.Duration
expected := time.Duration(0)
if err := allEngine.RCP.Call(utils.ResponderGetTimeout, 0, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expected, reply) {
t.Errorf("Expected: %s ,received: %s", expected, reply)
}
ev := TntWithApiKey{
TenantArg: utils.TenantArg{
Tenant: "cgrates.org",
},
DispatcherResource: DispatcherResource{
APIKey: "rsp12345",
},
}
if err := dispEngine.RCP.Call(utils.ResponderGetTimeout, &ev, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expected, reply) {
t.Errorf("Expected: %s ,received: %s", expected, reply)
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ResponderGetTimeout, &ev, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expected, reply) {
t.Errorf("Expected: %s ,received: %s", expected, reply)
}
allEngine.startEngine(t)
}
func testDspResponderShutdown(t *testing.T) {
var reply string
var statusReply map[string]interface{}

View File

@@ -1169,17 +1169,17 @@ func TestAttributeAttributeFilterIDs(t *testing.T) {
},
Attributes: []*Attribute{
{
FilterIDs: []string{"*string:PassField:Test"},
FilterIDs: []string{"*string:~PassField:Test"},
FieldName: "PassField",
Substitute: config.NewRSRParsersMustCompile("Pass", true, utils.INFIELD_SEP),
},
{
FilterIDs: []string{"*string:PassField:RandomValue"},
FilterIDs: []string{"*string:~PassField:RandomValue"},
FieldName: "NotPassField",
Substitute: config.NewRSRParsersMustCompile("NotPass", true, utils.INFIELD_SEP),
},
{
FilterIDs: []string{"*notexists:RandomField:"},
FilterIDs: []string{"*notexists:~RandomField:"},
FieldName: "RandomField",
Substitute: config.NewRSRParsersMustCompile("RandomValue", true, utils.INFIELD_SEP),
},

View File

@@ -146,7 +146,7 @@ func testRPCMethodsAddData(t *testing.T) {
tPrfl := &engine.ThresholdProfile{
Tenant: "cgrates.org",
ID: "THD_AccDisableAndLog",
FilterIDs: []string{"*string:Account:1001", "*string:DisableAction:DisableAction"},
FilterIDs: []string{"*string:~Account:1001", "*string:~DisableAction:DisableAction"},
MaxHits: -1,
MinSleep: time.Duration(1 * time.Second),
Weight: 30.0,
@@ -161,7 +161,7 @@ func testRPCMethodsAddData(t *testing.T) {
tPrfl2 := &engine.ThresholdProfile{
Tenant: "cgrates.org",
ID: "THD_AccEnableAndLog",
FilterIDs: []string{"*string:Account:1001", "*string:EnableAction:EnableAction"},
FilterIDs: []string{"*string:~Account:1001", "*string:~EnableAction:EnableAction"},
MaxHits: -1,
MinSleep: time.Duration(1 * time.Second),
Weight: 30.0,

View File

@@ -185,7 +185,7 @@ func testV1SplSAddNewSplPrf(t *testing.T) {
Tenant: "cgrates.org",
ID: "SPL_ResourceTest",
Sorting: utils.MetaReas,
FilterIDs: []string{"*string:CustomField:ResourceTest"},
FilterIDs: []string{"*string:~CustomField:ResourceTest"},
Suppliers: []*engine.Supplier{
//supplier1 will have ResourceUsage = 11
{
@@ -230,7 +230,7 @@ func testV1SplSAddNewResPrf(t *testing.T) {
rPrf := &engine.ResourceProfile{
Tenant: "cgrates.org",
ID: "ResourceSupplier1",
FilterIDs: []string{"*string:Supplier:supplier1", "*string:ResID:ResourceSupplier1"},
FilterIDs: []string{"*string:~Supplier:supplier1", "*string:~ResID:ResourceSupplier1"},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
@@ -251,7 +251,7 @@ func testV1SplSAddNewResPrf(t *testing.T) {
rPrf2 := &engine.ResourceProfile{
Tenant: "cgrates.org",
ID: "Resource2Supplier1",
FilterIDs: []string{"*string:Supplier:supplier1", "*string:ResID:Resource2Supplier1"},
FilterIDs: []string{"*string:~Supplier:supplier1", "*string:~ResID:Resource2Supplier1"},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
@@ -272,7 +272,7 @@ func testV1SplSAddNewResPrf(t *testing.T) {
rPrf3 := &engine.ResourceProfile{
Tenant: "cgrates.org",
ID: "ResourceSupplier2",
FilterIDs: []string{"*string:Supplier:supplier2", "*string:ResID:ResourceSupplier2"},
FilterIDs: []string{"*string:~Supplier:supplier2", "*string:~ResID:ResourceSupplier2"},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
@@ -293,7 +293,7 @@ func testV1SplSAddNewResPrf(t *testing.T) {
rPrf4 := &engine.ResourceProfile{
Tenant: "cgrates.org",
ID: "ResourceSupplier3",
FilterIDs: []string{"*string:Supplier:supplier3", "*string:ResID:ResourceSupplier3"},
FilterIDs: []string{"*string:~Supplier:supplier3", "*string:~ResID:ResourceSupplier3"},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
ExpiryTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
@@ -448,7 +448,7 @@ func testV1SplSAddNewSplPrf2(t *testing.T) {
Tenant: "cgrates.org",
ID: "SPL_ResourceDescendent",
Sorting: utils.MetaReds,
FilterIDs: []string{"*string:CustomField:ResourceDescendent"},
FilterIDs: []string{"*string:~CustomField:ResourceDescendent"},
Suppliers: []*engine.Supplier{
//supplier1 will have ResourceUsage = 11
{

View File

@@ -290,6 +290,11 @@ func (m *Migrator) migrateAttributeProfileFiltersV1() (err error) {
for i, fl := range attrPrf.FilterIDs {
attrPrf.FilterIDs[i] = migrateInlineFilter(fl)
}
for i, attr := range attrPrf.Attributes {
for j, fl := range attr.FilterIDs {
attrPrf.Attributes[i].FilterIDs[j] = migrateInlineFilter(fl)
}
}
if err := m.dmOut.DataManager().SetAttributeProfile(attrPrf, true); err != nil {
return err
}

View File

@@ -151,7 +151,6 @@ func testFltrITMigrateAndMove(t *testing.T) {
},
}
expFilters.Compile()
attrProf := &engine.AttributeProfile{
Tenant: "cgrates.org",
ID: "ATTR_1",
@@ -160,10 +159,9 @@ func testFltrITMigrateAndMove(t *testing.T) {
ActivationInterval: nil,
Attributes: []*engine.Attribute{
{
FilterIDs: []string{"*string:Account:1001"},
FieldName: "Account",
Initial: "1001",
Substitute: config.NewRSRParsersMustCompile("1002", true, utils.INFIELD_SEP),
Append: true,
},
},
Weight: 10,
@@ -176,10 +174,9 @@ func testFltrITMigrateAndMove(t *testing.T) {
ActivationInterval: nil,
Attributes: []*engine.Attribute{
{
FilterIDs: []string{"*string:~Account:1001"},
FieldName: "Account",
Initial: "1001",
Substitute: config.NewRSRParsersMustCompile("1002", true, utils.INFIELD_SEP),
Append: true,
},
},
Weight: 10,