From be393fd639fc3ef2467718cfade41f83c5a20ac7 Mon Sep 17 00:00:00 2001 From: adragusin Date: Fri, 17 Jan 2020 17:55:00 +0200 Subject: [PATCH] Updated IT tests --- agents/diam_it_test.go | 16 -- agents/dnsagent_it_test.go | 49 +++-- agents/httpagent_it_test.go | 107 ++++++----- agents/lib_test.go | 47 +++++ cmd/cgr-engine/cgr-engine.go | 2 +- .../attributes.json | 0 .../samples/dnsagent_internal/cgrates.json | 76 ++++++++ .../dryrun.json | 0 .../suppliers.json | 0 .../samples/dnsagent_mongo/attributes.json | 31 ++++ data/conf/samples/dnsagent_mongo/cgrates.json | 81 +++++++++ data/conf/samples/dnsagent_mongo/dryrun.json | 24 +++ .../samples/dnsagent_mongo/suppliers.json | 66 +++++++ .../samples/dnsagent_mysql/attributes.json | 31 ++++ .../{dnsagent => dnsagent_mysql}/cgrates.json | 0 data/conf/samples/dnsagent_mysql/dryrun.json | 24 +++ .../samples/dnsagent_mysql/suppliers.json | 66 +++++++ .../samples/httpagent_internal/cgrates.json | 64 +++++++ .../httpagent.json | 0 .../httpagent_internal_gob/cgrates.json | 71 ++++++++ .../httpagent.json | 0 .../conf/samples/httpagent_mongo/cgrates.json | 67 +++++++ .../samples/httpagent_mongo/httpagent.json | 168 +++++++++++++++++ .../samples/httpagent_mongo_gob/cgrates.json | 73 ++++++++ .../httpagent_mongo_gob/httpagent.json | 168 +++++++++++++++++ .../cgrates.json | 0 .../samples/httpagent_mysql/httpagent.json | 168 +++++++++++++++++ .../cgrates.json | 0 .../httpagent_mysql_gob/httpagent.json | 168 +++++++++++++++++ .../httpagenttls_internal/cgrates.json | 75 ++++++++ .../httpagent.json | 0 .../httpagenttls_internal_gob/cgrates.json | 84 +++++++++ .../httpagent.json | 0 .../samples/httpagenttls_mongo/cgrates.json | 77 ++++++++ .../samples/httpagenttls_mongo/httpagent.json | 169 ++++++++++++++++++ .../httpagenttls_mongo_gob/cgrates.json | 85 +++++++++ .../httpagenttls_mongo_gob/httpagent.json | 169 ++++++++++++++++++ .../cgrates.json | 0 .../samples/httpagenttls_mysql/httpagent.json | 169 ++++++++++++++++++ .../cgrates.json | 0 .../httpagenttls_mysql_gob/httpagent.json | 169 ++++++++++++++++++ integration_test.sh | 17 +- loaders/lib_test.go | 47 +++++ loaders/loader_it_test.go | 70 ++++---- 44 files changed, 2577 insertions(+), 121 deletions(-) create mode 100644 agents/lib_test.go rename data/conf/samples/{dnsagent => dnsagent_internal}/attributes.json (100%) create mode 100644 data/conf/samples/dnsagent_internal/cgrates.json rename data/conf/samples/{dnsagent => dnsagent_internal}/dryrun.json (100%) rename data/conf/samples/{dnsagent => dnsagent_internal}/suppliers.json (100%) create mode 100644 data/conf/samples/dnsagent_mongo/attributes.json create mode 100644 data/conf/samples/dnsagent_mongo/cgrates.json create mode 100644 data/conf/samples/dnsagent_mongo/dryrun.json create mode 100644 data/conf/samples/dnsagent_mongo/suppliers.json create mode 100644 data/conf/samples/dnsagent_mysql/attributes.json rename data/conf/samples/{dnsagent => dnsagent_mysql}/cgrates.json (100%) create mode 100644 data/conf/samples/dnsagent_mysql/dryrun.json create mode 100644 data/conf/samples/dnsagent_mysql/suppliers.json create mode 100644 data/conf/samples/httpagent_internal/cgrates.json rename data/conf/samples/{httpagent => httpagent_internal}/httpagent.json (100%) create mode 100644 data/conf/samples/httpagent_internal_gob/cgrates.json rename data/conf/samples/{httpagent_gob => httpagent_internal_gob}/httpagent.json (100%) create mode 100644 data/conf/samples/httpagent_mongo/cgrates.json create mode 100644 data/conf/samples/httpagent_mongo/httpagent.json create mode 100644 data/conf/samples/httpagent_mongo_gob/cgrates.json create mode 100644 data/conf/samples/httpagent_mongo_gob/httpagent.json rename data/conf/samples/{httpagent => httpagent_mysql}/cgrates.json (100%) create mode 100644 data/conf/samples/httpagent_mysql/httpagent.json rename data/conf/samples/{httpagent_gob => httpagent_mysql_gob}/cgrates.json (100%) create mode 100644 data/conf/samples/httpagent_mysql_gob/httpagent.json create mode 100755 data/conf/samples/httpagenttls_internal/cgrates.json rename data/conf/samples/{httpagenttls => httpagenttls_internal}/httpagent.json (100%) create mode 100755 data/conf/samples/httpagenttls_internal_gob/cgrates.json rename data/conf/samples/{httpagenttls_gob => httpagenttls_internal_gob}/httpagent.json (100%) create mode 100755 data/conf/samples/httpagenttls_mongo/cgrates.json create mode 100755 data/conf/samples/httpagenttls_mongo/httpagent.json create mode 100755 data/conf/samples/httpagenttls_mongo_gob/cgrates.json create mode 100755 data/conf/samples/httpagenttls_mongo_gob/httpagent.json rename data/conf/samples/{httpagenttls => httpagenttls_mysql}/cgrates.json (100%) create mode 100755 data/conf/samples/httpagenttls_mysql/httpagent.json rename data/conf/samples/{httpagenttls_gob => httpagenttls_mysql_gob}/cgrates.json (100%) create mode 100755 data/conf/samples/httpagenttls_mysql_gob/httpagent.json create mode 100644 loaders/lib_test.go diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index a0afedadf..3eff867f3 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -18,10 +18,8 @@ along with this program. If not, see package agents import ( - "errors" "flag" "net/rpc" - "net/rpc/jsonrpc" "os/exec" "path" "strings" @@ -38,11 +36,8 @@ import ( ) var ( - waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache") - dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here") interations = flag.Int("iterations", 1, "Number of iterations to do for dry run simulation") replyTimeout = flag.String("reply_timeout", "1s", "Maximum duration to wait for a reply") - encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be used for rpc comunication") daCfgPath, diamConfigDIR string daCfg *config.CGRConfig @@ -70,17 +65,6 @@ var ( } ) -func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) { - switch *encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return rpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} - // Test start here func TestDiamItTcp(t *testing.T) { engine.KillEngine(0) diff --git a/agents/dnsagent_it_test.go b/agents/dnsagent_it_test.go index ce0b40e6e..e8e3e39d7 100644 --- a/agents/dnsagent_it_test.go +++ b/agents/dnsagent_it_test.go @@ -34,36 +34,53 @@ import ( var ( dnsCfgPath string + dnsCfgDIR string dnsCfg *config.CGRConfig dnsRPC *rpc.Client dnsClnt *dns.Conn // so we can cache the connection + + sTestsDNS = []func(t *testing.T){ + testDNSitInitCfg, + testDNSitResetDB, + testDNSitStartEngine, + testDNSitApierRpcConn, + testDNSitTPFromFolder, + testDNSitClntConn, + testDNSitClntNAPTRDryRun, + testDNSitClntNAPTRAttributes, + testDNSitClntNAPTRSuppliers, + testDNSitStopEngine, + } ) -var sTestsDNS = []func(t *testing.T){ - testDNSitResetDB, - testDNSitStartEngine, - testDNSitApierRpcConn, - testDNSitTPFromFolder, - testDNSitClntConn, - testDNSitClntNAPTRDryRun, - testDNSitClntNAPTRAttributes, - testDNSitClntNAPTRSuppliers, - testDNSitStopEngine, +func TestDNSitSimple(t *testing.T) { + switch *dbType { + case utils.MetaInternal: + dnsCfgDIR = "dnsagent_internal" + case utils.MetaSQL: + dnsCfgDIR = "dnsagent_mysql" + case utils.MetaMongo: + dnsCfgDIR = "dnsagent_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } + for _, stest := range sTestsDNS { + t.Run(dnsCfgDIR, stest) + } } -func TestDNSitSimple(t *testing.T) { - dnsCfgPath = path.Join(*dataDir, "conf", "samples", "dnsagent") - // Init config first +// Init config +func testDNSitInitCfg(t *testing.T) { var err error + dnsCfgPath = path.Join(*dataDir, "conf", "samples", dnsCfgDIR) dnsCfg, err = config.NewCGRConfigFromPath(dnsCfgPath) if err != nil { t.Error(err) } dnsCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush() config.SetCgrConfig(dnsCfg) - for _, stest := range sTestsDNS { - t.Run("dnsAgent", stest) - } } // Remove data in both rating and accounting db diff --git a/agents/httpagent_it_test.go b/agents/httpagent_it_test.go index 02b7c1570..2d037696f 100644 --- a/agents/httpagent_it_test.go +++ b/agents/httpagent_it_test.go @@ -40,6 +40,7 @@ import ( var ( haCfgPath string + haCfgDIR string haCfg *config.CGRConfig haRPC *rpc.Client httpC *http.Client // so we can cache the connection @@ -48,6 +49,8 @@ var ( ) var sTestsHA = []func(t *testing.T){ + testHAitInitCfg, + testHAitHttp, testHAitResetDB, testHAitStartEngine, testHAitApierRpcConn, @@ -60,64 +63,82 @@ var sTestsHA = []func(t *testing.T){ testHAitStopEngine, } -func TestHAitSimple(t *testing.T) { - haCfgPath = path.Join(*dataDir, "conf", "samples", "httpagent") +func TestHAit(t *testing.T) { + var configDir, configDirTls string + switch *dbType { + case utils.MetaInternal: + configDir = "httpagent_internal" + configDirTls = "httpagenttls_internal" + case utils.MetaSQL: + configDir = "httpagent_mysql" + configDirTls = "httpagenttls_mysql" + case utils.MetaMongo: + configDir = "httpagent_mongo" + configDirTls = "httpagenttls_mongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") + } if *encoding == utils.MetaGOB { - haCfgPath = path.Join(*dataDir, "conf", "samples", "httpagent_gob") + configDir += "_gob" + configDirTls += "_gob" } - // Init config first - var err error - haCfg, err = config.NewCGRConfigFromPath(haCfgPath) - if err != nil { - t.Error(err) - } - haCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush() - config.SetCgrConfig(haCfg) - httpC = new(http.Client) + + //Run the tests without Tls + isTls = false + haCfgDIR = configDir for _, stest := range sTestsHA { - t.Run("httpagent", stest) + t.Run(haCfgDIR, stest) + } + //Run the tests with Tls + isTls = true + haCfgDIR = configDirTls + for _, stest := range sTestsHA { + t.Run(haCfgDIR, stest) } } -func TestHA2itWithTls(t *testing.T) { - haCfgPath = path.Join(*dataDir, "conf", "samples", "httpagenttls") - if *encoding == utils.MetaGOB { - haCfgPath = path.Join(*dataDir, "conf", "samples", "httpagenttls_gob") - } - // Init config first +// Init config first +func testHAitInitCfg(t *testing.T) { var err error + haCfgPath = path.Join(*dataDir, "conf", "samples", haCfgDIR) haCfg, err = config.NewCGRConfigFromPath(haCfgPath) if err != nil { t.Error(err) } haCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush() config.SetCgrConfig(haCfg) - //make http client with tls - cert, err := tls.LoadX509KeyPair(haCfg.TlsCfg().ClientCerificate, haCfg.TlsCfg().ClientKey) - if err != nil { - t.Error(err) - } +} - // Load CA cert - caCert, err := ioutil.ReadFile(haCfg.TlsCfg().CaCertificate) - if err != nil { - t.Error(err) - } - rootCAs, _ := x509.SystemCertPool() - if ok := rootCAs.AppendCertsFromPEM(caCert); !ok { - t.Error("Cannot append CA") - } +func testHAitHttp(t *testing.T) { + if isTls { + // With Tls + //make http client with tls + cert, err := tls.LoadX509KeyPair(haCfg.TlsCfg().ClientCerificate, haCfg.TlsCfg().ClientKey) + if err != nil { + t.Error(err) + } + // Load CA cert + caCert, err := ioutil.ReadFile(haCfg.TlsCfg().CaCertificate) + if err != nil { + t.Error(err) + } + rootCAs, _ := x509.SystemCertPool() + if ok := rootCAs.AppendCertsFromPEM(caCert); !ok { + t.Error("Cannot append CA") + } - // Setup HTTPS client - tlsConfig := &tls.Config{ - Certificates: []tls.Certificate{cert}, - RootCAs: rootCAs, - } - transport := &http.Transport{TLSClientConfig: tlsConfig} - httpC = &http.Client{Transport: transport} - isTls = true - for _, stest := range sTestsHA { - t.Run("httpagenttls", stest) + // Setup HTTPS client + tlsConfig := &tls.Config{ + Certificates: []tls.Certificate{cert}, + RootCAs: rootCAs, + } + transport := &http.Transport{TLSClientConfig: tlsConfig} + httpC = &http.Client{Transport: transport} + } else { + // Without Tls + httpC = new(http.Client) } } diff --git a/agents/lib_test.go b/agents/lib_test.go new file mode 100644 index 000000000..0f42e0ec2 --- /dev/null +++ b/agents/lib_test.go @@ -0,0 +1,47 @@ +/* +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 agents + +import ( + "errors" + "flag" + "net/rpc" + "net/rpc/jsonrpc" + + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/utils" +) + +var ( + waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache") + dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here") + encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be used for rpc comunication") + dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)") +) + +func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) { + switch *encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return rpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 7b8468797..9f86338ff 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -55,7 +55,7 @@ var ( singlecpu = cgrEngineFlags.Bool("singlecpu", false, "Run on single CPU core") syslogger = cgrEngineFlags.String("logger", "", "logger <*syslog|*stdout>") nodeID = cgrEngineFlags.String("node_id", "", "The node ID of the engine") - logLevel = cgrEngineFlags.Int("log_level", 6, "Log level (0-emergency to 7-debug)") + logLevel = cgrEngineFlags.Int("log_level", -1, "Log level (0-emergency to 7-debug)") cfg *config.CGRConfig ) diff --git a/data/conf/samples/dnsagent/attributes.json b/data/conf/samples/dnsagent_internal/attributes.json similarity index 100% rename from data/conf/samples/dnsagent/attributes.json rename to data/conf/samples/dnsagent_internal/attributes.json diff --git a/data/conf/samples/dnsagent_internal/cgrates.json b/data/conf/samples/dnsagent_internal/cgrates.json new file mode 100644 index 000000000..51fe78347 --- /dev/null +++ b/data/conf/samples/dnsagent_internal/cgrates.json @@ -0,0 +1,76 @@ +{ + +// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +// Copyright (C) ITsysCOM GmbH +// +// This file contains the default configuration hardcoded into CGRateS. +// This is what you get when you load CGRateS with an empty configuration file. + + +"general": { + "log_level": 7, // control the level of messages logged (0-emerg to 7-debug) +}, + +"data_db": { + "db_type": "*internal", +}, + + +"stor_db": { + "db_type": "*internal", +}, + + +"schedulers": { + "enabled": true, + "cdrs_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "rals_conns": ["*internal"], + "cdrs_conns": ["*internal"], + "chargers_conns": ["*internal"], + "suppliers_conns": ["*localhost"], +}, + + +"rals": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "rals_conns": ["*internal"], +}, + + +"chargers": { + "enabled": true, +}, + + +"attributes": { + "enabled": true, +}, + + +"suppliers": { + "enabled": true, +}, + + +"dns_agent": { + "enabled": true, + "listen": ":2053", + "sessions_conns": ["*localhost"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, +} \ No newline at end of file diff --git a/data/conf/samples/dnsagent/dryrun.json b/data/conf/samples/dnsagent_internal/dryrun.json similarity index 100% rename from data/conf/samples/dnsagent/dryrun.json rename to data/conf/samples/dnsagent_internal/dryrun.json diff --git a/data/conf/samples/dnsagent/suppliers.json b/data/conf/samples/dnsagent_internal/suppliers.json similarity index 100% rename from data/conf/samples/dnsagent/suppliers.json rename to data/conf/samples/dnsagent_internal/suppliers.json diff --git a/data/conf/samples/dnsagent_mongo/attributes.json b/data/conf/samples/dnsagent_mongo/attributes.json new file mode 100644 index 000000000..78f9449e1 --- /dev/null +++ b/data/conf/samples/dnsagent_mongo/attributes.json @@ -0,0 +1,31 @@ +{ + +"dns_agent": { + "request_processors": [ + { + "id": "NAPTRAttributes", + "filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.E164Address:4986517174964"], + "flags": ["*auth", "*attributes"], + "request_fields":[ + {"tag": "E164Address", "field_id": "E164Address", + "type": "*constant", "value": "4986517174964"}, + {"tag": "NAPTRAddress", "field_id": "NAPTRAddress", + "type": "*constant", "value": "*attributes"} + ], + "reply_fields":[ + {"tag": "NAPTROrder", "field_id": "Order", + "type": "*constant", "value": "100"}, + {"tag": "NAPTRPreference", "field_id": "Preference", + "type": "*constant", "value": "10"}, + {"tag": "NAPTRFlags", "field_id": "Flags", + "type": "*constant", "value": "U"}, + {"tag": "NAPTRService", "field_id": "Service", + "type": "*constant", "value": "E2U+SIP"}, + {"tag": "NAPTRRegex", "field_id": "Regexp", + "type": "*variable", "value": "~*cgrep.Attributes.NAPTRAddress"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/dnsagent_mongo/cgrates.json b/data/conf/samples/dnsagent_mongo/cgrates.json new file mode 100644 index 000000000..b531ed6c7 --- /dev/null +++ b/data/conf/samples/dnsagent_mongo/cgrates.json @@ -0,0 +1,81 @@ +{ + +// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +// Copyright (C) ITsysCOM GmbH +// +// This file contains the default configuration hardcoded into CGRateS. +// This is what you get when you load CGRateS with an empty configuration file. + + +"general": { + "log_level": 7, // control the level of messages logged (0-emerg to 7-debug) +}, + +"data_db": { + "db_type": "mongo", + "db_name": "10", + "db_port": 27017, +}, + + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + + + +"schedulers": { + "enabled": true, + "cdrs_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "rals_conns": ["*internal"], + "cdrs_conns": ["*internal"], + "chargers_conns": ["*internal"], + "suppliers_conns": ["*localhost"], +}, + + +"rals": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "rals_conns": ["*internal"], +}, + + +"chargers": { + "enabled": true, +}, + + +"attributes": { + "enabled": true, +}, + + +"suppliers": { + "enabled": true, +}, + + +"dns_agent": { + "enabled": true, + "listen": ":2053", + "sessions_conns": ["*localhost"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, +} \ No newline at end of file diff --git a/data/conf/samples/dnsagent_mongo/dryrun.json b/data/conf/samples/dnsagent_mongo/dryrun.json new file mode 100644 index 000000000..e485a7997 --- /dev/null +++ b/data/conf/samples/dnsagent_mongo/dryrun.json @@ -0,0 +1,24 @@ +{ + +"dns_agent": { + "request_processors": [ + { + "id": "DryRunNAPTR", + "filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.E164Address:4986517174963"], + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + ], + "reply_fields":[ + {"tag": "NAPTROrder", "field_id": "Order", "type": "*constant", "value": "100"}, + {"tag": "NAPTRPreference", "field_id": "Preference", "type": "*constant", "value": "10"}, + {"tag": "NAPTRFlags", "field_id": "Flags", "type": "*constant", "value": "U"}, + {"tag": "NAPTRService", "field_id": "Service", "type": "*constant", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*constant", "value": "!^(.*)$!sip:\\1@172.16.1.10.!"}, + {"tag": "NAPTRReplacement", "field_id": "Replacement", "type": "*constant", "value": "."}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/dnsagent_mongo/suppliers.json b/data/conf/samples/dnsagent_mongo/suppliers.json new file mode 100644 index 000000000..b531e99f1 --- /dev/null +++ b/data/conf/samples/dnsagent_mongo/suppliers.json @@ -0,0 +1,66 @@ +{ + +"dns_agent": { + "request_processors": [ + { + "id": "NAPTRSuppliersQuery", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965"], + "flags": ["*message", "*suppliers"], + "request_fields":[ + {"tag": "TOR", "field_id": "Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile + ], + "reply_fields":[ + {"tag": "DispatchReply", "type": "*none", + "blocker": true}, // enforces continue_on_success so we can check answer with filters + ], + "continue": true, + }, + { + "id": "NAPTRSuppliersOneSupplier", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965", + "*gte:~*cgrep.Suppliers.Count:1"], + "flags": ["*none"], // do not send request to CGRateS + "reply_fields":[ + {"tag": "NAPTROrder", "field_id": "Order", + "type": "*constant", "value": "100"}, + {"tag": "NAPTRPreference", "field_id": "Preference", + "type": "*constant", "value": "10"}, + {"tag": "NAPTRFlags", "field_id": "Flags", + "type": "*constant", "value": "U"}, + {"tag": "NAPTRService", "field_id": "Service", + "type": "*constant", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable", + "value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"}, + {"tag": "NAPTRReplacement", "field_id": "Replacement", + "type": "*constant", "value": "."}, + ], + "continue": true, + }, + { + "id": "NAPTRSuppliersTwoSuppliers", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965", + "*gte:~*cgrep.Suppliers.Count:2"], + "flags": ["*none"], + "reply_fields":[ + {"tag": "NAPTROrder", "type": "*constant", "new_branch": true, + "field_id": "Order", "value": "100"}, + {"tag": "NAPTRPreference", "field_id": "Preference", + "type": "*constant", "value": "10"}, + {"tag": "NAPTRFlags", "field_id": "Flags", + "type": "*constant", "value": "U"}, + {"tag": "NAPTRService", "field_id": "Service", + "type": "*constant", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable", + "value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"}, + {"tag": "NAPTRReplacement", "field_id": "Replacement", + "type": "*constant", "value": "."}, + ], + "continue": true, + }, + ], +}, + +} diff --git a/data/conf/samples/dnsagent_mysql/attributes.json b/data/conf/samples/dnsagent_mysql/attributes.json new file mode 100644 index 000000000..78f9449e1 --- /dev/null +++ b/data/conf/samples/dnsagent_mysql/attributes.json @@ -0,0 +1,31 @@ +{ + +"dns_agent": { + "request_processors": [ + { + "id": "NAPTRAttributes", + "filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.E164Address:4986517174964"], + "flags": ["*auth", "*attributes"], + "request_fields":[ + {"tag": "E164Address", "field_id": "E164Address", + "type": "*constant", "value": "4986517174964"}, + {"tag": "NAPTRAddress", "field_id": "NAPTRAddress", + "type": "*constant", "value": "*attributes"} + ], + "reply_fields":[ + {"tag": "NAPTROrder", "field_id": "Order", + "type": "*constant", "value": "100"}, + {"tag": "NAPTRPreference", "field_id": "Preference", + "type": "*constant", "value": "10"}, + {"tag": "NAPTRFlags", "field_id": "Flags", + "type": "*constant", "value": "U"}, + {"tag": "NAPTRService", "field_id": "Service", + "type": "*constant", "value": "E2U+SIP"}, + {"tag": "NAPTRRegex", "field_id": "Regexp", + "type": "*variable", "value": "~*cgrep.Attributes.NAPTRAddress"}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/dnsagent/cgrates.json b/data/conf/samples/dnsagent_mysql/cgrates.json similarity index 100% rename from data/conf/samples/dnsagent/cgrates.json rename to data/conf/samples/dnsagent_mysql/cgrates.json diff --git a/data/conf/samples/dnsagent_mysql/dryrun.json b/data/conf/samples/dnsagent_mysql/dryrun.json new file mode 100644 index 000000000..e485a7997 --- /dev/null +++ b/data/conf/samples/dnsagent_mysql/dryrun.json @@ -0,0 +1,24 @@ +{ + +"dns_agent": { + "request_processors": [ + { + "id": "DryRunNAPTR", + "filters": ["*string:~*vars.QueryType:NAPTR", "*string:~*vars.E164Address:4986517174963"], + "flags": ["*dryrun"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*sms"}, + ], + "reply_fields":[ + {"tag": "NAPTROrder", "field_id": "Order", "type": "*constant", "value": "100"}, + {"tag": "NAPTRPreference", "field_id": "Preference", "type": "*constant", "value": "10"}, + {"tag": "NAPTRFlags", "field_id": "Flags", "type": "*constant", "value": "U"}, + {"tag": "NAPTRService", "field_id": "Service", "type": "*constant", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*constant", "value": "!^(.*)$!sip:\\1@172.16.1.10.!"}, + {"tag": "NAPTRReplacement", "field_id": "Replacement", "type": "*constant", "value": "."}, + ], + }, + ], +}, + +} \ No newline at end of file diff --git a/data/conf/samples/dnsagent_mysql/suppliers.json b/data/conf/samples/dnsagent_mysql/suppliers.json new file mode 100644 index 000000000..b531e99f1 --- /dev/null +++ b/data/conf/samples/dnsagent_mysql/suppliers.json @@ -0,0 +1,66 @@ +{ + +"dns_agent": { + "request_processors": [ + { + "id": "NAPTRSuppliersQuery", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965"], + "flags": ["*message", "*suppliers"], + "request_fields":[ + {"tag": "TOR", "field_id": "Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile + ], + "reply_fields":[ + {"tag": "DispatchReply", "type": "*none", + "blocker": true}, // enforces continue_on_success so we can check answer with filters + ], + "continue": true, + }, + { + "id": "NAPTRSuppliersOneSupplier", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965", + "*gte:~*cgrep.Suppliers.Count:1"], + "flags": ["*none"], // do not send request to CGRateS + "reply_fields":[ + {"tag": "NAPTROrder", "field_id": "Order", + "type": "*constant", "value": "100"}, + {"tag": "NAPTRPreference", "field_id": "Preference", + "type": "*constant", "value": "10"}, + {"tag": "NAPTRFlags", "field_id": "Flags", + "type": "*constant", "value": "U"}, + {"tag": "NAPTRService", "field_id": "Service", + "type": "*constant", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable", + "value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"}, + {"tag": "NAPTRReplacement", "field_id": "Replacement", + "type": "*constant", "value": "."}, + ], + "continue": true, + }, + { + "id": "NAPTRSuppliersTwoSuppliers", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965", + "*gte:~*cgrep.Suppliers.Count:2"], + "flags": ["*none"], + "reply_fields":[ + {"tag": "NAPTROrder", "type": "*constant", "new_branch": true, + "field_id": "Order", "value": "100"}, + {"tag": "NAPTRPreference", "field_id": "Preference", + "type": "*constant", "value": "10"}, + {"tag": "NAPTRFlags", "field_id": "Flags", + "type": "*constant", "value": "U"}, + {"tag": "NAPTRService", "field_id": "Service", + "type": "*constant", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "field_id": "Regexp", "type": "*variable", + "value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"}, + {"tag": "NAPTRReplacement", "field_id": "Replacement", + "type": "*constant", "value": "."}, + ], + "continue": true, + }, + ], +}, + +} diff --git a/data/conf/samples/httpagent_internal/cgrates.json b/data/conf/samples/httpagent_internal/cgrates.json new file mode 100644 index 000000000..9ec91f4cd --- /dev/null +++ b/data/conf/samples/httpagent_internal/cgrates.json @@ -0,0 +1,64 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", +}, + +"stor_db": { + "db_type": "*internal", +}, + + +"rals": { + "enabled": true, + "max_increments":3000000, +}, + + +"schedulers": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": ["*internal"], + "rals_conns": ["*internal"], +}, + + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "chargers_conns": ["*internal"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/httpagent/httpagent.json b/data/conf/samples/httpagent_internal/httpagent.json similarity index 100% rename from data/conf/samples/httpagent/httpagent.json rename to data/conf/samples/httpagent_internal/httpagent.json diff --git a/data/conf/samples/httpagent_internal_gob/cgrates.json b/data/conf/samples/httpagent_internal_gob/cgrates.json new file mode 100644 index 000000000..1d6e1ec7b --- /dev/null +++ b/data/conf/samples/httpagent_internal_gob/cgrates.json @@ -0,0 +1,71 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", +}, + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}], + }, +}, + +"stor_db": { + "db_type": "*internal", +}, + + +"rals": { + "enabled": true, + "max_increments":3000000, +}, + + +"schedulers": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": ["*internal"], + "rals_conns": ["*internal"], +}, + + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["conn1"], + "cdrs_conns": ["conn1"], + "rals_conns": ["conn1"], + "chargers_conns": ["*internal"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/httpagent_gob/httpagent.json b/data/conf/samples/httpagent_internal_gob/httpagent.json similarity index 100% rename from data/conf/samples/httpagent_gob/httpagent.json rename to data/conf/samples/httpagent_internal_gob/httpagent.json diff --git a/data/conf/samples/httpagent_mongo/cgrates.json b/data/conf/samples/httpagent_mongo/cgrates.json new file mode 100644 index 000000000..bce58861d --- /dev/null +++ b/data/conf/samples/httpagent_mongo/cgrates.json @@ -0,0 +1,67 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", +}, + + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + + +"rals": { + "enabled": true, + "max_increments":3000000, +}, + + +"schedulers": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": ["*internal"], + "rals_conns": ["*internal"], +}, + + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "chargers_conns": ["*internal"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/httpagent_mongo/httpagent.json b/data/conf/samples/httpagent_mongo/httpagent.json new file mode 100644 index 000000000..48c2d4f3f --- /dev/null +++ b/data/conf/samples/httpagent_mongo/httpagent.json @@ -0,0 +1,168 @@ +{ + + +"http_agent": [ + { + "id": "conecto1", + "url": "/conecto", + "sessions_conns": ["*localhost"], + "request_payload": "*url", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed", + "value": "~*req.MCC;/", "mandatory": true}, + {"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed", + "value": "Val1"}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + "value": "0"}, + ], + }, + { + "id": "OutboundAUTH", + "filters": ["*string:~*req.request_type:OutboundAUTH"], + "tenant": "cgrates.org", + "flags": [ "*auth", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + "value": "*now", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "mtcall_cdr", + "filters": ["*string:~*req.request_type:MTCALL_CDR"], + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;s", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true}, + {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + "value": "1", "mandatory": true}, + ], + } + ], + }, + { + "id": "conecto_xml", + "url": "/conecto_xml", + "sessions_conns": ["*localhost"], + "request_payload": "*xml", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "cdr_from_xml", + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", + "value": "*data", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.complete-datasession-notification.customerid", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.complete-datasession-notification.username", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.complete-datasession-notification.userid", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true}, + ], + "reply_fields":[], + } + ], + }, + { + "id": "textplain", + "url": "/textplain", + "sessions_conns": ["*localhost"], + "request_payload": "*url", + "reply_payload": "*text_plain", + "request_processors": [ + { + "id": "TextPlainDryRun", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Variable1", "type": "*variable", + "value": "Hola1", "mandatory": true}, + {"tag": "Field2", "field_id": "Variable2", "type": "*variable", + "value": "Hola2", "mandatory": true}, + {"tag": "Field3", "field_id": "ComposedVar", "type": "*composed", + "value": "Test", "mandatory": true}, + {"tag": "Field4", "field_id": "ComposedVar", "type": "*composed", + "value": "Composed", "mandatory": true}, + {"tag": "Field5", "field_id": "Item1.1", "type": "*variable", + "value": "Val1", "mandatory": true}, + ], + "continue": true, + }, + { + "id": "TextPlainDryRun2", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[], + "reply_fields":[ + {"tag": "Field1", "field_id": "Item1.1", "type": "*variable", + "value": "Val2", "mandatory": true}, + ], + }, + ], + }, +], + + +} \ No newline at end of file diff --git a/data/conf/samples/httpagent_mongo_gob/cgrates.json b/data/conf/samples/httpagent_mongo_gob/cgrates.json new file mode 100644 index 000000000..b13361087 --- /dev/null +++ b/data/conf/samples/httpagent_mongo_gob/cgrates.json @@ -0,0 +1,73 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", +}, + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}], + }, +}, + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + + +"rals": { + "enabled": true, + "max_increments":3000000, +}, + + +"schedulers": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": ["*internal"], + "rals_conns": ["*internal"], +}, + + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + + +"sessions": { + "enabled": true, + "attributes_conns": ["conn1"], + "cdrs_conns": ["conn1"], + "rals_conns": ["conn1"], + "chargers_conns": ["*internal"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/httpagent_mongo_gob/httpagent.json b/data/conf/samples/httpagent_mongo_gob/httpagent.json new file mode 100644 index 000000000..708fa58d4 --- /dev/null +++ b/data/conf/samples/httpagent_mongo_gob/httpagent.json @@ -0,0 +1,168 @@ +{ + + +"http_agent": [ + { + "id": "conecto1", + "url": "/conecto", + "sessions_conns": ["conn1"], + "request_payload": "*url", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed", + "value": "~*req.MCC;/", "mandatory": true}, + {"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed", + "value": "Val1"}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + "value": "0"}, + ], + }, + { + "id": "OutboundAUTH", + "filters": ["*string:~*req.request_type:OutboundAUTH"], + "tenant": "cgrates.org", + "flags": [ "*auth", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + "value": "*now", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "mtcall_cdr", + "filters": ["*string:~*req.request_type:MTCALL_CDR"], + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;s", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true}, + {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + "value": "1", "mandatory": true}, + ], + } + ], + }, + { + "id": "conecto_xml", + "url": "/conecto_xml", + "sessions_conns": ["conn1"], + "request_payload": "*xml", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "cdr_from_xml", + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", + "value": "*data", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.complete-datasession-notification.customerid", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.complete-datasession-notification.username", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.complete-datasession-notification.userid", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true}, + ], + "reply_fields":[], + } + ], + }, + { + "id": "textplain", + "url": "/textplain", + "sessions_conns": ["conn1"], + "request_payload": "*url", + "reply_payload": "*text_plain", + "request_processors": [ + { + "id": "TextPlainDryRun", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Variable1", "type": "*variable", + "value": "Hola1", "mandatory": true}, + {"tag": "Field2", "field_id": "Variable2", "type": "*variable", + "value": "Hola2", "mandatory": true}, + {"tag": "Field3", "field_id": "ComposedVar", "type": "*composed", + "value": "Test", "mandatory": true}, + {"tag": "Field4", "field_id": "ComposedVar", "type": "*composed", + "value": "Composed", "mandatory": true}, + {"tag": "Field5", "field_id": "Item1.1", "type": "*variable", + "value": "Val1", "mandatory": true}, + ], + "continue": true, + }, + { + "id": "TextPlainDryRun2", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[], + "reply_fields":[ + {"tag": "Field1", "field_id": "Item1.1", "type": "*variable", + "value": "Val2", "mandatory": true}, + ], + }, + ], + }, +], + + +} \ No newline at end of file diff --git a/data/conf/samples/httpagent/cgrates.json b/data/conf/samples/httpagent_mysql/cgrates.json similarity index 100% rename from data/conf/samples/httpagent/cgrates.json rename to data/conf/samples/httpagent_mysql/cgrates.json diff --git a/data/conf/samples/httpagent_mysql/httpagent.json b/data/conf/samples/httpagent_mysql/httpagent.json new file mode 100644 index 000000000..48c2d4f3f --- /dev/null +++ b/data/conf/samples/httpagent_mysql/httpagent.json @@ -0,0 +1,168 @@ +{ + + +"http_agent": [ + { + "id": "conecto1", + "url": "/conecto", + "sessions_conns": ["*localhost"], + "request_payload": "*url", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed", + "value": "~*req.MCC;/", "mandatory": true}, + {"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed", + "value": "Val1"}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + "value": "0"}, + ], + }, + { + "id": "OutboundAUTH", + "filters": ["*string:~*req.request_type:OutboundAUTH"], + "tenant": "cgrates.org", + "flags": [ "*auth", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + "value": "*now", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "mtcall_cdr", + "filters": ["*string:~*req.request_type:MTCALL_CDR"], + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;s", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true}, + {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + "value": "1", "mandatory": true}, + ], + } + ], + }, + { + "id": "conecto_xml", + "url": "/conecto_xml", + "sessions_conns": ["*localhost"], + "request_payload": "*xml", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "cdr_from_xml", + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", + "value": "*data", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.complete-datasession-notification.customerid", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.complete-datasession-notification.username", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.complete-datasession-notification.userid", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true}, + ], + "reply_fields":[], + } + ], + }, + { + "id": "textplain", + "url": "/textplain", + "sessions_conns": ["*localhost"], + "request_payload": "*url", + "reply_payload": "*text_plain", + "request_processors": [ + { + "id": "TextPlainDryRun", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Variable1", "type": "*variable", + "value": "Hola1", "mandatory": true}, + {"tag": "Field2", "field_id": "Variable2", "type": "*variable", + "value": "Hola2", "mandatory": true}, + {"tag": "Field3", "field_id": "ComposedVar", "type": "*composed", + "value": "Test", "mandatory": true}, + {"tag": "Field4", "field_id": "ComposedVar", "type": "*composed", + "value": "Composed", "mandatory": true}, + {"tag": "Field5", "field_id": "Item1.1", "type": "*variable", + "value": "Val1", "mandatory": true}, + ], + "continue": true, + }, + { + "id": "TextPlainDryRun2", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[], + "reply_fields":[ + {"tag": "Field1", "field_id": "Item1.1", "type": "*variable", + "value": "Val2", "mandatory": true}, + ], + }, + ], + }, +], + + +} \ No newline at end of file diff --git a/data/conf/samples/httpagent_gob/cgrates.json b/data/conf/samples/httpagent_mysql_gob/cgrates.json similarity index 100% rename from data/conf/samples/httpagent_gob/cgrates.json rename to data/conf/samples/httpagent_mysql_gob/cgrates.json diff --git a/data/conf/samples/httpagent_mysql_gob/httpagent.json b/data/conf/samples/httpagent_mysql_gob/httpagent.json new file mode 100644 index 000000000..708fa58d4 --- /dev/null +++ b/data/conf/samples/httpagent_mysql_gob/httpagent.json @@ -0,0 +1,168 @@ +{ + + +"http_agent": [ + { + "id": "conecto1", + "url": "/conecto", + "sessions_conns": ["conn1"], + "request_payload": "*url", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed", + "value": "~*req.MCC;/", "mandatory": true}, + {"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed", + "value": "Val1"}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + "value": "0"}, + ], + }, + { + "id": "OutboundAUTH", + "filters": ["*string:~*req.request_type:OutboundAUTH"], + "tenant": "cgrates.org", + "flags": [ "*auth", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + "value": "*now", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "mtcall_cdr", + "filters": ["*string:~*req.request_type:MTCALL_CDR"], + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*variable", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*variable", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;s", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true}, + {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + "value": "1", "mandatory": true}, + ], + } + ], + }, + { + "id": "conecto_xml", + "url": "/conecto_xml", + "sessions_conns": ["conn1"], + "request_payload": "*xml", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "cdr_from_xml", + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", + "value": "*data", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.complete-datasession-notification.customerid", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.complete-datasession-notification.username", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.complete-datasession-notification.userid", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true}, + ], + "reply_fields":[], + } + ], + }, + { + "id": "textplain", + "url": "/textplain", + "sessions_conns": ["conn1"], + "request_payload": "*url", + "reply_payload": "*text_plain", + "request_processors": [ + { + "id": "TextPlainDryRun", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Variable1", "type": "*variable", + "value": "Hola1", "mandatory": true}, + {"tag": "Field2", "field_id": "Variable2", "type": "*variable", + "value": "Hola2", "mandatory": true}, + {"tag": "Field3", "field_id": "ComposedVar", "type": "*composed", + "value": "Test", "mandatory": true}, + {"tag": "Field4", "field_id": "ComposedVar", "type": "*composed", + "value": "Composed", "mandatory": true}, + {"tag": "Field5", "field_id": "Item1.1", "type": "*variable", + "value": "Val1", "mandatory": true}, + ], + "continue": true, + }, + { + "id": "TextPlainDryRun2", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[], + "reply_fields":[ + {"tag": "Field1", "field_id": "Item1.1", "type": "*variable", + "value": "Val2", "mandatory": true}, + ], + }, + ], + }, +], + + +} \ No newline at end of file diff --git a/data/conf/samples/httpagenttls_internal/cgrates.json b/data/conf/samples/httpagenttls_internal/cgrates.json new file mode 100755 index 000000000..466679457 --- /dev/null +++ b/data/conf/samples/httpagenttls_internal/cgrates.json @@ -0,0 +1,75 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", + "rpc_json_tls":":2022", + "rpc_gob_tls":":2023", + "http_tls": "localhost:2280", +}, + +"tls": { + "server_certificate" : "/usr/share/cgrates/tls/server.crt", // path to server certificate(must conatin server.crt + ca.crt) + "server_key":"/usr/share/cgrates/tls/server.key", // path to server key + "client_certificate" : "/usr/share/cgrates/tls/client.crt", // path to client certificate(must conatin client.crt + ca.crt) + "client_key":"/usr/share/cgrates/tls/client.key", // path to client key + "ca_certificate":"/usr/share/cgrates/tls/ca.crt", +}, + + +"stor_db": { + "db_type": "*internal", +}, + + +"rals": { + "enabled": true, + "max_increments":3000000, +}, + + +"schedulers": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": ["*internal"], + "rals_conns": ["*internal"], +}, + + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "chargers_conns": ["*internal"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/httpagenttls/httpagent.json b/data/conf/samples/httpagenttls_internal/httpagent.json similarity index 100% rename from data/conf/samples/httpagenttls/httpagent.json rename to data/conf/samples/httpagenttls_internal/httpagent.json diff --git a/data/conf/samples/httpagenttls_internal_gob/cgrates.json b/data/conf/samples/httpagenttls_internal_gob/cgrates.json new file mode 100755 index 000000000..acafbe97b --- /dev/null +++ b/data/conf/samples/httpagenttls_internal_gob/cgrates.json @@ -0,0 +1,84 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", + "rpc_json_tls":":2022", + "rpc_gob_tls":":2023", + "http_tls": "localhost:2280", +}, + + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}], + }, +}, + + +"tls": { + "server_certificate" : "/usr/share/cgrates/tls/server.crt", // path to server certificate(must conatin server.crt + ca.crt) + "server_key":"/usr/share/cgrates/tls/server.key", // path to server key + "client_certificate" : "/usr/share/cgrates/tls/client.crt", // path to client certificate(must conatin client.crt + ca.crt) + "client_key":"/usr/share/cgrates/tls/client.key", // path to client key + "ca_certificate":"/usr/share/cgrates/tls/ca.crt", +}, + + +"stor_db": { + "db_type": "*internal", +}, + + +"rals": { + "enabled": true, + "max_increments":3000000, +}, + + +"schedulers": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": ["*internal"], + "rals_conns": ["*internal"], +}, + + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + +"sessions": { + "enabled": true, + "attributes_conns": ["conn1"], + "cdrs_conns": ["conn1"], + "rals_conns": ["conn1"], + "chargers_conns": ["*internal"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/httpagenttls_gob/httpagent.json b/data/conf/samples/httpagenttls_internal_gob/httpagent.json similarity index 100% rename from data/conf/samples/httpagenttls_gob/httpagent.json rename to data/conf/samples/httpagenttls_internal_gob/httpagent.json diff --git a/data/conf/samples/httpagenttls_mongo/cgrates.json b/data/conf/samples/httpagenttls_mongo/cgrates.json new file mode 100755 index 000000000..ee460ecfb --- /dev/null +++ b/data/conf/samples/httpagenttls_mongo/cgrates.json @@ -0,0 +1,77 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", + "rpc_json_tls":":2022", + "rpc_gob_tls":":2023", + "http_tls": "localhost:2280", +}, + +"tls": { + "server_certificate" : "/usr/share/cgrates/tls/server.crt", // path to server certificate(must conatin server.crt + ca.crt) + "server_key":"/usr/share/cgrates/tls/server.key", // path to server key + "client_certificate" : "/usr/share/cgrates/tls/client.crt", // path to client certificate(must conatin client.crt + ca.crt) + "client_key":"/usr/share/cgrates/tls/client.key", // path to client key + "ca_certificate":"/usr/share/cgrates/tls/ca.crt", +}, + + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + + +"rals": { + "enabled": true, + "max_increments":3000000, +}, + + +"schedulers": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": ["*internal"], + "rals_conns": ["*internal"], +}, + + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + +"sessions": { + "enabled": true, + "attributes_conns": ["*localhost"], + "cdrs_conns": ["*localhost"], + "rals_conns": ["*localhost"], + "chargers_conns": ["*internal"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/httpagenttls_mongo/httpagent.json b/data/conf/samples/httpagenttls_mongo/httpagent.json new file mode 100755 index 000000000..7df9f5e06 --- /dev/null +++ b/data/conf/samples/httpagenttls_mongo/httpagent.json @@ -0,0 +1,169 @@ +{ + + +"http_agent": [ + { + "id": "conecto1", + "url": "/conecto", + "sessions_conns": ["*localhost"], + "request_payload": "*url", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed", + "value": "~*req.MCC;/", "mandatory": true}, + {"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed", + "value": "Val1"}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + "value": "0"}, + ], + }, + { + "id": "OutboundAUTH", + "filters": ["*string:~*req.request_type:OutboundAUTH"], + "tenant": "cgrates.org", + "flags": [ "*auth", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + "value": "*now", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "mtcall_cdr", + "filters": ["*string:~*req.request_type:MTCALL_CDR"], + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;s", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true}, + {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + "value": "1", "mandatory": true}, + ], + } + ], + }, + { + "id": "conecto_xml", + "url": "/conecto_xml", + "sessions_conns": ["*localhost"], + "request_payload": "*xml", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "cdr_from_xml", + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", + "value": "*data", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.complete-datasession-notification.customerid", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.complete-datasession-notification.username", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.complete-datasession-notification.userid", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true}, + ], + "reply_fields":[], + } + ], + }, + { + "id": "textplain", + "url": "/textplain", + "sessions_conns": ["*localhost"], + "request_payload": "*url", + "reply_payload": "*text_plain", + "request_processors": [ + { + "id": "TextPlainDryRun", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Variable1", "type": "*variable", + "value": "Hola1", "mandatory": true}, + {"tag": "Field2", "field_id": "Variable2", "type": "*variable", + "value": "Hola2", "mandatory": true}, + {"tag": "Field3", "field_id": "ComposedVar", "type": "*composed", + "value": "Test", "mandatory": true}, + {"tag": "Field4", "field_id": "ComposedVar", "type": "*composed", + "value": "Composed", "mandatory": true}, + {"tag": "Field5", "field_id": "Item1.1", "type": "*variable", + "value": "Val1", "mandatory": true}, + ], + "continue": true, + }, + { + "id": "TextPlainDryRun2", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Item1.1", "type": "*variable", + "value": "Val2", "mandatory": true}, + ], + }, + ], + }, +], + + +} \ No newline at end of file diff --git a/data/conf/samples/httpagenttls_mongo_gob/cgrates.json b/data/conf/samples/httpagenttls_mongo_gob/cgrates.json new file mode 100755 index 000000000..96b87ddbc --- /dev/null +++ b/data/conf/samples/httpagenttls_mongo_gob/cgrates.json @@ -0,0 +1,85 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", + "rpc_json_tls":":2022", + "rpc_gob_tls":":2023", + "http_tls": "localhost:2280", +}, + + +"rpc_conns": { + "conn1": { + "strategy": "*first", + "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}], + }, +}, + + +"tls": { + "server_certificate" : "/usr/share/cgrates/tls/server.crt", // path to server certificate(must conatin server.crt + ca.crt) + "server_key":"/usr/share/cgrates/tls/server.key", // path to server key + "client_certificate" : "/usr/share/cgrates/tls/client.crt", // path to client certificate(must conatin client.crt + ca.crt) + "client_key":"/usr/share/cgrates/tls/client.key", // path to client key + "ca_certificate":"/usr/share/cgrates/tls/ca.crt", +}, + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + + +"rals": { + "enabled": true, + "max_increments":3000000, +}, + + +"schedulers": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": ["*internal"], + "rals_conns": ["*internal"], +}, + + +"attributes": { + "enabled": true, +}, + +"chargers": { + "enabled": true, + "attributes_conns": ["*internal"], +}, + +"sessions": { + "enabled": true, + "attributes_conns": ["conn1"], + "cdrs_conns": ["conn1"], + "rals_conns": ["conn1"], + "chargers_conns": ["*internal"], +}, + + +"apier": { + "scheduler_conns": ["*internal"], +}, + + +} diff --git a/data/conf/samples/httpagenttls_mongo_gob/httpagent.json b/data/conf/samples/httpagenttls_mongo_gob/httpagent.json new file mode 100755 index 000000000..e2e9ea92f --- /dev/null +++ b/data/conf/samples/httpagenttls_mongo_gob/httpagent.json @@ -0,0 +1,169 @@ +{ + + +"http_agent": [ + { + "id": "conecto1", + "url": "/conecto", + "sessions_conns": ["conn1"], + "request_payload": "*url", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed", + "value": "~*req.MCC;/", "mandatory": true}, + {"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed", + "value": "Val1"}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + "value": "0"}, + ], + }, + { + "id": "OutboundAUTH", + "filters": ["*string:~*req.request_type:OutboundAUTH"], + "tenant": "cgrates.org", + "flags": [ "*auth", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + "value": "*now", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "mtcall_cdr", + "filters": ["*string:~*req.request_type:MTCALL_CDR"], + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;s", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true}, + {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + "value": "1", "mandatory": true}, + ], + } + ], + }, + { + "id": "conecto_xml", + "url": "/conecto_xml", + "sessions_conns": ["conn1"], + "request_payload": "*xml", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "cdr_from_xml", + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", + "value": "*data", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.complete-datasession-notification.customerid", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.complete-datasession-notification.username", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.complete-datasession-notification.userid", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true}, + ], + "reply_fields":[], + } + ], + }, + { + "id": "textplain", + "url": "/textplain", + "sessions_conns": ["conn1"], + "request_payload": "*url", + "reply_payload": "*text_plain", + "request_processors": [ + { + "id": "TextPlainDryRun", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Variable1", "type": "*variable", + "value": "Hola1", "mandatory": true}, + {"tag": "Field2", "field_id": "Variable2", "type": "*variable", + "value": "Hola2", "mandatory": true}, + {"tag": "Field3", "field_id": "ComposedVar", "type": "*composed", + "value": "Test", "mandatory": true}, + {"tag": "Field4", "field_id": "ComposedVar", "type": "*composed", + "value": "Composed", "mandatory": true}, + {"tag": "Field5", "field_id": "Item1.1", "type": "*variable", + "value": "Val1", "mandatory": true}, + ], + "continue": true, + }, + { + "id": "TextPlainDryRun2", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Item1.1", "type": "*variable", + "value": "Val2", "mandatory": true}, + ], + }, + ], + }, +], + + +} \ No newline at end of file diff --git a/data/conf/samples/httpagenttls/cgrates.json b/data/conf/samples/httpagenttls_mysql/cgrates.json similarity index 100% rename from data/conf/samples/httpagenttls/cgrates.json rename to data/conf/samples/httpagenttls_mysql/cgrates.json diff --git a/data/conf/samples/httpagenttls_mysql/httpagent.json b/data/conf/samples/httpagenttls_mysql/httpagent.json new file mode 100755 index 000000000..7df9f5e06 --- /dev/null +++ b/data/conf/samples/httpagenttls_mysql/httpagent.json @@ -0,0 +1,169 @@ +{ + + +"http_agent": [ + { + "id": "conecto1", + "url": "/conecto", + "sessions_conns": ["*localhost"], + "request_payload": "*url", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed", + "value": "~*req.MCC;/", "mandatory": true}, + {"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed", + "value": "Val1"}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + "value": "0"}, + ], + }, + { + "id": "OutboundAUTH", + "filters": ["*string:~*req.request_type:OutboundAUTH"], + "tenant": "cgrates.org", + "flags": [ "*auth", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + "value": "*now", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "mtcall_cdr", + "filters": ["*string:~*req.request_type:MTCALL_CDR"], + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;s", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true}, + {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + "value": "1", "mandatory": true}, + ], + } + ], + }, + { + "id": "conecto_xml", + "url": "/conecto_xml", + "sessions_conns": ["*localhost"], + "request_payload": "*xml", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "cdr_from_xml", + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", + "value": "*data", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.complete-datasession-notification.customerid", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.complete-datasession-notification.username", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.complete-datasession-notification.userid", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true}, + ], + "reply_fields":[], + } + ], + }, + { + "id": "textplain", + "url": "/textplain", + "sessions_conns": ["*localhost"], + "request_payload": "*url", + "reply_payload": "*text_plain", + "request_processors": [ + { + "id": "TextPlainDryRun", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Variable1", "type": "*variable", + "value": "Hola1", "mandatory": true}, + {"tag": "Field2", "field_id": "Variable2", "type": "*variable", + "value": "Hola2", "mandatory": true}, + {"tag": "Field3", "field_id": "ComposedVar", "type": "*composed", + "value": "Test", "mandatory": true}, + {"tag": "Field4", "field_id": "ComposedVar", "type": "*composed", + "value": "Composed", "mandatory": true}, + {"tag": "Field5", "field_id": "Item1.1", "type": "*variable", + "value": "Val1", "mandatory": true}, + ], + "continue": true, + }, + { + "id": "TextPlainDryRun2", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Item1.1", "type": "*variable", + "value": "Val2", "mandatory": true}, + ], + }, + ], + }, +], + + +} \ No newline at end of file diff --git a/data/conf/samples/httpagenttls_gob/cgrates.json b/data/conf/samples/httpagenttls_mysql_gob/cgrates.json similarity index 100% rename from data/conf/samples/httpagenttls_gob/cgrates.json rename to data/conf/samples/httpagenttls_mysql_gob/cgrates.json diff --git a/data/conf/samples/httpagenttls_mysql_gob/httpagent.json b/data/conf/samples/httpagenttls_mysql_gob/httpagent.json new file mode 100755 index 000000000..e2e9ea92f --- /dev/null +++ b/data/conf/samples/httpagenttls_mysql_gob/httpagent.json @@ -0,0 +1,169 @@ +{ + + +"http_agent": [ + { + "id": "conecto1", + "url": "/conecto", + "sessions_conns": ["conn1"], + "request_payload": "*url", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "OutboundAUTHDryRun", + "filters": ["*string:~*req.request_type:OutboundAUTH","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "Concatenated1", "field_id": "response.Concatenated", "type": "*composed", + "value": "~*req.MCC;/", "mandatory": true}, + {"tag": "Concatenated2", "field_id": "response.Concatenated", "type": "*composed", + "value": "Val1"}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*constant", + "value": "1200", "blocker": true}, + {"tag": "Unused", "field_id": "response.Unused", "type": "*constant", + "value": "0"}, + ], + }, + { + "id": "OutboundAUTH", + "filters": ["*string:~*req.request_type:OutboundAUTH"], + "tenant": "cgrates.org", + "flags": [ "*auth", "*accounts", "*attributes"], + "request_fields":[ + {"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CallID", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.Msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.Destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*constant", + "value": "*now", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "Allow", "field_id": "response.Allow", "type": "*constant", + "value": "1", "mandatory": true}, + {"tag": "MaxDuration", "field_id": "response.MaxDuration", "type": "*composed", + "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true}, + ], + }, + { + "id": "mtcall_cdr", + "filters": ["*string:~*req.request_type:MTCALL_CDR"], + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", + "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.msisdn", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.destination", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.timestamp", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.leg_duration;s", "mandatory": true}, + ], + "reply_fields":[ + {"tag": "ResultCode", "filters": ["*rsr::~*cgrep.Error(!^$)"], + "field_id": "CDR_RESPONSE.RESULT_CODE", "type": "*composed", "value": "~*cgrep.Error", "blocker": true}, + {"tag": "CDR_ID", "field_id": "CDR_RESPONSE.CDR_ID", "type": "*composed", + "value": "~*req.CDR_ID", "mandatory": true}, + {"tag": "CDR_STATUS", "field_id": "CDR_RESPONSE.CDR_STATUS", "type": "*constant", + "value": "1", "mandatory": true}, + ], + } + ], + }, + { + "id": "conecto_xml", + "url": "/conecto_xml", + "sessions_conns": ["conn1"], + "request_payload": "*xml", + "reply_payload": "*xml", + "request_processors": [ + { + "id": "cdr_from_xml", + "tenant": "cgrates.org", + "flags": ["*cdrs"], + "request_fields":[ + {"tag": "TOR", "field_id": "ToR", "type": "*constant", + "value": "*data", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*constant", + "value": "*pseudoprepaid", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", + "value": "~*req.complete-datasession-notification.customerid", "mandatory": true}, + {"tag": "Account", "field_id": "Account", "type": "*composed", + "value": "~*req.complete-datasession-notification.username", "mandatory": true}, + {"tag": "Destination", "field_id": "Destination", "type": "*composed", + "value": "~*req.complete-datasession-notification.userid", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", + "value": "~*req.complete-datasession-notification.createtime", "mandatory": true}, + {"tag": "Usage", "field_id": "Usage", "type": "*composed", + "value": "~*req.complete-datasession-notification.callleg.bytes", "mandatory": true}, + ], + "reply_fields":[], + } + ], + }, + { + "id": "textplain", + "url": "/textplain", + "sessions_conns": ["conn1"], + "request_payload": "*url", + "reply_payload": "*text_plain", + "request_processors": [ + { + "id": "TextPlainDryRun", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Variable1", "type": "*variable", + "value": "Hola1", "mandatory": true}, + {"tag": "Field2", "field_id": "Variable2", "type": "*variable", + "value": "Hola2", "mandatory": true}, + {"tag": "Field3", "field_id": "ComposedVar", "type": "*composed", + "value": "Test", "mandatory": true}, + {"tag": "Field4", "field_id": "ComposedVar", "type": "*composed", + "value": "Composed", "mandatory": true}, + {"tag": "Field5", "field_id": "Item1.1", "type": "*variable", + "value": "Val1", "mandatory": true}, + ], + "continue": true, + }, + { + "id": "TextPlainDryRun2", + "filters": ["*string:~*req.request_type:TextPlainDryRun","*string:~*req.Msisdn:497700056231"], + "tenant": "cgrates.org", + "flags": ["*dryrun"], + "request_fields":[ + ], + "reply_fields":[ + {"tag": "Field1", "field_id": "Item1.1", "type": "*variable", + "value": "Val2", "mandatory": true}, + ], + }, + ], + }, +], + + +} \ No newline at end of file diff --git a/integration_test.sh b/integration_test.sh index 682abb150..68488378b 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -17,6 +17,9 @@ echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*internal go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*internal ers_internal=$? +echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*internal' +go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*internal +lds_internal=$? # SQL echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql' go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql @@ -30,7 +33,9 @@ en_sql=$? echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*sql' go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*sql ers_sql=$? - +echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*sql' +go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*sql +lds_sql=$? # Mongo echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo' go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo @@ -44,7 +49,9 @@ en_mongo=$? echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mongo' go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*mongo ers_mongo=$? - +echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*mongo' +go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*mongo +lds_mongo=$? # Postgres echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres' go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres @@ -58,6 +65,9 @@ en_postgres=$? echo 'go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*postgres' go test github.com/cgrates/cgrates/ers -tags=integration -dbtype=*postgres ers_postgres=$? +echo 'go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*postgres' +go test github.com/cgrates/cgrates/loaders -tags=integration -dbtype=*postgres +lds_postgres=$? echo 'go test github.com/cgrates/cgrates/cdrc -tags=integration' go test github.com/cgrates/cgrates/cdrc -tags=integration @@ -82,9 +92,6 @@ mgr=$? echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration' go test github.com/cgrates/cgrates/dispatchers -tags=integration dis=$? -echo 'go test github.com/cgrates/cgrates/loaders -tags=integration' -go test github.com/cgrates/cgrates/loaders -tags=integration -lds=$? echo 'go test github.com/cgrates/cgrates/services -tags=integration' go test github.com/cgrates/cgrates/services -tags=integration srv=$? diff --git a/loaders/lib_test.go b/loaders/lib_test.go new file mode 100644 index 000000000..89229649b --- /dev/null +++ b/loaders/lib_test.go @@ -0,0 +1,47 @@ +/* +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 loaders + +import ( + "errors" + "flag" + "net/rpc" + "net/rpc/jsonrpc" + + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/utils" +) + +var ( + waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache") + dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here") + encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be used for rpc comunication") + dbType = flag.String("dbtype", utils.MetaInternal, "The type of DataBase (Internal/Mongo/mySql)") +) + +func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) { + switch *encoding { + case utils.MetaJSON: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOB: + return rpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} diff --git a/loaders/loader_it_test.go b/loaders/loader_it_test.go index 22c159269..dab46c834 100644 --- a/loaders/loader_it_test.go +++ b/loaders/loader_it_test.go @@ -20,11 +20,8 @@ along with this program. If not, see package loaders import ( - "errors" - "flag" "io/ioutil" "net/rpc" - "net/rpc/jsonrpc" "os" "path" "reflect" @@ -39,61 +36,54 @@ import ( var ( loaderCfgPath string + loaderCfgDIR string //run tests for specific configuration loaderCfg *config.CGRConfig loaderRPC *rpc.Client - loaderDataDir = "/usr/share/cgrates" - loaderConfigDIR string //run tests for specific configuration loaderPathIn, loaderPathOut string - encoding = flag.String("rpc", utils.MetaJSON, "what encoding whould be uused for rpc comunication") + + sTestsLoader = []func(t *testing.T){ + testLoaderMakeFolders, + testLoaderInitCfg, + testLoaderResetDataDB, + testLoaderStartEngine, + testLoaderRPCConn, + testLoaderPopulateData, + testLoaderLoadAttributes, + testLoaderVerifyOutDir, + testLoaderCheckAttributes, + testLoaderKillEngine, + } ) -func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) { - switch *encoding { - case utils.MetaJSON: - return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) - case utils.MetaGOB: - return rpc.Dial(utils.TCP, cfg.RPCGOBListen) - default: - return nil, errors.New("UNSUPPORTED_RPC") - } -} - -var sTestsLoader = []func(t *testing.T){ - testLoaderMakeFolders, - testLoaderInitCfg, - testLoaderResetDataDB, - testLoaderStartEngine, - testLoaderRPCConn, - testLoaderPopulateData, - testLoaderLoadAttributes, - testLoaderVerifyOutDir, - testLoaderCheckAttributes, - testLoaderKillEngine, -} - //Test start here -func TestLoaderITMySql(t *testing.T) { - loaderConfigDIR = "tutmysql" - for _, stest := range sTestsLoader { - t.Run(loaderConfigDIR, stest) +func TestLoaderIT(t *testing.T) { + switch *dbType { + case utils.MetaInternal: + loaderCfgDIR = "tutinternal" + case utils.MetaSQL: + loaderCfgDIR = "tutmysql" + case utils.MetaMongo: + loaderCfgDIR = "tutmongo" + case utils.MetaPostgres: + t.SkipNow() + default: + t.Fatal("Unknown Database type") } -} -func TestLoaderITMongo(t *testing.T) { - loaderConfigDIR = "tutmongo" + loaderCfgDIR = "tutmysql" for _, stest := range sTestsLoader { - t.Run(loaderConfigDIR, stest) + t.Run(loaderCfgDIR, stest) } } func testLoaderInitCfg(t *testing.T) { var err error - loaderCfgPath = path.Join(loaderDataDir, "conf", "samples", "loaders", loaderConfigDIR) + loaderCfgPath = path.Join(*dataDir, "conf", "samples", "loaders", loaderCfgDIR) loaderCfg, err = config.NewCGRConfigFromPath(loaderCfgPath) if err != nil { t.Fatal(err) } - loaderCfg.DataFolderPath = loaderDataDir // Share DataFolderPath through config towards StoreDb for Flush() + loaderCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush() config.SetCgrConfig(loaderCfg) }