ncouture / MockSSH

Mock an SSH server and define all commands it supports (Python, Twisted)
Other
123 stars 22 forks source link

Packaging for PyPi #2

Open ayoshi opened 10 years ago

ayoshi commented 10 years ago

Hi.

Love the idea, could you please package it for pypi?

If you want an easy way, this tool could help:

https://github.com/Infinidat/infi.projector

ncouture commented 10 years ago

This is not really production quality software, there are no unit tests and it has mostly been a toy project for me to play around and tests different ways to emulate SSH and commands so far.

What would be the advantage of having it in pypi?

ayoshi commented 10 years ago

Well, I think having a way to mock SSH is helpful in building software for devops, mostly collection of data using ssh. It could, of course be mocked bypassing SSH entirely, but having a way to do it fast and from the code has a lot of value. Look, for example, at what fabric had to go through:

https://github.com/fabric/fabric/issues/185
https://github.com/fabric/fabric/issues/275

The only other available approach is build custom servers using paramiko.

There is also a library which does similar stuff:

https://github.com/simon-engledew/sshim

But your API , IMHO, is much much better.

ncouture commented 10 years ago

Testing SSH seems to be a problem shared by the unit tests of a set of networking libraries.

Looking at the referenced fabric tickets (https://github.com/fabric/fabric/issues/185 https://github.com/fabric/fabric/issues/275) I am also in favor programmatically spawning and defining SSH servers and supported commands from the unit tests during their execution over suggested alternatives.

The related fabric tickets reveals a few features they had to implement in their solution:

  1. SSH key forwarding (ssh-agent/SSH_AUTH_SOCK related?)
  2. Using ssh_config configuration files
  3. Changing the default ssh password prompt

Are these features that would be needed in MockSSH as well?

The reason I am asking this is that I would still like to know more about your personal interest in this issue is before considering packaging something that has no unit tests.

Do you think it would be possible to implement good unit test coverage of MockSSH (sshim has unit tests)?

Currently MockSSH supports:

Before packaging MockSSH I would like to:

Where are fabric's current ssh unit tests so we can have a look at what their current solution looks like?

self ~ $ git clone http://github.com/fabric/fabric
Cloning into 'fabric'...
remote: Reusing existing pack: 15313, done.
remote: Total 15313 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (15313/15313), 7.03 MiB | 697.00 KiB/s, done.
Resolving deltas: 100% (8854/8854), done.
Checking connectivity... done.
self ~ $ grep -lir 'import ssh|from ssh|paramiko' fabric/
self ~ $ 

Thanks for pointing to https://github.com/simon-engledew/sshim, it's interesting to compare projects with common goals.

ayoshi commented 10 years ago

Hi.

I'm not a contributor to fabric - so I'm not familiar with their codebase, but the mock ssh implementation is here:

cd fabric/tests
tests❯ grep -i SSH server.py                                                                                                       fabric/git/master
from fabric.network import disconnect_all, ssh
class TestServer(ssh.ServerInterface):
    Test server implementing the 'ssh' lib's server interface parent class.
    Mostly just handles the bare minimum necessary to handle SSH-level things
    ``serve_responses`` function and its ``SSHHandler`` class.
            return ssh.OPEN_SUCCEEDED
        return ssh.OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
        return ssh.AUTH_SUCCESSFUL if passed else ssh.AUTH_FAILED
        return ssh.AUTH_SUCCESSFUL if self.pubkeys else ssh.AUTH_FAILED

As to my personal interest - I require only the ability to fire up an instance, pass it to paramiko, and define output as per input. Personally, for me what you already have would suffice fully.

Hopefully, your project would be useful to more people though - I see someone from Rackspace starring it, so maybe they've looked for something similar.

ncouture commented 10 years ago

Created:

It's Friday night and I'm using Emoji on github :crying_cat_face:

ncouture commented 9 years ago

https://pypi.python.org/pypi/MockSSH/1.3

ayoshi commented 9 years ago

Thank you!

I hope it will become popular, it's already popular with me :) On Aug 5, 2014 7:11 AM, "Nicolas Couture" notifications@github.com wrote:

https://pypi.python.org/pypi/MockSSH/1.3

— Reply to this email directly or view it on GitHub https://github.com/ncouture/MockSSH/issues/2#issuecomment-51150655.