-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38a4cbe
commit d9cb702
Showing
6 changed files
with
49 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from paramiko import MissingHostKeyPolicy, SSHClient, PKey | ||
|
||
class CustomMissingKeyPolicy(MissingHostKeyPolicy): | ||
def missing_host_key(self, client: SSHClient, hostname: str, key: PKey) -> None: | ||
client.get_host_keys().add(hostname, key.get_name(), key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,37 @@ | ||
import logging | ||
import os | ||
import sys | ||
from typing import TextIO, Tuple | ||
|
||
sys.path.append(os.path.abspath("../")) | ||
|
||
from pathlib import Path | ||
|
||
from insightconnect_plugin_runtime.action import Action | ||
from komand_ssh.connection.connection import Connection | ||
from komand_ssh.connection.schema import Input | ||
|
||
STUB_CONNECTION = { | ||
Input.HOST: "0.0.0.0", | ||
Input.PORT: "22", | ||
Input.KEY: {}, | ||
Input.USE_KEY: False, | ||
Input.PASSWORD: {"secretKey": "ABC"}, | ||
Input.USERNAME: "username", | ||
} | ||
|
||
|
||
class Util: | ||
@staticmethod | ||
def default_connector(): | ||
connection = Connection() | ||
params = { | ||
Input.HOST: "0.0.0.0", | ||
Input.PORT: "22", | ||
Input.KEY: {}, | ||
Input.USE_KEY: False, | ||
Input.PASSWORD: {"secretKey": "ABC"}, | ||
Input.USERNAME: "username", | ||
} | ||
connection.logger = logging.getLogger("action logger") | ||
connection.parameters = params | ||
return connection | ||
def default_connector(action: Action) -> Action: | ||
default_connection = Connection() | ||
default_connection.logger = logging.getLogger("connection logger") | ||
default_connection.connect(STUB_CONNECTION) | ||
action.connection = default_connection | ||
action.logger = logging.getLogger("action logger") | ||
return action | ||
|
||
@staticmethod | ||
def mock_execute_command() -> Tuple[TextIO, TextIO, TextIO]: | ||
file_ = open(Path(__file__).parent / "responses" / "results.txt", "r") | ||
return file_, file_, file_ |