proxy

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package proxy provides a reverse proxy that captures real AWS traffic for later replay against CloudMock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSProxy

type AWSProxy struct {
	// contains filtered or unexported fields
}

AWSProxy is a reverse proxy that forwards requests to real AWS endpoints and captures the request/response pairs as CapturedEntry values.

func New

func New(region string) *AWSProxy

New creates a new AWSProxy targeting the given AWS region.

func (*AWSProxy) Entries

func (p *AWSProxy) Entries() []*traffic.CapturedEntry

Entries returns a copy of the captured entries.

func (*AWSProxy) Recording

func (p *AWSProxy) Recording() *traffic.Recording

Recording converts the captured entries into a traffic.Recording.

func (*AWSProxy) SaveToFile

func (p *AWSProxy) SaveToFile(path string) error

SaveToFile marshals the recording to JSON and writes it to the given path.

func (*AWSProxy) ServeHTTP

func (p *AWSProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles an incoming AWS SDK request by detecting the target service, forwarding the request to the real AWS endpoint, and capturing the exchange.

type ContractProxy

type ContractProxy struct {
	// contains filtered or unexported fields
}

ContractProxy is a dual-mode proxy that sends each incoming request to both real AWS and a local CloudMock instance, compares the responses, and returns the real AWS response to the caller. The comparison results are stored for later report generation.

func NewContractProxy

func NewContractProxy(region string, cloudmockEndpoint string, ignorePaths []string) *ContractProxy

NewContractProxy creates a ContractProxy that forwards to real AWS via AWSProxy and simultaneously to the given CloudMock endpoint.

func (*ContractProxy) Report

func (cp *ContractProxy) Report() *ContractReport

Report generates a ContractReport summarising the contract test run.

func (*ContractProxy) Results

func (cp *ContractProxy) Results() []*ContractResult

Results returns a copy of all contract comparison results.

func (*ContractProxy) SaveReport

func (cp *ContractProxy) SaveReport(path string) error

SaveReport writes the contract report as JSON to the given file path.

func (*ContractProxy) ServeHTTP

func (cp *ContractProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles an incoming request by sending it to both real AWS and CloudMock concurrently, comparing the responses, and returning the real AWS response to the caller.

type ContractReport

type ContractReport struct {
	StartedAt        string                    `json:"started_at"`
	DurationSec      float64                   `json:"duration_sec"`
	TotalRequests    int                       `json:"total_requests"`
	Matched          int                       `json:"matched"`
	Mismatched       int                       `json:"mismatched"`
	CompatibilityPct float64                   `json:"compatibility_pct"`
	ByService        map[string]*ServiceReport `json:"by_service"`
	Mismatches       []MismatchEntry           `json:"mismatches"`
}

ContractReport is the JSON-serialisable summary of a contract test run.

type ContractResult

type ContractResult struct {
	Timestamp       time.Time
	Service         string
	Action          string
	Method          string
	Path            string
	AWSStatus       int
	AWSBody         []byte
	CloudMockStatus int
	CloudMockBody   []byte
	Match           bool
	Diffs           []string
	Severity        string
	LatencyAWS      time.Duration
	LatencyCM       time.Duration
}

ContractResult holds the comparison outcome for a single request pair.

type MismatchEntry

type MismatchEntry struct {
	Service         string   `json:"service"`
	Action          string   `json:"action"`
	AWSStatus       int      `json:"aws_status"`
	CloudMockStatus int      `json:"cloudmock_status"`
	Diffs           []string `json:"diffs"`
	Severity        string   `json:"severity"`
}

MismatchEntry is a single mismatched request in the report.

type ServiceReport

type ServiceReport struct {
	Total   int     `json:"total"`
	Matched int     `json:"matched"`
	Pct     float64 `json:"pct"`
}

ServiceReport provides per-service match statistics.

Jump to

Keyboard shortcuts

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