ssh-mock


Namessh-mock JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/DanielHabenicht/mock-ssh.git
SummaryMocks an SSH Server
upload_time2024-07-04 23:48:18
maintainerNone
docs_urlNone
authorDanielHabenicht
requires_python<4.0.0,>=3.8.1
licenseMIT
keywords ssh server mocking mock testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Mock SSH Server
-----------------

Simple SSH Mock Server for E2E testing purposes, e.g. with [Testcontainers](https://testcontainers.com/).

Installation
-----------

## Python

```bash
pip install ssh-mock
# Create commands.yml first
# Start Mock
ssh-mock
```

## Docker

See docker-compose.yml or run:

```bash
# Create commands.yml first
# Run Mock Server:
docker run --rm -p 5050:5050 -v ./commands.yml:/usr/src/app/commands.yml ghcr.io/danielhabenicht/mock-ssh:0.2.2
# Try it out
ssh localhost -p 5050
exec echo Hello World!
```

## YAML Configuration

```yaml	title=commands.yml
version: "3.7"
commands:
# Simple command
 - command: echo hello
   stdout: "Hello World!"
   returncode: 0
# Command matching regex
 - command: interface.*
   stdout: ""
# Return values from command via JINJA template
 - command: exec echo.*
   stdout_template: "{{command[9:]|trim|trim('''')|trim('\"')}}"
   returncode: 0
# Modify the Hostname
 - command: enable
   stdout: "Password"
   modify_host: HOST#
   returncode: 0
# Use multiple lines
 - command: show users
   stdout: "    Line       User       Host(s)              Idle       Location\n*  1 vty 0     rootuser   idle                 00:00:00\n                                                          example.test.de\n\n  Interface    User               Mode         Idle     Peer Address\n\n"
   returncode: 0
 - command: show interfaces description
   stdout: | 
    Interface                      Status         Protocol Description
    Vl1                            up             up
    Vl308                          up             up
    Gi1/0/1                        up             up       Access Port
    Gi1/0/12                       down           down     Access Port
    Gi1/1/1                        down           down
    Gi1/1/2                        down           down
    Te1/1/3                        down           down
    Te1/1/4                        up             up
```


## Thanks

This was initally a fork of [https://github.com/d1618033/fake-ssh](https://github.com/d1618033/fake-ssh). Thanks [David](https://github.com/d1618033) for your work!
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/DanielHabenicht/mock-ssh.git",
    "name": "ssh-mock",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.8.1",
    "maintainer_email": null,
    "keywords": "SSH, Server, Mocking, Mock, Testing",
    "author": "DanielHabenicht",
    "author_email": "daniel-habenicht@outlook.de",
    "download_url": "https://files.pythonhosted.org/packages/28/48/0b51b645c4d211e44a0f57699e95afe06231ef515d7199ad55ec4c7535af/ssh_mock-0.3.1.tar.gz",
    "platform": null,
    "description": "Mock SSH Server\n-----------------\n\nSimple SSH Mock Server for E2E testing purposes, e.g. with [Testcontainers](https://testcontainers.com/).\n\nInstallation\n-----------\n\n## Python\n\n```bash\npip install ssh-mock\n# Create commands.yml first\n# Start Mock\nssh-mock\n```\n\n## Docker\n\nSee docker-compose.yml or run:\n\n```bash\n# Create commands.yml first\n# Run Mock Server:\ndocker run --rm -p 5050:5050 -v ./commands.yml:/usr/src/app/commands.yml ghcr.io/danielhabenicht/mock-ssh:0.2.2\n# Try it out\nssh localhost -p 5050\nexec echo Hello World!\n```\n\n## YAML Configuration\n\n```yaml\ttitle=commands.yml\nversion: \"3.7\"\ncommands:\n# Simple command\n - command: echo hello\n   stdout: \"Hello World!\"\n   returncode: 0\n# Command matching regex\n - command: interface.*\n   stdout: \"\"\n# Return values from command via JINJA template\n - command: exec echo.*\n   stdout_template: \"{{command[9:]|trim|trim('''')|trim('\\\"')}}\"\n   returncode: 0\n# Modify the Hostname\n - command: enable\n   stdout: \"Password\"\n   modify_host: HOST#\n   returncode: 0\n# Use multiple lines\n - command: show users\n   stdout: \"    Line       User       Host(s)              Idle       Location\\n*  1 vty 0     rootuser   idle                 00:00:00\\n                                                          example.test.de\\n\\n  Interface    User               Mode         Idle     Peer Address\\n\\n\"\n   returncode: 0\n - command: show interfaces description\n   stdout: | \n    Interface                      Status         Protocol Description\n    Vl1                            up             up\n    Vl308                          up             up\n    Gi1/0/1                        up             up       Access Port\n    Gi1/0/12                       down           down     Access Port\n    Gi1/1/1                        down           down\n    Gi1/1/2                        down           down\n    Te1/1/3                        down           down\n    Te1/1/4                        up             up\n```\n\n\n## Thanks\n\nThis was initally a fork of [https://github.com/d1618033/fake-ssh](https://github.com/d1618033/fake-ssh). Thanks [David](https://github.com/d1618033) for your work!",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Mocks an SSH Server",
    "version": "0.3.1",
    "project_urls": {
        "Homepage": "https://github.com/DanielHabenicht/mock-ssh.git",
        "Repository": "https://github.com/DanielHabenicht/mock-ssh.git"
    },
    "split_keywords": [
        "ssh",
        " server",
        " mocking",
        " mock",
        " testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e46857cbd1e14f0b31d924023f5c32f636a7ae1fe27739acef4cfd106fc9b14",
                "md5": "670a91f65c72fd451a64b9599324417c",
                "sha256": "9517a06db876a030280edab191eb91d194d5cb89caf43f4787ef1f9fc0778e62"
            },
            "downloads": -1,
            "filename": "ssh_mock-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "670a91f65c72fd451a64b9599324417c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.8.1",
            "size": 9486,
            "upload_time": "2024-07-04T23:48:17",
            "upload_time_iso_8601": "2024-07-04T23:48:17.085481Z",
            "url": "https://files.pythonhosted.org/packages/6e/46/857cbd1e14f0b31d924023f5c32f636a7ae1fe27739acef4cfd106fc9b14/ssh_mock-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28480b51b645c4d211e44a0f57699e95afe06231ef515d7199ad55ec4c7535af",
                "md5": "d17e7880dabb192680270192e3f4b249",
                "sha256": "20d75d0cc5f59f3d2c9c8432af43d5db247060255e4380b4a625c04b0b9b550a"
            },
            "downloads": -1,
            "filename": "ssh_mock-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d17e7880dabb192680270192e3f4b249",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.8.1",
            "size": 8936,
            "upload_time": "2024-07-04T23:48:18",
            "upload_time_iso_8601": "2024-07-04T23:48:18.543951Z",
            "url": "https://files.pythonhosted.org/packages/28/48/0b51b645c4d211e44a0f57699e95afe06231ef515d7199ad55ec4c7535af/ssh_mock-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-04 23:48:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DanielHabenicht",
    "github_project": "mock-ssh",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ssh-mock"
}
        
Elapsed time: 0.28766s