Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feedback needed, WIP] Add tests #412

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

CapacitorSet
Copy link
Contributor

@CapacitorSet CapacitorSet commented Aug 9, 2018

As the title says - I was on a long plane trip, so I figured I'd try and spend my time implementing tests. Note that they launch the Honeytrap binary, since getting it to work with honeytrap.New() was too much of a pain in the ass - most importantly, it seems impossible to tell the Honeytrap goroutine to shut down, even after messing with server/honeytrap.go.

Anyways, I developed some quick general tests (test that it starts with a dummy config, --help, the various --list), and service-specific tests for HTTP and Redis (http.Client/net.Dial + nmap checks). Before proceeding to write more tests, I'd like to know what you think of the overall test setup and what changes you suggest.

I'd also like ideas on how to test events (eg. "test that when you make a valid http request, an event is sent"). I thought of the following:

  • Making Honeytrap write the events to stdout ([filter.console] type="console"), and have the test application read that. This seems to be outright impossible, given how the Honeytrap binary is launched - you can connect stdout to an os.File, not a custom io.Writer, which prevents us from reading stdout directly; and reading it from an actual file seems impractical.
  • Making Honeytrap push the events to RabbitMQ, and receiving them in the test application. This is rather straightforward, but it requires RabbitMQ to be installed on the developer's machine, which is not optimal.
  • Creating a new pusher specifically for IPC (maybe marking it "for internal usage only") and using that. Also straightforward, but I'm not excited about adding features just for tests.
  • Do not spawn a new Honeytrap process; rather, create a new service (eg. http := services.HTTP(options); http.Handle(...)) and pass it a mock net.Conn. This is in my opinion the most interesting idea, but I'm afraid it would make tests depend too much on the implementation details (SetChannel, pass a TOML config, essentially make a second implementation of findService, ...) which are instead hidden when launching a process.

Depends on #411, which I discovered while writing the tests; fixes #239.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test ipv6 support
1 participant