From 3cb2ea70a9b04c61e01f41e5f506855d53be4715 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 18 Nov 2014 18:01:58 +0100 Subject: [PATCH] MT#10199 add prof_preferences --- ngcp/ngcp.lua | 16 ++-- ngcp/pprof.lua | 128 +++++++++++++++++++++++++++ ngcp/rp.lua | 11 ++- tests/ngcp.lua | 130 ++++++++++++++++++++++++++- tests/test_all.lua | 3 +- tests_v/pprof_vars.lua | 194 +++++++++++++++++++++++++++++++++++++++++ tests_v/up_vars.lua | 12 +++ 7 files changed, 481 insertions(+), 13 deletions(-) create mode 100644 ngcp/pprof.lua create mode 100644 tests_v/pprof_vars.lua diff --git a/ngcp/ngcp.lua b/ngcp/ngcp.lua index 2786885..34e3b5b 100644 --- a/ngcp/ngcp.lua +++ b/ngcp/ngcp.lua @@ -18,6 +18,7 @@ -- Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". -- require 'ngcp.cp' +require 'ngcp.pprof' require 'ngcp.pp' require 'ngcp.dp' require 'ngcp.up' @@ -41,6 +42,8 @@ NGCPConfig_MT = { __index = NGCPConfig } db_pass = "somepasswd", db_database = "kamailio", default = { + prof = { + }, contract = { }, peer = { @@ -149,6 +152,7 @@ end } t.prefs = { dom = NGCPDomainPrefs:new(t.config), + prof = NGCPProfilePrefs:new(t.config), usr = NGCPUserPrefs:new(t.config), peer = NGCPPeerPrefs:new(t.config), real = NGCPRealPrefs:new(t.config), @@ -193,13 +197,13 @@ end local _,v local keys = { domain = self.prefs.dom:caller_load(domain), + prof = self.prefs.prof:caller_load(uuid), user = self.prefs.usr:caller_load(uuid) } local unique_keys = table.deepcopy(keys.domain) + table.merge(unique_keys, keys.prof) + table.merge(unique_keys, keys.user) - for _,v in pairs(keys.user) do - table.add(unique_keys, v) - end self.prefs.real:caller_usr_load(unique_keys) local xavp = NGCPXAvp:new('caller', 'dom') @@ -210,13 +214,13 @@ end local _,v local keys = { domain = self.prefs.dom:callee_load(domain), + prof = self.prefs.prof:callee_load(uuid), user = self.prefs.usr:callee_load(uuid) } local unique_keys = table.deepcopy(keys.domain) + table.merge(unique_keys, keys.prof) + table.merge(unique_keys, keys.user) - for _,v in pairs(keys.user) do - table.add(unique_keys, v) - end self.prefs.real:callee_usr_load(unique_keys) return unique_keys diff --git a/ngcp/pprof.lua b/ngcp/pprof.lua new file mode 100644 index 0000000..0185d17 --- /dev/null +++ b/ngcp/pprof.lua @@ -0,0 +1,128 @@ +-- +-- Copyright 2014 SipWise Team +-- +-- 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 package 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 . +-- . +-- On Debian systems, the complete text of the GNU General +-- Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". +-- +require 'ngcp.utils' +require 'ngcp.xavp' + +-- class NGCPProfilePrefs +NGCPProfilePrefs = { + __class__ = 'NGCPProfilePrefs' +} +NGCPProfilePrefs_MT = { __index = NGCPProfilePrefs } + +NGCPProfilePrefs_MT.__tostring = function () + local output = '' + local xavp = NGCPXAvp:new('caller','prof_prefs') + output = string.format("caller_prof_prefs:%s\n", tostring(xavp)) + xavp = NGCPXAvp:new('callee','prof_prefs') + output = output .. string.format("callee_prof_prefs:%s\n", tostring(xavp)) + return output + end + + function NGCPProfilePrefs:new(config) + local t = { + config = config, + db_table = "prof_preferences" + } + -- creates xavp prof + NGCPPrefs.init("prof_prefs") + return setmetatable( t, NGCPProfilePrefs_MT ) + end + + function NGCPProfilePrefs:caller_load(uuid) + if uuid then + return self:_load("caller",uuid) + else + return {} + end + end + + function NGCPProfilePrefs:callee_load(uuid) + if uuid then + return self:_load("callee",uuid) + else + return {} + end + end + + function NGCPProfilePrefs:_defaults(level) + local defaults = self.config:get_defaults('prof') + local keys = {} + local k,_ + + if defaults then + for k,v in pairs(defaults) do + table.insert(keys, k) + end + end + return keys, defaults + end + + function NGCPProfilePrefs:_load(level, uuid) + local con = assert (self.config:getDBConnection()) + local query = "SELECT prefs.* FROM provisioning.voip_subscribers as usr LEFT JOIN ".. + self.db_table .." AS prefs ON usr.profile_id = prefs.uuid WHERE usr.uuid = '".. uuid .. "'" + local cur = assert (con:execute(query)) + local defaults + local keys + local result = {} + local row = cur:fetch({}, "a") + local k,v + local xavp + + keys, defaults = self:_defaults(level) + + if row then + while row do + --sr.log("info", string.format("result:%s row:%s", table.tostring(result), table.tostring(row))) + table.insert(result, row) + table.add(keys, row.attribute) + defaults[row.attribute] = nil + row = cur:fetch({}, "a") + end + else + sr.log("dbg", string.format("no results for query:%s", query)) + end + cur:close() + + xavp = self:xavp(level, result) + for k,v in pairs(defaults) do + sr.log("dbg", string.format("setting default[%s]:%s", k, tostring(v))) + xavp(k, v) + end + return keys + end + + function NGCPProfilePrefs:xavp(level, l) + if level ~= 'caller' and level ~= 'callee' then + error(string.format("unknown level:%s. It has to be [caller|callee]", tostring(level))) + end + return NGCPXAvp:new(level,'prof_prefs', l) + end + + function NGCPProfilePrefs:clean(vtype) + if not vtype then + NGCPProfilePrefs:xavp('callee'):clean() + NGCPProfilePrefs:xavp('caller'):clean() + else + NGCPProfilePrefs:xavp(vtype):clean() + end + end +-- class +--EOF \ No newline at end of file diff --git a/ngcp/rp.lua b/ngcp/rp.lua index fcff035..433e52c 100644 --- a/ngcp/rp.lua +++ b/ngcp/rp.lua @@ -101,22 +101,27 @@ NGCPRealPrefs_MT.__tostring = function () function NGCPRealPrefs:_usr_load(level, keys) local _,v,k local xavp = { - real = NGCPRealPrefs:xavp(level), + real = NGCPRealPrefs:xavp(level), dom = NGCPDomainPrefs:xavp(level), + prof = NGCPProfilePrefs:xavp(level), usr = NGCPUserPrefs:xavp(level) } local real_values = {} local dom_values = sr.xavp.get(xavp.dom.name, 0, 0) + local prof_values = sr.xavp.get(xavp.prof.name, 0, 0) local usr_values = sr.xavp.get(xavp.usr.name, 0, 0) for _,v in pairs(keys) do local value = usr_values[v] if not value then - value = dom_values[v] + value = prof_values[v] + if not value then + value = dom_values[v] + end end if value then real_values[v] = value else - sr.log("err", string.format("key:%s not in user or domain", v)) + sr.log("err", string.format("key:%s not in user, profile or domain", v)) end end local real_keys = {} diff --git a/tests/ngcp.lua b/tests/ngcp.lua index 71d37a9..960d6d3 100644 --- a/tests/ngcp.lua +++ b/tests/ngcp.lua @@ -22,6 +22,7 @@ require('lemock') require 'ngcp.utils' require 'tests_v.dp_vars' require 'tests_v.pp_vars' +require 'tests_v.pprof_vars' require 'tests_v.up_vars' if not sr then @@ -35,6 +36,7 @@ local mc,env local dp_vars = DPFetch:new() local pp_vars = PPFetch:new() local up_vars = UPFetch:new() +local pprof_vars = PProfFetch:new() package.loaded.luasql = nil package.preload['luasql.mysql'] = function () @@ -59,12 +61,15 @@ TestNGCP = {} --class self.ngcp.config.con = nil dp_vars:reset() pp_vars:reset() + pprof_vars:reset() up_vars:reset() end function TestNGCP:tearDown() sr.pv.unset("$xavp(caller_dom_prefs)") sr.pv.unset("$xavp(callee_dom_prefs)") + sr.pv.unset("$xavp(caller_prof_prefs)") + sr.pv.unset("$xavp(callee_prof_prefs)") sr.pv.unset("$xavp(caller_peer_prefs)") sr.pv.unset("$xavp(callee_peer_prefs)") sr.pv.unset("$xavp(caller_usr_prefs)") @@ -112,6 +117,9 @@ TestNGCP = {} --class assertTrue(self.ngcp.prefs.real) assertEquals(sr.pv.get("$xavp(caller_real_prefs=>dummy)"),"caller") assertEquals(sr.pv.get("$xavp(callee_real_prefs=>dummy)"),"callee") + assertTrue(self.ngcp.prefs.prof) + assertEquals(sr.pv.get("$xavp(caller_prof_prefs=>dummy)"),"caller") + assertEquals(sr.pv.get("$xavp(callee_prof_prefs=>dummy)"),"callee") end function TestNGCP:test_log_pref() @@ -134,6 +142,16 @@ TestNGCP = {} --class function TestNGCP:test_caller_usr_load_empty_dom() local c = self.ngcp.config env:connect(c.db_database, c.db_username, c.db_pass, c.db_host, c.db_port) ;mc :returns(self.con) + -- connection check + self.con:execute("SELECT 1") ;mc :returns(self.cur) + self.cur:fetch() ;mc :returns({}) + self.cur:numrows() ;mc :returns(1) + self.cur:close() + -- + self.con:execute("SELECT prefs.* FROM provisioning.voip_subscribers as usr LEFT JOIN prof_preferences AS prefs ON usr.profile_id = prefs.uuid WHERE usr.uuid = 'ae736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + -- self.con:execute("SELECT * FROM usr_preferences WHERE uuid ='ae736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) @@ -193,6 +211,15 @@ TestNGCP = {} --class self.cur:numrows() ;mc :returns(1) self.cur:close() -- + self.con:execute("SELECT prefs.* FROM provisioning.voip_subscribers as usr LEFT JOIN prof_preferences AS prefs ON usr.profile_id = prefs.uuid WHERE usr.uuid = 'ae736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + -- connection check + self.con:execute("SELECT 1") ;mc :returns(self.cur) + self.cur:fetch() ;mc :returns({}) + self.cur:numrows() ;mc :returns(1) + self.cur:close() + -- self.con:execute("SELECT * FROM usr_preferences WHERE uuid ='ae736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) @@ -234,6 +261,16 @@ TestNGCP = {} --class self.cur:numrows() ;mc :returns(1) self.cur:close() -- + self.con:execute("SELECT prefs.* FROM provisioning.voip_subscribers as usr LEFT JOIN prof_preferences AS prefs ON usr.profile_id = prefs.uuid WHERE usr.uuid = 'ae736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(pprof_vars:val("prof_1")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + -- connection check + self.con:execute("SELECT 1") ;mc :returns(self.cur) + self.cur:fetch() ;mc :returns({}) + self.cur:numrows() ;mc :returns(1) + self.cur:close() + -- self.con:execute("SELECT * FROM usr_preferences WHERE uuid ='ae736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) @@ -255,6 +292,93 @@ TestNGCP = {} --class assertEquals(sr.pv.get("$xavp(callee_real_prefs=>sst_refresh_method)"), "UPDATE_FALLBACK_INVITE") end + function TestNGCP:test_callee_usr_load_prof() + local c = self.ngcp.config + env:connect(c.db_database, c.db_username, c.db_pass, c.db_host, c.db_port) ;mc :returns(self.con) + self.con:execute("SELECT * FROM dom_preferences WHERE domain ='192.168.51.56'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(dp_vars:val("d_192_168_51_56")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(dp_vars:val("d_192_168_51_56")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + -- connection check + self.con:execute("SELECT 1") ;mc :returns(self.cur) + self.cur:fetch() ;mc :returns({}) + self.cur:numrows() ;mc :returns(1) + self.cur:close() + -- + self.con:execute("SELECT prefs.* FROM provisioning.voip_subscribers as usr LEFT JOIN prof_preferences AS prefs ON usr.profile_id = prefs.uuid WHERE usr.uuid = 'ae736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(pprof_vars:val("prof_2")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + -- connection check + self.con:execute("SELECT 1") ;mc :returns(self.cur) + self.cur:fetch() ;mc :returns({}) + self.cur:numrows() ;mc :returns(1) + self.cur:close() + -- + self.con:execute("SELECT * FROM usr_preferences WHERE uuid ='ae736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ae736f72_21d1_4ea6_a3ea_4d7f56b3887c")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + + mc:replay() + local keys = self.ngcp:callee_usr_load("ae736f72-21d1-4ea6-a3ea-4d7f56b3887c", "192.168.51.56") + mc:verify() + + assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>dummy)"), "callee") + assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>sst_enable)"), "no") + assertEquals(sr.pv.get("$xavp(callee_prof_prefs=>sst_enable)"), "yes") + --- the default is on real NOT in usr + assertIsNil(sr.pv.get("$xavp(callee_usr_prefs=>sst_enable)")) + assertEquals(sr.pv.get("$xavp(callee_real_prefs=>sst_enable)"), "yes") + assertEquals(sr.pv.get("$xavp(callee_real_prefs=>sst_refresh_method)"), "UPDATE_FALLBACK_INVITE") + end + + function TestNGCP:test_callee_usr_load_prof_usr() + local c = self.ngcp.config + env:connect(c.db_database, c.db_username, c.db_pass, c.db_host, c.db_port) ;mc :returns(self.con) + self.con:execute("SELECT * FROM dom_preferences WHERE domain ='192.168.51.56'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(dp_vars:val("d_192_168_51_56")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(dp_vars:val("d_192_168_51_56")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + -- connection check + self.con:execute("SELECT 1") ;mc :returns(self.cur) + self.cur:fetch() ;mc :returns({}) + self.cur:numrows() ;mc :returns(1) + self.cur:close() + -- + self.con:execute("SELECT prefs.* FROM provisioning.voip_subscribers as usr LEFT JOIN prof_preferences AS prefs ON usr.profile_id = prefs.uuid WHERE usr.uuid = 'ah736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(pprof_vars:val("prof_2")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + -- connection check + self.con:execute("SELECT 1") ;mc :returns(self.cur) + self.cur:fetch() ;mc :returns({}) + self.cur:numrows() ;mc :returns(1) + self.cur:close() + -- + self.con:execute("SELECT * FROM usr_preferences WHERE uuid ='ah736f72-21d1-4ea6-a3ea-4d7f56b3887c'") ;mc :returns(self.cur) + self.cur:fetch(mc.ANYARGS) ;mc :returns(up_vars:val("ah736f72_21d1_4ea6_a3ea_4d7f56b3887c")) + self.cur:fetch(mc.ANYARGS) ;mc :returns(nil) + self.cur:close() + + mc:replay() + local keys = self.ngcp:callee_usr_load("ah736f72-21d1-4ea6-a3ea-4d7f56b3887c", "192.168.51.56") + mc:verify() + + assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>dummy)"), "callee") + assertEquals(sr.pv.get("$xavp(callee_dom_prefs=>sst_enable)"), "no") + assertEquals(sr.pv.get("$xavp(callee_prof_prefs=>sst_enable)"), "yes") + --- the default is on real NOT in usr + assertEquals(sr.pv.get("$xavp(callee_usr_prefs=>sst_enable)"), "no") + assertEquals(sr.pv.get("$xavp(callee_real_prefs=>sst_enable)"), "no") + end + function TestNGCP:test_caller_peer_load_empty() assertEquals(self.ngcp:caller_peer_load(), {}) end @@ -314,7 +438,7 @@ TestNGCP = {} --class end function TestNGCP:test_clean_caller_groups() - local groups = {"peer", "usr", "dom", "real"} + local groups = {"peer", "usr", "dom", "real", "prof"} local _,v for _,v in pairs(groups) do @@ -330,7 +454,7 @@ TestNGCP = {} --class function TestNGCP:test_clean_callee_groups() - local groups = {"peer", "usr", "dom", "real"} + local groups = {"peer", "usr", "dom", "real", "prof"} local _,v, xavp for _,v in pairs(groups) do @@ -389,7 +513,7 @@ TestNGCP = {} --class end function TestNGCP:test_tostring() - assertEquals(tostring(self.ngcp), 'caller_contract_prefs:{dummy={"caller"}}\ncallee_contract_prefs:{dummy={"callee"}}\ncaller_peer_prefs:{dummy={"caller"}}\ncallee_peer_prefs:{dummy={"callee"}}\ncaller_dom_prefs:{dummy={"caller"}}\ncallee_dom_prefs:{dummy={"callee"}}\ncaller_usr_prefs:{dummy={"caller"}}\ncallee_usr_prefs:{dummy={"callee"}}\ncaller_real_prefs:{dummy={"caller"}}\ncallee_real_prefs:{dummy={"callee"}}\n') + assertEquals(tostring(self.ngcp), 'caller_contract_prefs:{dummy={"caller"}}\ncallee_contract_prefs:{dummy={"callee"}}\ncaller_peer_prefs:{dummy={"caller"}}\ncallee_peer_prefs:{dummy={"callee"}}\ncaller_dom_prefs:{dummy={"caller"}}\ncallee_dom_prefs:{dummy={"callee"}}\ncaller_prof_prefs:{dummy={"caller"}}\ncallee_prof_prefs:{dummy={"callee"}}\ncaller_usr_prefs:{dummy={"caller"}}\ncallee_usr_prefs:{dummy={"callee"}}\ncaller_real_prefs:{dummy={"caller"}}\ncallee_real_prefs:{dummy={"callee"}}\n') end -- class TestNGCP --EOF diff --git a/tests/test_all.lua b/tests/test_all.lua index 2f4df28..de76078 100644 --- a/tests/test_all.lua +++ b/tests/test_all.lua @@ -22,6 +22,7 @@ require 'tests.mocks' require 'tests.ngcp_avp' require 'tests.ngcp_xavp' require 'tests.ngcp_pref' +--require 'tests.ngcp_pprof' require 'tests.ngcp_dp' require 'tests.ngcp_up' require 'tests.ngcp_pp' @@ -29,6 +30,6 @@ require 'tests.ngcp_rp' require 'tests.ngcp' ---- Control test output: lu = LuaUnit -lu:setOutputType( "TAP" ) +lu:setOutputType( "TEXT" ) lu:setVerbosity( 1 ) lu:run() \ No newline at end of file diff --git a/tests_v/pprof_vars.lua b/tests_v/pprof_vars.lua new file mode 100644 index 0000000..7c7c2d4 --- /dev/null +++ b/tests_v/pprof_vars.lua @@ -0,0 +1,194 @@ +-- +-- Copyright 2013 SipWise Team +-- +-- 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 package 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 . +-- . +-- On Debian systems, the complete text of the GNU General +-- Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". +-- +pprof_vars = { + prof_1 = { + { + id = 1, + uuid = "1", + username = "0", + domain = nil, + attribute = "sst_enable", + type = 0, + value = "no", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 2, + uuid = "1", + username = "0", + domain = nil, + attribute = "sst_refresh_method", + type = 0, + value = "UPDATE_FALLBACK_INVITE", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 3, + uuid = "1", + username = "0", + domain = nil, + attribute = "outbound_from_user", + type = 0, + value = "upn", + last_modified = "0000-00-00 00:00:00" + }, + { + id = "4", + uuid = "1", + username = "0", + domain = nil, + attribute = "outbound_pai_user", + type = 0, + value = "npn", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 5, + uuid = "1", + username = "0", + domain = nil, + attribute = "use_rtpproxy", + type = 0, + value = "ice_strip_candidates", + last_modified = "0000-00-00 00:00:00" + } + }, + prof_2 = { + { + id = 8, + uuid = "2", + username = "0", + domain = nil, + attribute = "sst_enable", + type = 0, + value = "yes", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 9, + uuid = "2", + username = "0", + domain = nil, + attribute = "sst_refresh_method", + type = 0, + value = "UPDATE_FALLBACK_INVITE", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 10, + uuid = "2", + username = "0", + domain = nil, + attribute = "outbound_from_user", + type = 0, + value = "upn", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 11, + uuid = "2", + username = "0", + domain = nil, + attribute = "outbound_pai_user", + type = 0, + value = "npn", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 12, + uuid = "2", + username = "0", + domain = nil, + attribute = "use_rtpproxy", + type = 0, + value = "ice_strip_candidates", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 15, + uuid = "2", + username = "0", + domain = nil, + attribute = "rewrite_caller_in_dpid", + type = 1, + value = "1", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 16, + uuid = "2", + username = "0", + domain = nil, + attribute = "rewrite_callee_in_dpid", + type = 1, + value = "2", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 17, + uuid = "2", + username = "0", + domain = nil, + attribute = "rewrite_caller_out_dpid", + type = 1, + value = "3", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 18, + uuid = "2", + username = "0", + domain = nil, + attribute = "rewrite_callee_out_dpid", + type = 1, + value = "4", + last_modified = "0000-00-00 00:00:00" + }, + { + id = 19, + uuid = "2", + username = "0", + domain = nil, + attribute = "inbound_uprn", + type = 0, + value = "none", + last_modified = "0000-00-00 00:00:00" + } + } +} + +PProfFetch = { + __class__ = 'PProfFetch', + _i = 1 +} + function PProfFetch:new() + t = {} + return setmetatable(t, { __index = PProfFetch }) + end + + function PProfFetch:val(uuid) + self._i = self._i + 1 + return pprof_vars[uuid][self._i-1] + end + + function PProfFetch:reset() + self._i = 1 + end +--EOF \ No newline at end of file diff --git a/tests_v/up_vars.lua b/tests_v/up_vars.lua index 6eb61a1..e5ea63a 100644 --- a/tests_v/up_vars.lua +++ b/tests_v/up_vars.lua @@ -121,6 +121,18 @@ up_vars = { value = "4311002", last_modified = "1900-01-01 00:00:01" } + }, + ah736f72_21d1_4ea6_a3ea_4d7f56b3887c = { + { + id = 1, + uuid = "ah736f72-21d1-4ea6-a3ea-4d7f56b3887c", + username = "testuser1", + domain = "192.168.51.56", + attribute = "sst_enable", + type = 0, + value = "no", + last_modified = "1900-01-01 00:00:01" + }, } }