A mock SSH server emulating Aerohive devices.
pip install mock-aerohive
from mock_aerohive import MockAerohive aerohive = MockAerohive() # You must add at least 1 user before starting the server! (Library limitation) aerohive.addUser("admin", "aerohive") port = aerohive.run("127.0.0.1") # Or provide a port: aerohive.run("127.0.0.1", 2222) # Now you can SSH in: # ssh firstname.lastname@example.org -p 2222 aerohive.stop() # Stop a single server. aerohive.stopAll() # Terminate the background thread running all SSH servers (otherwise the process will hang) # Once you stop the background thread, you may not start another server (with 'run') - # another library limitation.
For an example of a py.test fixture that automates starting and stopping servers
(which cleans up servers at the end of the testing session, but allows multiple servers to be run),
test/integration/auth/test_addUser_and_login.py for an example.
Some Aerohive commands have been created, for instance,
ssh email@example.com -p 2222 firstname.lastname@example.org's password: Aerohive Networks Inc. Copyright (C) 2006-2012 AH-2A0B00#hostname example-1 example-1#example-1#hostname example-2 invalid-extra-argument ^-- unknown keyword or invalid input example-1#exit Connection to 127.0.0.1 closed.
If you are using PyUnit, this package ships with a test fixture to automatically create and stop mock servers for each test.
First, import the fixture into your test file:
from mock_aerohive import MockAerohiveFixture as MockAerohive
(I like to rename the imported fixture
MockAerohive, but that’s a personal preference.)
Then, add a parameter to your PyUnit test:
def test_some_feature(MockAerohive): aerohive = MockAerohive() aerohive.addUser("admin", "aerohive") port = aerohive.run("127.0.0.1") # Now you can SSH into the server # ... aerohive.stop()
aerohive.stop() at the end of your test is optional.
The fixture will automatically clean up all servers once all tests are complete,
but you can stop each server if they might interfere with future tests.
This package uses semantic versioning.