Fixed disptacher_it_test structure

This commit is contained in:
porosnicuadrian
2021-07-30 16:52:14 +03:00
committed by Dan Christian Bogos
parent 32ac9b992a
commit 839afb9fc1

View File

@@ -32,23 +32,15 @@ import (
// for the moment we dispable Apier through dispatcher
// until we figured out a better sollution in case of gob server
/*
import (
"reflect"
"testing"
"time"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
var sTestsDspApier = []func(t *testing.T){
testDspApierSetAttributes,
testDspApierGetAttributes,
testDspApierUnkownAPiKey,
}
//Test start here
func TestDspApierITMySQL(t *testing.T) {
testDsp(t, sTestsDspApier, "TestDspApier", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers")
@@ -60,35 +52,37 @@ func TestDspApierITMongo(t *testing.T) {
//because we import dispatchers in APIerSv1 we will send information as map[string]interface{}
func testDspApierSetAttributes(t *testing.T) {
ev := &map[string]interface{}{
utils.Tenant: "cgrates.org",
"ID": "ATTR_Dispatcher",
"Contexts": []string{utils.MetaSessionS},
"FilterIDs": []string{"*string:~Account:1234"},
"ActivationInterval": &utils.ActivationInterval{
ActivationTimes: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
},
"Attributes": []*engine.Attribute{
{
Path: utils.MetaReq + utils.NestingSep + utils.Subject,
Value: config.RSRParsers{
&config.RSRParser{
Rules: "roam",
attrPrf := &engine.AttributeProfileWithAPIOpts{
AttributeProfile: &engine.AttributeProfile{
Tenant: "cgrates.org",
ID: "ATTR_Dispatcher",
Contexts: []string{utils.MetaSessionS},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
},
Attributes: []*engine.Attribute{
{
Path: utils.MetaReq + utils.NestingSep + utils.Subject,
Value: config.RSRParsers{
&config.RSRParser{
Rules: "roam",
},
},
},
},
},
"Weight": 10,
utils.APIKey: utils.StringPointer("apier12345"),
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "apier12345",
},
}
var result string
if err := dispEngine.RPC.Call(utils.APIerSv1SetAttributeProfile, ev, &result); err != nil {
if err := dispEngine.RPC.Call(utils.APIerSv1SetAttributeProfile, attrPrf, &result); err != nil {
t.Error(err)
} else if result != utils.OK {
t.Error("Unexpected reply returned", result)
}
}
func testDspApierGetAttributes(t *testing.T) {
@@ -99,7 +93,7 @@ func testDspApierGetAttributes(t *testing.T) {
Contexts: []string{utils.MetaSessionS},
FilterIDs: []string{"*string:~*req.Account:1234"},
ActivationInterval: &utils.ActivationInterval{
ActivationTimes: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
},
Attributes: []*engine.Attribute{
@@ -118,7 +112,9 @@ func testDspApierGetAttributes(t *testing.T) {
if err := dispEngine.RPC.Call(utils.APIerSv1GetAttributeProfile,
utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("apier12345")},
APIOpts: map[string]interface{}{
utils.OptsAPIKey:"apier12345",
},
}, &reply); err != nil {
t.Fatal(err)
}
@@ -134,12 +130,16 @@ func testDspApierUnkownAPiKey(t *testing.T) {
if err := dispEngine.RPC.Call(utils.APIerSv1GetAttributeProfile,
utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("RandomApiKey")},
APIOpts: map[string]interface{}{
utils.OptsAPIKey:"RandomApiKey",
},
}, &reply); err == nil || err.Error() != utils.ErrUnknownApiKey.Error() {
t.Fatal(err)
}
}
*/
*/
func TestDispatcherServiceDispatcherProfileForEventGetDispatchertWithoutAuthentification(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
cfg.DispatcherSCfg().IndexedSelects = false