Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Modify __init__() method and use new syntax for super().
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Nov 26, 2019
1 parent df3a46b commit c235b6b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Add solution method to solution of vt object. [#166](https://github.com/greenbone/ospd/pull/166)

### Changes
- Modify __init__() method and use new syntax for super(). [#186](https://github.com/greenbone/ospd/pull/186)

## [2.0.1] (unreleased)

### Added
Expand Down
9 changes: 3 additions & 6 deletions ospd/ospd_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,12 @@ class OSPDaemonSimpleSSH(OSPDaemon):
an array.
"""

def __init__(self, certfile, keyfile, cafile, niceness=None):
def __init__(self, **kwargs):
""" Initializes the daemon and add parameters needed to remote SSH
execution. """
super().__init__(**kwargs)

super(OSPDaemonSimpleSSH, self).__init__(
certfile=certfile, keyfile=keyfile, cafile=cafile, niceness=niceness
)

self._niceness = niceness
self._niceness = kwargs.get('niceness', None)

if paramiko is None:
raise ImportError(
Expand Down
16 changes: 11 additions & 5 deletions tests/test_ssh_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,22 @@ def AutoAddPolicy(): # pylint: disable=invalid-name
ssh_exception = FakeExceptions


class DummyWrapper(OSPDaemonSimpleSSH):
def __init__(self, niceness=10):
super().__init__(niceness=niceness)


class SSHDaemonTestCase(unittest.TestCase):
def test_no_paramiko(self):
ospd_ssh.paramiko = None

with self.assertRaises(ImportError):
OSPDaemonSimpleSSH('cert', 'key', 'ca', '10')
OSPDaemonSimpleSSH()

def test_run_command(self):
ospd_ssh.paramiko = fakeparamiko
daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca', '10')

daemon = DummyWrapper(niceness=10)
scanid = daemon.create_scan(
None,
[['host.example.com', '80, 443', '', '', '']],
Expand All @@ -96,7 +102,7 @@ def test_run_command(self):
def test_run_command_legacy_credential(self):
ospd_ssh.paramiko = fakeparamiko

daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca', '10')
daemon = DummyWrapper(niceness=10)
scanid = daemon.create_scan(
None,
[['host.example.com', '80, 443', '', '', '']],
Expand All @@ -112,7 +118,7 @@ def test_run_command_legacy_credential(self):
def test_run_command_new_credential(self):
ospd_ssh.paramiko = fakeparamiko

daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca', '10')
daemon = DummyWrapper(niceness=10)

cred_dict = {
'ssh': {
Expand All @@ -138,7 +144,7 @@ def test_run_command_new_credential(self):
def test_run_command_no_credential(self):
ospd_ssh.paramiko = fakeparamiko

daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca', '10')
daemon = DummyWrapper(niceness=10)
scanid = daemon.create_scan(
None,
[['host.example.com', '80, 443', '', '', '']],
Expand Down

0 comments on commit c235b6b

Please sign in to comment.