demo

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package demo is a dev-only, in-memory stand-in for a mail server and its DNS zone, so the Mail page can be exercised without a container, provider or domain.

Index

Constants

View Source
const (
	// DevModeEnv is the existing dev gate.
	DevModeEnv = "APP_DEV_MODE"
	// EnableEnv is the extra opt-in.
	EnableEnv = "APP_MAIL_DEMO"

	// DefaultDomain is used when the caller types no domain.
	DefaultDomain = "demo.example"
	// AppName is the fake mail app every demo request resolves to.
	AppName = "mail-demo"
	// ProviderName labels the fake zone provider in responses and audit rows.
	ProviderName = "demo"
	// FakeMarker is a placeholder that is not a credential for anything.
	FakeMarker = "demo-not-a-real-value"
	// DKIMSelector is the demo signing selector.
	DKIMSelector = "demo2026"
	// MailIPv4 is a documentation address (RFC 5737), never routable.
	MailIPv4 = "203.0.113.10"
)

Variables

This section is empty.

Functions

func DKIMPublicKey

func DKIMPublicKey() string

DKIMPublicKey is a throwaway public key made per process; its private half is discarded.

func Enabled

func Enabled(devMode bool, getenv func(string) string) (on, ignored bool)

Enabled reports whether demo mode is on. It needs both the dev gate and the opt-in; ignored is true when the opt-in is set without the dev gate.

func EnabledFromEnv

func EnabledFromEnv(devMode bool) (on, ignored bool)

EnabledFromEnv is Enabled over the process environment.

Types

type Engine

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

Engine is an in-memory mail.Engine seeded with fixtures. It makes no network or filesystem call, so nothing it holds can reach a real server.

func NewEngine

func NewEngine() *Engine

NewEngine returns an engine with two domains, five mailboxes, aliases and a queue.

func (*Engine) AccountDetail

func (e *Engine) AccountDetail(_ context.Context, name string) (mail.AccountDetail, error)

AccountDetail implements mail.Engine.

func (*Engine) Accounts

func (e *Engine) Accounts(context.Context) ([]mail.Account, error)

Accounts implements mail.Engine.

func (*Engine) AddAccount

func (e *Engine) AddAccount(_ context.Context, a mail.AccountSpec) error

AddAccount implements mail.Engine.

func (*Engine) AddAddress

func (e *Engine) AddAddress(_ context.Context, address, acct string) error

AddAddress implements mail.Engine.

func (*Engine) AddAlias

func (e *Engine) AddAlias(_ context.Context, a mail.Alias) error

AddAlias implements mail.Engine.

func (*Engine) AddDomain

func (e *Engine) AddDomain(_ context.Context, d mail.DomainSpec) error

AddDomain implements mail.Engine.

func (*Engine) Aliases

func (e *Engine) Aliases(_ context.Context, domain string) ([]mail.Alias, error)

Aliases implements mail.Engine.

func (*Engine) DKIMKeys

func (e *Engine) DKIMKeys(_ context.Context, _ string) ([]mail.DKIMKey, error)

DKIMKeys implements mail.Engine.

func (*Engine) DNSRecords

func (e *Engine) DNSRecords(_ context.Context, domain string) ([]mail.DNSRecord, error)

DNSRecords implements mail.Engine.

func (*Engine) Domains

func (e *Engine) Domains(context.Context) ([]mail.Domain, error)

Domains implements mail.Engine.

func (*Engine) Health

func (e *Engine) Health(context.Context) error

Health implements mail.Engine.

func (*Engine) HoldMessages

func (e *Engine) HoldMessages(_ context.Context, ids []int64, hold bool) (int, error)

HoldMessages implements mail.Engine.

func (*Engine) HoldQueue

func (e *Engine) HoldQueue(context.Context) error

HoldQueue implements mail.Engine.

func (*Engine) QueueList

func (e *Engine) QueueList(_ context.Context, limit int) ([]mail.QueueEntry, error)

QueueList implements mail.Engine.

func (*Engine) QueueStats

func (e *Engine) QueueStats(context.Context) (mail.QueueStats, error)

QueueStats implements mail.Engine.

func (*Engine) ReleaseQueue

func (e *Engine) ReleaseQueue(context.Context) error

ReleaseQueue implements mail.Engine.

func (*Engine) RemoveAccount

