test

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package test contains end-to-end integration tests for the mirage AiTM proxy. Tests start a real daemon in-process (real TLS, real SQLite, real pipeline) against a controllable fake upstream, then assert on session state via the SDK client. No subprocess, no Docker, no browser required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrainAndClose

func DrainAndClose(resp *http.Response)

DrainAndClose reads the response body and closes it.

Types

type Harness

type Harness struct {
	// Upstream is the fake target website. Tests register handlers on its Mux.
	Upstream    *httptest.Server
	UpstreamMux *http.ServeMux

	// Victim simulates a phishing victim's browser.
	// It trusts the proxy CA, dials the proxy directly, and holds a cookie jar.
	Victim *http.Client

	// API is the management SDK client, authenticated via mTLS.
	API *sdk.Client

	// PhishHost is the phishing hostname tests should send requests to.
	PhishHost string

	// ProxyAddr is the TCP address of the running proxy (e.g. "127.0.0.1:PORT").
	ProxyAddr string
	// contains filtered or unexported fields
}

Harness is a fully-wired test environment. Obtain one via NewHarness.

func NewHarness

func NewHarness(t *testing.T) *Harness

NewHarness starts a full daemon and returns a configured Harness. All resources are cleaned up automatically via t.Cleanup.

func (*Harness) EnrollClient added in v0.5.0

func (h *Harness) EnrollClient() *http.Client

EnrollClient returns an unauthenticated HTTPS client that dials the proxy directly. Used for testing the operator enrollment endpoint.

func (*Harness) EnrollURL added in v0.5.0

func (h *Harness) EnrollURL() string

EnrollURL returns the full URL for the enrollment endpoint.

func (*Harness) VictimGet

func (h *Harness) VictimGet(t *testing.T, path string) *http.Response

VictimGet sends a GET request from the victim client to the given path on the phishing hostname. Returns the response; the caller must close the body.

func (*Harness) VictimPost

func (h *Harness) VictimPost(t *testing.T, path, body string) *http.Response

VictimPost sends a POST request with application/x-www-form-urlencoded body.

func (*Harness) VictimPostJSON

func (h *Harness) VictimPostJSON(t *testing.T, path, body string) *http.Response

VictimPostJSON sends a POST request with application/json body.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL