testing

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DKIMSummary

type DKIMSummary struct {
	Signed    bool      `json:"signed"`
	Verified  bool      `json:"verified"`
	Selector  string    `json:"selector"`
	KeySize   int       `json:"key_size"`
	Algorithm string    `json:"algorithm"`
	ValidFrom time.Time `json:"valid_from"`
	Error     string    `json:"error,omitempty"`
}

DKIMSummary contains DKIM verification results

type DMARCSummary

type DMARCSummary struct {
	Result    string `json:"result"`
	Policy    string `json:"policy"`
	Aligned   bool   `json:"aligned"`
	Alignment string `json:"alignment"`
	Pct       int    `json:"pct"`
	Error     string `json:"error,omitempty"`
}

DMARCSummary contains DMARC verification results

type ReputationScore

type ReputationScore struct {
	Score         int     `json:"score"`
	DeliveryRate  float64 `json:"delivery_rate"`
	BounceRate    float64 `json:"bounce_rate"`
	ComplaintRate float64 `json:"complaint_rate"`
	Status        string  `json:"status"`
}

ReputationScore contains reputation information

type SPFSummary

type SPFSummary struct {
	Result  string `json:"result"`
	Record  string `json:"record"`
	IPRange string `json:"ip_range"`
	Aligned bool   `json:"aligned"`
	Error   string `json:"error,omitempty"`
}

SPFSummary contains SPF verification results

type SecuritySummary

type SecuritySummary struct {
	DKIM          DKIMSummary     `json:"dkim"`
	SPF           SPFSummary      `json:"spf"`
	DMARC         DMARCSummary    `json:"dmarc"`
	Reputation    ReputationScore `json:"reputation"`
	OverallStatus string          `json:"overall_status"`
}

SecuritySummary contains security verification results

type TestConfig

type TestConfig struct {
	// Server configuration
	SMTPAddr     string `yaml:"smtp_addr" json:"smtp_addr"`
	IMAPAddr     string `yaml:"imap_addr" json:"imap_addr"`
	HTTPAddr     string `yaml:"http_addr" json:"http_addr"`
	DatabasePath string `yaml:"database_path" json:"database_path"`

	// Test settings
	Timeout time.Duration `yaml:"timeout" json:"timeout"`
	Verbose bool          `yaml:"verbose" json:"verbose"`
	Debug   bool          `yaml:"debug" json:"debug"`

	// Authentication
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`

	// Security settings
	VerifyDKIM  bool `yaml:"verify_dkim" json:"verify_dkim"`
	VerifySPF   bool `yaml:"verify_spf" json:"verify_spf"`
	VerifyDMARC bool `yaml:"verify_dmarc" json:"verify_dmarc"`

	// Report settings
	OutputDir  string `yaml:"output_dir" json:"output_dir"`
	HTMLReport bool   `yaml:"html_report" json:"html_report"`
	JSONReport bool   `yaml:"json_report" json:"json_report"`

	// Advanced settings
	MaxRetries int           `yaml:"max_retries" json:"max_retries"`
	RetryDelay time.Duration `yaml:"retry_delay" json:"retry_delay"`
}

TestConfig holds configuration for test execution

func DefaultTestConfig

func DefaultTestConfig() TestConfig

DefaultTestConfig returns a default test configuration

type TestResult

type TestResult struct {
	ID          string        `json:"id"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Passed      bool          `json:"passed"`
	StartTime   time.Time     `json:"start_time"`
	EndTime     time.Time     `json:"end_time"`
	Duration    time.Duration `json:"duration"`
	Trace       []TraceEvent  `json:"trace"`
	Errors      []error       `json:"errors"`
	Summary     string        `json:"summary"`
}

TestResult represents the result of a test execution

func NewTestResult

func NewTestResult(name, description string) *TestResult

NewTestResult creates a new test result

func (*TestResult) AddError

func (r *TestResult) AddError(err error)

AddError adds an error to the test result

func (*TestResult) AddTrace

func (r *TestResult) AddTrace(event TraceEvent)

AddTrace adds a trace event to the result

func (*TestResult) Complete

func (r *TestResult) Complete(passed bool, summary string)

Complete marks the test result as completed

type TestRunner

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

TestRunner orchestrates test execution

func NewTestRunner

func NewTestRunner(config TestConfig) *TestRunner

NewTestRunner creates a new test runner

func (*TestRunner) Close

func (r *TestRunner) Close() error

Close closes the test runner and cleans up resources

func (*TestRunner) Config

func (r *TestRunner) Config() TestConfig

Config returns the test configuration

func (*TestRunner) FetchLatestMessage

func (r *TestRunner) FetchLatestMessage() (*imap.Message, error)

FetchLatestMessage is a convenience method for fetching the latest IMAP message

func (*TestRunner) IMAPClient

func (r *TestRunner) IMAPClient() *client.Client

IMAPClient returns the IMAP client for test scenarios

func (*TestRunner) Run

func (r *TestRunner) Run(ctx context.Context, scenario TestScenario) (*TestResult, error)

Run executes a test scenario

func (*TestRunner) SMTPClient

func (r *TestRunner) SMTPClient() *smtp.Client

SMTPClient returns the SMTP client for test scenarios

func (*TestRunner) SendEmail

func (r *TestRunner) SendEmail(from, to, subject, body string) error

SendEmail is a convenience method for sending email via SMTP

func (*TestRunner) Tracer

func (r *TestRunner) Tracer() *TraceCollector

Tracer returns the trace collector

func (*TestRunner) WaitForMessage

func (r *TestRunner) WaitForMessage(timeout time.Duration) (*imap.Message, error)

WaitForMessage waits for a message to arrive in the mailbox

type TestScenario

type TestScenario interface {
	// Name returns the scenario name
	Name() string

	// Description returns a description of the scenario
	Description() string

	// Setup prepares the scenario for execution
	Setup(ctx context.Context) error

	// Execute runs the main scenario logic
	Execute(ctx context.Context) error

	// Verify checks that the scenario executed correctly
	Verify(ctx context.Context) error

	// Cleanup cleans up after the scenario
	Cleanup(ctx context.Context) error
}

TestScenario defines the interface for test scenarios

type TraceCollector

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

TraceCollector collects and manages trace events during test execution

func NewTraceCollector

func NewTraceCollector() *TraceCollector

NewTraceCollector creates a new trace collector

func (*TraceCollector) AddEvent

func (tc *TraceCollector) AddEvent(event TraceEvent)

AddEvent adds a trace event manually

func (*TraceCollector) Clear

func (tc *TraceCollector) Clear()

Clear clears all trace events

func (*TraceCollector) Count

func (tc *TraceCollector) Count() int

Count returns the number of trace events

func (*TraceCollector) Events

func (tc *TraceCollector) Events() []TraceEvent

Events returns all collected trace events

func (*TraceCollector) FilterByComponent

func (tc *TraceCollector) FilterByComponent(component string) []TraceEvent

FilterByComponent returns events filtered by component

func (*TraceCollector) FilterByPhase

func (tc *TraceCollector) FilterByPhase(phase string) []TraceEvent

FilterByPhase returns events filtered by phase

func (*TraceCollector) FilterByStatus

func (tc *TraceCollector) FilterByStatus(status string) []TraceEvent

FilterByStatus returns events filtered by status

func (*TraceCollector) Start

func (tc *TraceCollector) Start(phase string) *TraceSpan

Start begins tracing for a specific phase/component/action

func (*TraceCollector) StartWithComponent

func (tc *TraceCollector) StartWithComponent(phase, component string) *TraceSpan

StartWithComponent begins tracing with component specified

func (*TraceCollector) StartWithDetails

func (tc *TraceCollector) StartWithDetails(phase, component, action string) *TraceSpan

StartWithDetails begins tracing with full details

type TraceEvent

type TraceEvent struct {
	Timestamp time.Time              `json:"timestamp"`
	Phase     string                 `json:"phase"`
	Component string                 `json:"component"`
	Action    string                 `json:"action"`
	Duration  time.Duration          `json:"duration"`
	Status    string                 `json:"status"`
	Details   map[string]interface{} `json:"details,omitempty"`
	Error     string                 `json:"error,omitempty"`
}

TraceEvent represents a single trace event

type TraceSpan

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

TraceSpan represents an active trace span

func (*TraceSpan) Action

func (ts *TraceSpan) Action() string

Action returns the action of this span

func (*TraceSpan) Component

func (ts *TraceSpan) Component() string

Component returns the component of this span

func (*TraceSpan) Details

func (ts *TraceSpan) Details() map[string]interface{}

Details returns the details of this span

func (*TraceSpan) Duration

func (ts *TraceSpan) Duration() time.Duration

Duration returns the duration of this span (if finished)

func (*TraceSpan) End

func (ts *TraceSpan) End()

End completes this trace span with success status

func (*TraceSpan) EndWithError

func (ts *TraceSpan) EndWithError(err error)

EndWithError completes this trace span with error status

func (*TraceSpan) EndWithStatus

func (ts *TraceSpan) EndWithStatus(status string, err error)

EndWithStatus completes this trace span with specified status

func (*TraceSpan) IsFinished

func (ts *TraceSpan) IsFinished() bool

IsFinished returns whether this span is finished

func (*TraceSpan) Phase

func (ts *TraceSpan) Phase() string

Phase returns the phase of this span

func (*TraceSpan) WithAction

func (ts *TraceSpan) WithAction(action string) *TraceSpan

WithAction sets the action for this span

func (*TraceSpan) WithComponent

func (ts *TraceSpan) WithComponent(component string) *TraceSpan

WithComponent sets the component for this span

func (*TraceSpan) WithDetail

func (ts *TraceSpan) WithDetail(key string, value interface{}) *TraceSpan

WithDetail adds a single detail to this span

func (*TraceSpan) WithDetails

func (ts *TraceSpan) WithDetails(details map[string]interface{}) *TraceSpan

WithDetails adds details to this span

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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