func (e *Engine) RemoveAccount(_ context.Context, name string) error

RemoveAccount implements mail.Engine.

func (*Engine) RemoveAlias

func (e *Engine) RemoveAlias(_ context.Context, address string) error

RemoveAlias implements mail.Engine.

func (*Engine) RemoveDomain

func (e *Engine) RemoveDomain(_ context.Context, name string) error

RemoveDomain implements mail.Engine.

func (*Engine) SetLoginDisabled

func (e *Engine) SetLoginDisabled(_ context.Context, acct, message string) error

SetLoginDisabled implements mail.Engine.

func (*Engine) SetPassword

func (e *Engine) SetPassword(_ context.Context, acct, _ string) error

SetPassword implements mail.Engine.

func (*Engine) SetQuota

func (e *Engine) SetQuota(_ context.Context, acct string, _ mail.Quota) error

SetQuota implements mail.Engine.

type Zone

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

Zone is an in-memory DNS provider and resolver sharing one record store, so a record applied through it is what the check later resolves.

func NewZone

func NewZone() *Zone

NewZone returns an empty demo zone store.

func (*Zone) Capabilities

func (z *Zone) Capabilities() dnszones.Capabilities

Capabilities implements dnszones.Provider and the mailrecords resolver.

func (*Zone) CreateZone

func (z *Zone) CreateZone(_ context.Context, name string) (dnszones.Zone, error)

CreateZone implements dnszones.Provider and the mailrecords resolver.

func (*Zone) DeleteRecordSet

func (z *Zone) DeleteRecordSet(_ context.Context, zone dnszones.Zone, key dnszones.Key) error

DeleteRecordSet implements dnszones.Provider and the mailrecords resolver.

func (*Zone) DeleteZone

func (z *Zone) DeleteZone(_ context.Context, id string) error

DeleteZone implements dnszones.Provider and the mailrecords resolver.

func (*Zone) GetZone

func (z *Zone) GetZone(_ context.Context, id string) (dnszones.Zone, error)

GetZone implements dnszones.Provider and the mailrecords resolver.

func (*Zone) ListRecordSets

func (z *Zone) ListRecordSets(_ context.Context, zone dnszones.Zone) ([]dnszones.RecordSet, error)

ListRecordSets implements dnszones.Provider and the mailrecords resolver.

func (*Zone) ListZones

func (z *Zone) ListZones(context.Context) ([]dnszones.Zone, error)

ListZones implements dnszones.Provider and the mailrecords resolver.

func (*Zone) LookupAddr

func (z *Zone) LookupAddr(_ context.Context, addr string) ([]string, error)

LookupAddr plays the hosting provider's reverse DNS: any address the zone maps from a host name reverses to that name.

func (*Zone) LookupCNAME

func (z *Zone) LookupCNAME(_ context.Context, name string) (string, error)

LookupCNAME implements dnszones.Provider and the mailrecords resolver.

func (*Zone) LookupHost

func (z *Zone) LookupHost(_ context.Context, host string) ([]string, error)

LookupHost implements dnszones.Provider and the mailrecords resolver.

func (*Zone) LookupMX

func (z *Zone) LookupMX(_ context.Context, name string) ([]*net.MX, error)

LookupMX implements dnszones.Provider and the mailrecords resolver.

func (*Zone) LookupSRV

func (z *Zone) LookupSRV(context.Context, string, string, string) (string, []*net.SRV, error)

LookupSRV implements dnszones.Provider and the mailrecords resolver.

func (*Zone) LookupTXT

func (z *Zone) LookupTXT(_ context.Context, name string) ([]string, error)

LookupTXT implements dnszones.Provider and the mailrecords resolver.

func (*Zone) Name

func (z *Zone) Name() string

Name implements dnszones.Provider and the mailrecords resolver.

func (*Zone) Reset

func (z *Zone) Reset()

Reset forgets every applied record, so the checklist fails again.

func (*Zone) UpsertRecordSet

func (z *Zone) UpsertRecordSet(_ context.Context, zone dnszones.Zone, rs dnszones.RecordSet) error

UpsertRecordSet implements dnszones.Provider and the mailrecords resolver.

func (*Zone) ZoneFor

func (z *Zone) ZoneFor(domain string) dnszones.Zone

ZoneFor is the fake zone object for a domain.

Jump to

Keyboard shortcuts

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