mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
792 lines
28 KiB
Go
792 lines
28 KiB
Go
/*
|
|
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
|
Copyright (C) ITsysCOM GmbH
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
*/
|
|
|
|
package dispatchers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/cgrates/birpc/context"
|
|
"github.com/cgrates/cgrates/config"
|
|
"github.com/cgrates/cgrates/sessions"
|
|
"github.com/cgrates/cgrates/utils"
|
|
)
|
|
|
|
func TestDspSessionSv1PingNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1Ping(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1PingErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1Ping(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1AuthorizeEventNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1AuthorizeArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1AuthorizeReply
|
|
result := dspSrv.SessionSv1AuthorizeEvent(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1AuthorizeEventErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1AuthorizeArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1AuthorizeReply
|
|
result := dspSrv.SessionSv1AuthorizeEvent(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1AuthorizeEventWithDigestNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1AuthorizeArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1AuthorizeReplyWithDigest
|
|
result := dspSrv.SessionSv1AuthorizeEventWithDigest(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1AuthorizeEventWithDigestErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1AuthorizeArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1AuthorizeReplyWithDigest
|
|
result := dspSrv.SessionSv1AuthorizeEventWithDigest(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1InitiateSessionNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1InitSessionArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1InitSessionReply
|
|
result := dspSrv.SessionSv1InitiateSession(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1InitiateSessionErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1InitSessionArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1InitSessionReply
|
|
result := dspSrv.SessionSv1InitiateSession(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1InitiateSessionWithDigestNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1InitSessionArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1InitReplyWithDigest
|
|
result := dspSrv.SessionSv1InitiateSessionWithDigest(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1InitiateSessionWithDigestErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1InitSessionArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1InitReplyWithDigest
|
|
result := dspSrv.SessionSv1InitiateSessionWithDigest(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1UpdateSessionNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1UpdateSessionArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1UpdateSessionReply
|
|
result := dspSrv.SessionSv1UpdateSession(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1UpdateSessionErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1UpdateSessionArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1UpdateSessionReply
|
|
result := dspSrv.SessionSv1UpdateSession(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1SyncSessionsNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.TenantWithAPIOpts{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1SyncSessions(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1SyncSessionsErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.TenantWithAPIOpts{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1SyncSessions(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1TerminateSessionNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1TerminateSessionArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1TerminateSession(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1TerminateSessionErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1TerminateSessionArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1TerminateSession(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ProcessCDRNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1ProcessCDR(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ProcessCDRErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1ProcessCDR(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ProcessMessageNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1ProcessMessageArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1ProcessMessageReply
|
|
result := dspSrv.SessionSv1ProcessMessage(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ProcessMessageErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1ProcessMessageArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1ProcessMessageReply
|
|
result := dspSrv.SessionSv1ProcessMessage(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ProcessEventNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1ProcessEventArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1ProcessEventReply
|
|
result := dspSrv.SessionSv1ProcessEvent(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ProcessEventErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1ProcessEventArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1ProcessEventReply
|
|
result := dspSrv.SessionSv1ProcessEvent(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetCostNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1ProcessEventArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1GetCostReply
|
|
result := dspSrv.SessionSv1GetCost(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetCostErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1ProcessEventArgs{
|
|
CGREvent: &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *sessions.V1GetCostReply
|
|
result := dspSrv.SessionSv1GetCost(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetActiveSessionsNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *[]*sessions.ExternalSession
|
|
result := dspSrv.SessionSv1GetActiveSessions(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetActiveSessionsErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *[]*sessions.ExternalSession
|
|
result := dspSrv.SessionSv1GetActiveSessions(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetActiveSessionsCountNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *int
|
|
result := dspSrv.SessionSv1GetActiveSessionsCount(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetActiveSessionsCountErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *int
|
|
result := dspSrv.SessionSv1GetActiveSessionsCount(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ForceDisconnectNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
args := utils.SessionFilterWithEvent{
|
|
SessionFilter: &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1ForceDisconnect(context.Background(), args, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ForceDisconnectErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
args := utils.SessionFilterWithEvent{
|
|
SessionFilter: &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1ForceDisconnect(context.Background(), args, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetPassiveSessionsNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *[]*sessions.ExternalSession
|
|
result := dspSrv.SessionSv1GetPassiveSessions(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetPassiveSessionsErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *[]*sessions.ExternalSession
|
|
result := dspSrv.SessionSv1GetPassiveSessions(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ReplicateSessionsNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := ArgsReplicateSessionsWithAPIOpts{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1ReplicateSessions(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ReplicateSessionsErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := ArgsReplicateSessionsWithAPIOpts{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1ReplicateSessions(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetPassiveSessionsCountNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *int
|
|
result := dspSrv.SessionSv1GetPassiveSessionsCount(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1GetPassiveSessionsCountErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *int
|
|
result := dspSrv.SessionSv1GetPassiveSessionsCount(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1SetPassiveSessionNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.Session{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1SetPassiveSession(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1SetPassiveSessionErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.Session{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1SetPassiveSession(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ActivateSessionsNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1ActivateSessions(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1ActivateSessionsErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1ActivateSessions(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1DeactivateSessionsNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1DeactivateSessions(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1DeactivateSessionsErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &utils.SessionIDsWithArgsDispatcher{
|
|
Tenant: "tenant",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1DeactivateSessions(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1STIRAuthenticateNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1STIRAuthenticateArgs{}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1STIRAuthenticate(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1STIRAuthenticateErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1STIRAuthenticateArgs{}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1STIRAuthenticate(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1STIRIdentityNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
CGREvent := &sessions.V1STIRIdentityArgs{}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1STIRIdentity(context.Background(), CGREvent, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1STIRIdentityErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
CGREvent := &sessions.V1STIRIdentityArgs{}
|
|
var reply *string
|
|
result := dspSrv.SessionSv1STIRIdentity(context.Background(), CGREvent, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1AlterSessionsNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
args := utils.SessionFilterWithEvent{
|
|
SessionFilter: &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *string
|
|
err := dspSrv.SessionSv1AlterSessions(context.Background(), args, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if err == nil || err.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
|
}
|
|
}
|
|
|
|
func TestDspSessionSv1AlterSessionsErrorNil(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
|
args := utils.SessionFilterWithEvent{
|
|
SessionFilter: &utils.SessionFilter{
|
|
Tenant: "tenant",
|
|
},
|
|
}
|
|
var reply *string
|
|
err := dspSrv.SessionSv1AlterSessions(context.Background(), args, reply)
|
|
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
|
if err == nil || err.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
|
|
}
|
|
}
|
|
|
|
func TestTrendSv1PingNilArgs(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
args := &utils.CGREvent{
|
|
Tenant: "",
|
|
}
|
|
var reply *string
|
|
result := dspSrv.TrendSv1Ping(context.Background(), args, reply)
|
|
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
if result == nil || result.Error() != expected {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
|
}
|
|
}
|
|
|
|
func TestTrendSv1PingErrorAuthorization(t *testing.T) {
|
|
cgrCfg := config.NewDefaultCGRConfig()
|
|
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
|
args := &utils.CGREvent{
|
|
Tenant: "tenant",
|
|
APIOpts: map[string]interface{}{
|
|
utils.OptsAPIKey: "invalid_api_key",
|
|
},
|
|
}
|
|
var reply *string
|
|
expectedError := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
|
result := dspSrv.TrendSv1Ping(context.Background(), args, reply)
|
|
if result == nil || result.Error() != expectedError {
|
|
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expectedError, result)
|
|
}
|
|
}
|