From ac171f050e2174f0f523889d3c533207229fbff9 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 26 Nov 2021 12:23:08 +0200 Subject: [PATCH] Updated integration tests --- analyzers/analyzers_it_test.go | 2 +- dispatchers/attributes_it_test.go | 4 +++- dispatchers/sessions_it_test.go | 24 +++++++++++++++-------- engine/account.go | 5 ++++- general_tests/all_cfg_sect_rld_it_test.go | 6 +++--- general_tests/attributes_it_test.go | 2 +- general_tests/filters_it_test.go | 6 +++--- general_tests/session3_it_test.go | 3 +++ registrarc/registrarcrpc_it_test.go | 11 ++++++----- sessions/sessions.go | 13 ++++++++++++ 10 files changed, 53 insertions(+), 23 deletions(-) diff --git a/analyzers/analyzers_it_test.go b/analyzers/analyzers_it_test.go index d98b89b55..fd3ee4b10 100644 --- a/analyzers/analyzers_it_test.go +++ b/analyzers/analyzers_it_test.go @@ -194,7 +194,7 @@ func testAnalyzerSChargerSv1ProcessEvent(t *testing.T) { }, APIOpts: map[string]interface{}{ "*subsys": "*chargers", - utils.OptsAttributesProfileIDs: []string{"*constant:*req.RequestType:*none"}, + utils.OptsAttributesProfileIDs: []interface{}{"*constant:*req.RequestType:*none"}, }, }, }, diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go index 00be46838..f285b05b4 100644 --- a/dispatchers/attributes_it_test.go +++ b/dispatchers/attributes_it_test.go @@ -450,7 +450,8 @@ func testDspAttrTestAuthKey2(t *testing.T) { "Password": "CGRateS.org", }, APIOpts: map[string]interface{}{ - utils.OptsAPIKey: "attr12345", + utils.OptsAPIKey: "attr12345", + utils.OptsContext: "simpleauth", }, }, } @@ -564,6 +565,7 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) { utils.ToJSON(eRply), utils.ToJSON(rplyEv)) } + eRply.APIOpts[utils.OptsContext] = "simpleauth" // To ALL if err := dispEngine.RPC.Call(utils.AttributeSv1ProcessEvent, args, &rplyEv); err != nil { diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go index b03008cad..eb283c649 100644 --- a/dispatchers/sessions_it_test.go +++ b/dispatchers/sessions_it_test.go @@ -403,8 +403,9 @@ func testDspSessionUpdate(t *testing.T) { utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf", }, APIOpts: map[string]interface{}{ - utils.OptsAPIKey: "ses12345", - utils.Subsys: utils.MetaSessionS, + utils.OptsAPIKey: "ses12345", + "*attrProfileIDs": nil, + utils.Subsys: utils.MetaSessionS, }, }, } @@ -477,8 +478,9 @@ func testDspSessionUpdate2(t *testing.T) { utils.Usage: float64(reqUsage), }, APIOpts: map[string]interface{}{ - utils.OptsAPIKey: "ses12345", - utils.Subsys: utils.MetaSessionS, + utils.OptsAPIKey: "ses12345", + "*attrProfileIDs": nil, + utils.Subsys: utils.MetaSessionS, }, }, } @@ -631,8 +633,11 @@ func testDspSessionProcessEvent(t *testing.T) { utils.Usage: 300000000000.0, }, APIOpts: map[string]interface{}{ - utils.OptsAPIKey: "ses12345", - utils.Subsys: utils.MetaSessionS, + utils.OptsAPIKey: "ses12345", + "*attrProfileIDs": nil, + "*rsUnits": 1., + "*rsUsageID": "TestSSv1It2", + utils.Subsys: utils.MetaSessionS, }, }, } @@ -709,8 +714,11 @@ func testDspSessionProcessEvent2(t *testing.T) { utils.Usage: 300000000000.0, }, APIOpts: map[string]interface{}{ - utils.OptsAPIKey: "pse12345", - utils.Subsys: utils.MetaSessionS, + utils.OptsAPIKey: "pse12345", + "*attrProfileIDs": nil, + "*rsUnits": 1., + "*rsUsageID": "TestSSv1It2", + utils.Subsys: utils.MetaSessionS, }, }, } diff --git a/engine/account.go b/engine/account.go index 5da6c027e..042864bde 100644 --- a/engine/account.go +++ b/engine/account.go @@ -1280,7 +1280,10 @@ func (acc *Account) String() string { } func (acc *Account) FieldAsInterface(fldPath []string) (val interface{}, err error) { - if acc == nil || len(fldPath) == 0 { + if len(fldPath) == 0 { + return acc, nil + } + if acc == nil { return nil, utils.ErrNotFound } switch fldPath[0] { diff --git a/general_tests/all_cfg_sect_rld_it_test.go b/general_tests/all_cfg_sect_rld_it_test.go index d75838db7..016f47c87 100644 --- a/general_tests/all_cfg_sect_rld_it_test.go +++ b/general_tests/all_cfg_sect_rld_it_test.go @@ -312,7 +312,7 @@ func testSectConfigSReloadHTTP(t *testing.T) { } else if reply != utils.OK { t.Errorf("Expected OK received: %+v", reply) } - cfgStr := "{\"http\":{\"auth_users\":{},\"client_opts\":{\"dialFallbackDelay\":\"300ms\",\"dialKeepAlive\":\"30s\",\"dialTimeout\":\"30s\",\"disableCompression\":false,\"disableKeepAlives\":false,\"expectContinueTimeout\":\"0\",\"forceAttemptHttp2\":true,\"idleConnTimeout\":\"90s\",\"maxConnsPerHost\":0,\"maxIdleConns\":100,\"maxIdleConnsPerHost\":2,\"responseHeaderTimeout\":\"0\",\"skipTlsVerify\":false,\"tlsHandshakeTimeout\":\"10s\"},\"freeswitch_cdrs_url\":\"/freeswitch_json\",\"http_cdrs\":\"/cdr_http\",\"json_rpc_url\":\"/jsonrpc\",\"registrars_url\":\"/registrar\",\"use_basic_auth\":false,\"ws_url\":\"/ws\"}}" + cfgStr := "{\"http\":{\"auth_users\":{},\"client_opts\":{\"dialFallbackDelay\":\"300ms\",\"dialKeepAlive\":\"30s\",\"dialTimeout\":\"30s\",\"disableCompression\":false,\"disableKeepAlives\":false,\"expectContinueTimeout\":\"0s\",\"forceAttemptHttp2\":true,\"idleConnTimeout\":\"1m30s\",\"maxConnsPerHost\":0,\"maxIdleConns\":100,\"maxIdleConnsPerHost\":2,\"responseHeaderTimeout\":\"0s\",\"skipTlsVerify\":false,\"tlsHandshakeTimeout\":\"10s\"},\"freeswitch_cdrs_url\":\"/freeswitch_json\",\"http_cdrs\":\"/cdr_http\",\"json_rpc_url\":\"/jsonrpc\",\"registrars_url\":\"/registrar\",\"use_basic_auth\":false,\"ws_url\":\"/ws\"}}" var rpl string if err := testSectRPC.Call(utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ @@ -981,7 +981,7 @@ func testSectConfigSReloadResources(t *testing.T) { } else if reply != utils.OK { t.Errorf("Expected OK received: %+v", reply) } - cfgStr := "{\"resources\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*units\":1,\"*usageID\":\"\",\"*usageTTL\":259200000000000},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"store_interval\":\"-1ns\",\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"],\"thresholds_conns\":[\"*internal\"]}}" + cfgStr := "{\"resources\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*units\":1,\"*usageID\":\"\"},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"store_interval\":\"-1ns\",\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"],\"thresholds_conns\":[\"*internal\"]}}" var rpl string if err := testSectRPC.Call(utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ Tenant: "cgrates.org", @@ -1095,7 +1095,7 @@ func testSectConfigSReloadRoutes(t *testing.T) { } else if reply != utils.OK { t.Errorf("Expected OK received: %+v", reply) } - cfgStr := "{\"routes\":{\"attributes_conns\":[\"*localhost\"],\"default_ratio\":1,\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*context\":\"*routes\",\"*ignoreErrors\":false,\"*maxCost\":\"\",\"*profileCount\":1},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"rals_conns\":[\"*localhost\"],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"]}}" + cfgStr := "{\"routes\":{\"attributes_conns\":[\"*localhost\"],\"default_ratio\":1,\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*context\":\"*routes\",\"*ignoreErrors\":false,\"*maxCost\":\"\"},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"rals_conns\":[\"*localhost\"],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"]}}" var rpl string if err := testSectRPC.Call(utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ Tenant: "cgrates.org", diff --git a/general_tests/attributes_it_test.go b/general_tests/attributes_it_test.go index e1833b6de..4ba3c3b98 100644 --- a/general_tests/attributes_it_test.go +++ b/general_tests/attributes_it_test.go @@ -1030,7 +1030,7 @@ func testAttributeSProcessEventWithLibPhoneNumberFull(t *testing.T) { Event: map[string]interface{}{ "EventName": "AddDestinationDetails", "Destination": "+447779330921", - "DestinationDetails": "{\"Carrier\":\"Orange\",\"CountryCode\":44,\"CountryCodeSource\":1,\"Extension\":\"\",\"GeoLocation\":\"\",\"ItalianLeadingZero\":false,\"LengthOfNationalDestinationCode\":0,\"NationalNumber\":7779330921,\"NumberOfLeadingZeros\":1,\"NumberType\":1,\"PreferredDomesticCarrierCode\":\"\",\"RawInput\":\"+447779330921\",\"Region\":\"GB\"}", + "DestinationDetails": "{\"Carrier\":\"Orange\",\"CountryCode\":44,\"CountryCodeSource\":1,\"Extension\":\"\",\"GeoLocation\":\"United Kingdom\",\"ItalianLeadingZero\":false,\"LengthOfNationalDestinationCode\":0,\"NationalNumber\":7779330921,\"NumberOfLeadingZeros\":1,\"NumberType\":1,\"PreferredDomesticCarrierCode\":\"\",\"RawInput\":\"+447779330921\",\"Region\":\"GB\"}", }, APIOpts: map[string]interface{}{ utils.OptsContext: utils.MetaSessionS, diff --git a/general_tests/filters_it_test.go b/general_tests/filters_it_test.go index cb47c06e1..55d53608c 100644 --- a/general_tests/filters_it_test.go +++ b/general_tests/filters_it_test.go @@ -939,7 +939,7 @@ func testV1FltrChargerSuffix(t *testing.T) { }, APIOpts: map[string]interface{}{ utils.Subsys: utils.MetaChargers, - utils.OptsAttributesProfileIDs: []string{"*constant:*req.Subject:intraState"}, + utils.OptsAttributesProfileIDs: []interface{}{"*constant:*req.Subject:intraState"}, }, }, }, @@ -977,7 +977,7 @@ func testV1FltrChargerSuffix(t *testing.T) { }, APIOpts: map[string]interface{}{ utils.Subsys: utils.MetaChargers, - utils.OptsAttributesProfileIDs: []string{"*constant:*req.Subject:interState"}, + utils.OptsAttributesProfileIDs: []interface{}{"*constant:*req.Subject:interState"}, }, }, }, @@ -1144,7 +1144,7 @@ func testV1FltrPopulateTimings(t *testing.T) { utils.AnswerTime: "2021-04-29T10:45:00Z", }, APIOpts: map[string]interface{}{ - utils.OptsAttributesProfileIDs: []string{"FltrTest"}, + utils.OptsAttributesProfileIDs: []interface{}{"FltrTest"}, utils.OptsContext: utils.MetaAny, }, }, diff --git a/general_tests/session3_it_test.go b/general_tests/session3_it_test.go index 7420eea5b..07dac0a47 100644 --- a/general_tests/session3_it_test.go +++ b/general_tests/session3_it_test.go @@ -188,6 +188,9 @@ func testSes3ItProcessEvent(t *testing.T) { utils.Subsys: utils.MetaSessionS, utils.OptsAPIKey: "ses12345", utils.MetaEventType: utils.StatUpdate, + "*attrProfileIDs": nil, + "*rsUnits": 1., + "*rsUsageID": "TestSSv1It2", }, }, } diff --git a/registrarc/registrarcrpc_it_test.go b/registrarc/registrarcrpc_it_test.go index 3df3b3f9f..ea1e99b94 100644 --- a/registrarc/registrarcrpc_it_test.go +++ b/registrarc/registrarcrpc_it_test.go @@ -160,8 +160,8 @@ func testRPCChargerSWithAttr(t *testing.T) { "RunID": "CustomerCharges", }, APIOpts: map[string]interface{}{ - "*processRuns": 1., - "*subsys": "*chargers", + utils.OptsAttributesProcessRuns: 1., + "*subsys": "*chargers", }, }, }, { @@ -176,8 +176,8 @@ func testRPCChargerSWithAttr(t *testing.T) { "RunID": "raw", }, APIOpts: map[string]interface{}{ - utils.OptsAttributesProcessRuns: 1, - utils.OptsAttributesProfileIDs: []string{"*constant:*req.RequestType:*none"}, + utils.OptsAttributesProcessRuns: 1., + utils.OptsAttributesProfileIDs: []interface{}{"*constant:*req.RequestType:*none"}, "*subsys": "*chargers", }, }, @@ -193,7 +193,8 @@ func testRPCChargerSWithAttr(t *testing.T) { "Subject": "SUPPLIER1", }, APIOpts: map[string]interface{}{ - utils.OptsAttributesProcessRuns: 1, + utils.OptsAttributesProcessRuns: 1., + "*attrProfileIDs": []interface{}{"ATTR_SUPPLIER1"}, "*subsys": "*chargers", }, }, diff --git a/sessions/sessions.go b/sessions/sessions.go index ac9eaa224..f377a80d2 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -1846,6 +1846,8 @@ type V1AuthorizeArgs struct { utils.Paginator } +func (V1AuthorizeArgs) RPCClone() {} + // ParseFlags will populate the V1AuthorizeArgs flags func (args *V1AuthorizeArgs) ParseFlags(flags, sep string) { for _, subsystem := range strings.Split(flags, sep) { @@ -2145,6 +2147,8 @@ type V1InitSessionArgs struct { *utils.CGREvent } +func (V1InitSessionArgs) RPCClone() {} + // ParseFlags will populate the V1InitSessionArgs flags func (args *V1InitSessionArgs) ParseFlags(flags, sep string) { for _, subsystem := range strings.Split(flags, sep) { @@ -2424,6 +2428,8 @@ type V1UpdateSessionArgs struct { *utils.CGREvent } +func (V1UpdateSessionArgs) RPCClone() {} + // V1UpdateSessionReply contains options for session update reply type V1UpdateSessionReply struct { Attributes *engine.AttrSProcessEventReply `json:",omitempty"` @@ -2581,6 +2587,8 @@ type V1TerminateSessionArgs struct { *utils.CGREvent } +func (V1TerminateSessionArgs) RPCClone() {} + // ParseFlags will populate the V1TerminateSessionArgs flags func (args *V1TerminateSessionArgs) ParseFlags(flags, sep string) { for _, subsystem := range strings.Split(flags, sep) { @@ -2829,6 +2837,8 @@ type V1ProcessMessageArgs struct { utils.Paginator } +func (V1ProcessMessageArgs) RPCClone() {} + // ParseFlags will populate the V1ProcessMessageArgs flags func (args *V1ProcessMessageArgs) ParseFlags(flags, sep string) { for _, subsystem := range strings.Split(flags, sep) { @@ -3043,6 +3053,9 @@ type V1ProcessEventArgs struct { utils.Paginator } +// RPCClone implements rpcclient.RPCCloner interface +func (V1ProcessEventArgs) RPCClone() {} + // V1ProcessEventReply is the reply for the ProcessEvent API type V1ProcessEventReply struct { MaxUsage map[string]time.Duration `json:",omitempty"`