Tests and the TestPlatform framework

UML Diagram:


High-Level Description:

The entire testing framework is based on the Strategy design pattern (https://en.wikipedia.org/wiki/Strategy_pattern).

All tests must extend from the Test interface. This way they all respect the same structure, provide results according to a certain pattern, have a description, have a name, etc. Their run() method, however, can be implemented how the test’s author decides. This is where the Strategy pattern comes in, interfacing/connecting all different implementations to a common, easy to understand, framework.

In order to run tests, a TestPlatform instance is needed. The TestPlatform takes in a list of tests, does all initializations, runs the tests (calls their run() methods) and provides the results and stats. This is possible because all tests must implement the same interface and thus all have the behavior expected by the TestPlatform.

Tests are very modular. All you must do to run a series of tests is to instantiate them and provide them along with the target Honeypot to a TestPlatform instance. Adding new tests will thus be very easy as the framework is already implemented and you only need to override the run() method and enroll the Test in the list provided to the TestPlatform.

The Honeypot class is the source of all data associated with a target: IP address, open ports, website, banners, etc. This way there can be no data dependency between tests. For example, there can be many Test classes that need the website of the target system. The first Test requests this data from the Honeypot class through the self.target_honeypot reference. The Honeypot class then fetches and caches the website. Afterward, it offers the cached version to all tests who request it in the future.

The Honeypot class is also meant to provide a common interface for gathering data, hiding the underlying implementation details. This way, if some of the libraries/algorithms used for fetching this data need to be changed, all modifications will happen exclusively inside the Honeypot class without affecting the tests.