MT#56961 Clean $xavp(callee_prefs) when cleaning $xavp(callee_peer_prefs)

The following scenario disclouse an issue with "ngcp_clean" lua
function in case of callee peer:

- A is a local subscriber with Peer_auth set and
  force_outbound_call_to_peer set;
- B is a local subscriber with Peer_auth set and
  force_outbound_call_to_peer set;

A calls B.
We clean and load callee preferences of B.
Call is detected as forced to PSTN.
We clean and load peer preferences.
When we set outbound peer_auth* values, the $xavp(callee_prefs)
still contains values from B (instead of peering preferences).

When we clean preferences for the callee peer, we only
clean "callee_peer_prefs" and not "callee_prefs".
"callee_prefs" are clean only in case of 'usr' or 'dom'
preferences.

This patch try to fix this problem in order to fix this
scenario with outbound user authentication.

Change-Id: I76dfa6f9e074b3d83ac67bd818e59233ca50492c
(cherry picked from commit 8cdd63731b)
mr8.5.11
Daniel Grotti 2 years ago
parent d951075204
commit f7d7bcafe2

@ -19,6 +19,7 @@
--
local utils = require 'ngcp.utils'
local NGCPPrefs = require 'ngcp.pref'
local NGCPXAvp = require 'ngcp.xavp'
-- class NGCPPeerPrefs
local NGCPPeerPrefs = utils.inheritsFrom(NGCPPrefs)
@ -36,5 +37,15 @@ function NGCPPeerPrefs:new(config)
return instance
end
function NGCPPeerPrefs:clean(vtype)
NGCPPrefs.clean(self, vtype)
if not vtype then
NGCPXAvp:new('callee', 'prefs'):clean()
NGCPXAvp:new('caller', 'prefs'):clean()
else
NGCPXAvp:new(vtype, 'prefs'):clean()
end
end
-- class
return NGCPPeerPrefs

@ -22,7 +22,7 @@ local lemock = require('lemock')
local utils = require 'ngcp.utils'
local utable = utils.table
local PPFetch = require 'tests_v.pp_vars'
local NGCPXAvp = require 'ngcp.xavp'
local ksrMock = require 'mocks.ksr'
KSR = ksrMock.new()
@ -228,6 +228,24 @@ TestNGCPPeerPrefs = {} --class
lu.assertEquals(KSR.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
end
function TestNGCPPeerPrefs:test_clean_prefs()
local xavp_pref = NGCPXAvp:new('callee', 'prefs')
local xavp = NGCPPeerPrefs:xavp('callee')
xavp("testid",1)
xavp("foo","foo")
xavp_pref("two",2)
lu.assertEquals(KSR.pv.get("$xavp(callee_prefs=>two)"),2)
lu.assertEquals(KSR.pv.get("$xavp(callee_peer_prefs=>testid)"),1)
lu.assertEquals(KSR.pv.get("$xavp(callee_peer_prefs=>foo)"),"foo")
lu.assertEquals(KSR.pv.get("$xavp(caller_peer_prefs=>dummy)"),"caller")
lu.assertEquals(KSR.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
self.d:clean('callee')
lu.assertEquals(KSR.pv.get("$xavp(caller_peer_prefs=>dummy)"),"caller")
lu.assertEquals(KSR.pv.get("$xavp(callee_peer_prefs=>dummy)"),"callee")
lu.assertNil(KSR.pv.get("$xavp(peer)"))
lu.assertEquals(KSR.pv.get("$xavp(callee_prefs=>dummy)"), "callee")
end
function TestNGCPPeerPrefs:test_tostring()
local callee_xavp = NGCPPeerPrefs:xavp('callee')
callee_xavp("testid",1)

Loading…
Cancel
Save