Skip to content

Commit

Permalink
Merge pull request #46 from SIPp/proxyaddr_fix
Browse files Browse the repository at this point in the history
Proxyaddr fix
  • Loading branch information
goodboy authored Jul 4, 2019
2 parents a3743ab + e2ef59b commit 36a9b63
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pysipp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def scenario(dirpath=None, proxyaddr=None, autolocalsocks=True,
scenkwargs=scenkwargs
)

if proxyaddr:
assert isinstance(
proxyaddr, tuple), 'proxyaddr must be a (addr, port) tuple'
scen.clientdefaults.proxyaddr = proxyaddr
if proxyaddr:
assert isinstance(
proxyaddr, tuple), 'proxyaddr must be a (addr, port) tuple'
scen.clientdefaults.proxyaddr = proxyaddr

return scen

Expand Down
4 changes: 2 additions & 2 deletions pysipp/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ def merge(dicts):
# apply defaults
ordered = [self._defaults, secondary, agent.todict()]
for name, defs in zip(['defaults', dname, 'agent.todict()'], ordered):
log.debug("'{}' contents:\n{}".format(name, defs))
log.debug("{} '{}' contents:\n{}".format(agent.name, name, defs))

params = merge(ordered)
log.debug("merged contents:\n{}".format(params))
log.debug("{} merged contents:\n{}".format(agent.name, params))
ua = UserAgent(defaults=params)

ua.enable_logging(enable_screen_file=self.enable_screen_file)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
url='https://github.com/SIPp/pysipp',
platforms=['linux'],
packages=['pysipp', 'pysipp.cli'],
install_requires=['pluggy==0.3.1'],
install_requires=['pluggy==0.11.0'],
tests_require=['pytest'],
entry_points={
'console_scripts': [
Expand Down
19 changes: 19 additions & 0 deletions tests/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ def test_confpy_hooks(scendir):
assert agent.uri_username == 'doggy'


def test_proxyaddr_with_scendir(scendir):
"""When building a scenario from a xml file directory the
`proxyaddr` kwarg should be assigned.
"""
remoteaddr = ('9.9.9.9', 80)
scen = pysipp.scenario(
dirpath=scendir + '/default_with_confpy',
proxyaddr=remoteaddr
)

assert scen.clientdefaults.proxyaddr == remoteaddr
for name, cmd in scen.cmditems():
if name == 'uac':
assert "-rsa '{}':'{}'".format(*remoteaddr) in cmd
assert "'{}':'{}'".format(*scen.clientdefaults.destaddr) in cmd
elif name == 'uas':
assert "-rsa '{}':'{}'".format(*remoteaddr) not in cmd


def test_sync_run(scenwalk):
"""Ensure all scenarios in the test run to completion in synchronous mode
"""
Expand Down

0 comments on commit 36a9b63

Please sign in to comment.