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 ¶
- func DrainAndClose(resp *http.Response)
- type Harness
- func (h *Harness) EnrollClient() *http.Client
- func (h *Harness) EnrollURL() string
- func (h *Harness) VictimGet(t *testing.T, path string) *http.Response
- func (h *Harness) VictimPost(t *testing.T, path, body string) *http.Response
- func (h *Harness) VictimPostJSON(t *testing.T, path, body string) *http.Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrainAndClose ¶
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 ¶
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
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
EnrollURL returns the full URL for the enrollment endpoint.
func (*Harness) VictimGet ¶
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 ¶
VictimPost sends a POST request with application/x-www-form-urlencoded body.