Mock Aerohive

A mock SSH server emulating Aerohive devices.


pip install mock-aerohive

Basic usage:

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 ="")
# Or provide a port:"", 2222)

# Now you can SSH in:
# ssh admin@ -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), see test/util/, and test/integration/auth/ for an example.

Some Aerohive commands have been created, for instance, hostname:

ssh admin@ -p 2222
admin@'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
Connection to closed.

PyUnit Fixture

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 ="")

  # Now you can SSH into the server
  # ...


Calling 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.

Indices and tables