smtp

package
v0.74.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

SMTP Endpoint Service

This service allows email message validation. Listen operation starts SMTP endpoint that places all incoming messages to validation queue. Assert operation validates mail messages.

Service Id Action Description Request Response
smtp/endpoint listen start accepting mails ListenRequest ListenResponse
smtp/endpoint assert perform validation on provided expected user message AssertRequest AssertResponse

Usage

endly -r=test.yaml

@test.yaml

pipeline:
  listen:
    action: smtp/endpoint:listen
    port: 1465
    enableTLS: true
    certLocation:
    users:
      - username: bob
        credentials: e2eendly

  send:
    action: smtp:send
    target:
      URL: smtp://localhost:1465
      credentials: e2eendly
    mail:
      from: tester@localhost
      to:
        - bob@localhost
      subject: test subject
      body: this is test body

  assert:
    action: smtp/endpoint:assert
    expect:
      - user: bob
        message:
          Subject: test subject2
          Body: /test body/

Using SSL/TLS

When enabling SSL/TLS for testing you can use the following command to generate self describing cert:

openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem

Documentation

Index

Constants

View Source
const ServiceID = "smtp/endpoint"

Variables

This section is empty.

Functions

func New

func New() endly.Service

New create a new SMTP endpoint service

Types

type AssertRequest

type AssertRequest struct {
	DescriptionTemplate string
	Expect              []*UserMessage `required:"true" description:"expected user messagesByUser"`
}

AssertRequest represents a log assert request

func (*AssertRequest) Init

func (r *AssertRequest) Init() error

type AssertResponse

type AssertResponse struct {
	Validations []*assertly.Validation
}

AssertResponse represents a smtp message assert response

func (*AssertResponse) Assertion

func (r *AssertResponse) Assertion() []*assertly.Validation

Assertion returns description with validation slice

type ListenRequest

type ListenRequest struct {
	ServerName   string
	Port         int
	EnableTLS    bool
	MaxBodySize  int
	Users        []*User
	CertLocation string
	Debug        bool
}

ListenRequest represents a new listen request

func (*ListenRequest) Init

func (r *ListenRequest) Init() error

func (*ListenRequest) Validate

func (r *ListenRequest) Validate() error

type ListenResponse

type ListenResponse struct{}

ListenResponse represents a new listen response

type Message

type Message struct {
	From    string
	To      []string
	Subject string
	Header  map[string]string
	Raw     string
	Body    string
}

Message represent an email

func NewMessage

func NewMessage(from string, to []string, reader io.Reader) (*Message, error)

func (*Message) Decode

func (m *Message) Decode()

type Messages

type Messages struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

Messages represents a FIFO message collection grouped by user

func NewMessages

func NewMessages() *Messages

NewMessages returns a new FIFO message collection by user

func (*Messages) Push

func (m *Messages) Push(username string, message *Message)

Push appends a message by user

func (*Messages) Shift

func (m *Messages) Shift(username string) *Message

Shift remove first placed message for supplied message

type User

type User struct {
	Username    string
	Password    string
	Credentials string
}

User represent email user

type UserMessage

type UserMessage struct {
	User    string
	TagID   string
	Message interface{}
}

UserMessage represents desired user message

Jump to

Keyboard shortcuts

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