diff --git a/data/tariffplans/testit/ActionPlans.csv b/data/tariffplans/testit/ActionPlans.csv index 5358216bb..e893d0486 100644 --- a/data/tariffplans/testit/ActionPlans.csv +++ b/data/tariffplans/testit/ActionPlans.csv @@ -1,3 +1,4 @@ #Id,ActionsId,TimingId,Weight PACKAGE_1001,TOPUP_RST_MONETARY_10,*asap,10 +PACKAGE_1001,ACTION_TOPUP_RESET_SMS,*asap,10 PACKAGE_1002,TOPUP_RST_DATA_100,*asap,10 diff --git a/data/tariffplans/testit/Actions.csv b/data/tariffplans/testit/Actions.csv index 1bc50ce8f..5ea3c924a 100644 --- a/data/tariffplans/testit/Actions.csv +++ b/data/tariffplans/testit/Actions.csv @@ -2,3 +2,4 @@ TOPUP_RST_MONETARY_10,*topup_reset,,,,*monetary,,*any,,,*unlimited,,10,10,false,false,10 TOPUP_MONETARY_10,*topup,,,,*monetary,,*any,,,*unlimited,,10,10,false,false,10 TOPUP_RST_DATA_100,*topup_reset,,,,*data,,*any,,,*monthly,,4096,10,false,false,10 +ACTION_TOPUP_RESET_SMS,*topup_reset,,,,*sms,,*any,,,*unlimited,,500,10,false,false,10 \ No newline at end of file diff --git a/general_tests/authorize_event_sms_data_it_test.go b/general_tests/authorize_event_sms_data_it_test.go new file mode 100644 index 000000000..82fab9092 --- /dev/null +++ b/general_tests/authorize_event_sms_data_it_test.go @@ -0,0 +1,111 @@ +//go:build integration +// +build integration + +/* +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 general_tests + +import ( + "path" + "testing" + "time" + + "github.com/cgrates/birpc/context" + "github.com/cgrates/cgrates/sessions" + "github.com/cgrates/cgrates/utils" +) + +func TestSSv1AuthorizeEventSMS(t *testing.T) { + var cfgDir string + switch *dbType { + case utils.MetaInternal: + cfgDir = "sessions_internal" + case utils.MetaMySQL: + cfgDir = "sessions_mysql" + case utils.MetaMongo: + cfgDir = "sessions_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } + testEnv := TestEnvironment{ + Name: "TestSSv1AuthorizeEventSMS", + ConfigPath: path.Join(*dataDir, "conf", "samples", cfgDir), + TpPath: path.Join(*dataDir, "tariffplans", "testit"), + } + client, _, shutdown, err := testEnv.Setup(t, *waitRater) + if err != nil { + t.Fatal(err) + } + defer shutdown() + + t.Run("AuthorizeEventSMS", func(t *testing.T) { + args := &sessions.V1AuthorizeArgs{ + GetMaxUsage: true, + GetAttributes: true, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItAuthSMS", + Event: map[string]any{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaSMS, + utils.OriginID: "TestSSv1It1SMS", + utils.AccountField: "1001", + utils.Destination: "1002", + utils.SetupTime: time.Date(2023, time.November, 16, 16, 60, 0, 0, time.UTC), + utils.Usage: 20, + }, + }, + } + var rply sessions.V1AuthorizeReply + if err := client.Call(context.Background(), utils.SessionSv1AuthorizeEvent, args, &rply); err != nil { + t.Fatal(err) + } + if rply.MaxUsage == nil || *rply.MaxUsage != 20 { + t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage) + } + }) + + t.Run("AuthorizeEventData", func(t *testing.T) { + args := &sessions.V1AuthorizeArgs{ + GetMaxUsage: true, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItAuthData", + Event: map[string]any{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaData, + utils.OriginID: "TestSSv1It1Data", + utils.AccountField: "1002", + utils.Destination: "1001", + utils.SetupTime: time.Date(2023, time.November, 16, 16, 60, 0, 0, time.UTC), + utils.Usage: 1024, + }, + }, + } + var rply sessions.V1AuthorizeReply + if err := client.Call(context.Background(), utils.SessionSv1AuthorizeEvent, args, &rply); err != nil { + t.Fatal(err) + } + if rply.MaxUsage == nil || *rply.MaxUsage != 1024 { + t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage) + } + }) + +}