diff --git a/dispatchers/guardian_test.go b/dispatchers/guardian_test.go
new file mode 100644
index 000000000..13652f716
--- /dev/null
+++ b/dispatchers/guardian_test.go
@@ -0,0 +1,124 @@
+/*
+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 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package dispatchers
+
+import (
+ "testing"
+
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/utils"
+)
+
+func TestDspRateSv1CostForEventCase(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ CGREvent := &utils.CGREvent{
+ Tenant: "tenant",
+ }
+ var reply *string
+ result := dspSrv.GuardianSv1Ping(CGREvent, reply)
+ expected := "DISPATCHER_ERROR:NOT_FOUND"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspGuardianSv1PingNil(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ var reply *string
+ result := dspSrv.GuardianSv1Ping(nil, reply)
+ expected := "DISPATCHER_ERROR:NOT_FOUND"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspGuardianSv1PingErrorNil(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.GuardianSv1Ping(CGREvent, reply)
+ expected := "MANDATORY_IE_MISSING: [ApiKey]"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspGuardianSv1RemoteLockCase(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ CGREvent := AttrRemoteLockWithAPIOpts{
+ Tenant: "tenant",
+ }
+ var reply *string
+ result := dspSrv.GuardianSv1RemoteLock(CGREvent, reply)
+ expected := "DISPATCHER_ERROR:NOT_FOUND"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspGuardianSv1RemoteLockErrorNil(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
+ CGREvent := AttrRemoteLockWithAPIOpts{
+ Tenant: "tenant",
+ }
+ var reply *string
+ result := dspSrv.GuardianSv1RemoteLock(CGREvent, reply)
+ expected := "MANDATORY_IE_MISSING: [ApiKey]"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspGuardianSv1RemoteUnlockCase(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ CGREvent := AttrRemoteUnlockWithAPIOpts{
+ Tenant: "tenant",
+ }
+ var reply *[]string
+ result := dspSrv.GuardianSv1RemoteUnlock(CGREvent, reply)
+ expected := "DISPATCHER_ERROR:NOT_FOUND"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspGuardianSv1RemoteUnlockErrorNil(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
+ CGREvent := AttrRemoteUnlockWithAPIOpts{
+ Tenant: "tenant",
+ }
+ var reply *[]string
+ result := dspSrv.GuardianSv1RemoteUnlock(CGREvent, reply)
+ expected := "MANDATORY_IE_MISSING: [ApiKey]"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
diff --git a/dispatchers/rates.go b/dispatchers/rates.go
index fedb79834..641b3d420 100644
--- a/dispatchers/rates.go
+++ b/dispatchers/rates.go
@@ -38,7 +38,9 @@ func (dS *DispatcherService) RateSv1Ping(args *utils.CGREvent, rpl *string) (err
func (dS *DispatcherService) RateSv1CostForEvent(args *utils.ArgsCostForEvent, rpCost *utils.RateProfileCost) (err error) {
if args == nil {
- args = new(utils.ArgsCostForEvent)
+ args = &utils.ArgsCostForEvent{
+ CGREvent: &utils.CGREvent{},
+ }
}
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
diff --git a/dispatchers/rates_test.go b/dispatchers/rates_test.go
index 534302ea2..91c7c353c 100644
--- a/dispatchers/rates_test.go
+++ b/dispatchers/rates_test.go
@@ -1 +1,110 @@
+/*
+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 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
package dispatchers
+
+import (
+ "testing"
+
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/utils"
+)
+
+func TestDspRateSv1PingErrorCase2(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ CGREvent := &utils.CGREvent{
+ Tenant: "tenant",
+ }
+ var reply *string
+ result := dspSrv.RateSv1Ping(CGREvent, reply)
+ expected := "DISPATCHER_ERROR:NOT_FOUND"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspRateSv1PingErrorNil(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.RateSv1Ping(CGREvent, reply)
+ expected := "MANDATORY_IE_MISSING: [ApiKey]"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspRateSv1CostForEventCaseNil(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ var reply *string
+ result := dspSrv.RateSv1Ping(nil, reply)
+ expected := "DISPATCHER_ERROR:NOT_FOUND"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspRateSv1CostForEventCase2(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ CGREvent := &utils.ArgsCostForEvent{
+ CGREvent: &utils.CGREvent{
+ Tenant: "tenant",
+ },
+ }
+ var reply *utils.RateProfileCost
+ result := dspSrv.RateSv1CostForEvent(CGREvent, reply)
+ expected := "DISPATCHER_ERROR:NOT_FOUND"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspRateSv1PingNil(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ var reply *utils.RateProfileCost
+ result := dspSrv.RateSv1CostForEvent(nil, reply)
+ expected := "DISPATCHER_ERROR:NOT_FOUND"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}
+
+func TestDspRateSv1CostForEventErrorNil(t *testing.T) {
+ cgrCfg := config.NewDefaultCGRConfig()
+ dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
+ cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
+ CGREvent := &utils.ArgsCostForEvent{
+ CGREvent: &utils.CGREvent{
+ Tenant: "tenant",
+ },
+ }
+ var reply *utils.RateProfileCost
+ result := dspSrv.RateSv1CostForEvent(CGREvent, reply)
+ expected := "MANDATORY_IE_MISSING: [ApiKey]"
+ if result == nil || result.Error() != expected {
+ t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
+ }
+}