testutil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MpModeConst = iota
	MpModeInc
	MpModeHalfInc
)

Variables

This section is empty.

Functions

func AppendAnswer

func AppendAnswer(m *dns.Msg, rr ...dns.RR)

func AssertAttrList

func AssertAttrList(t *testing.T, actual []pdp.AttributeAssignment, expected ...pdp.AttributeAssignment)

func AssertCRExtraResult

func AssertCRExtraResult(t *testing.T, desc string, io *testIORoutine, eMsg *dns.Msg, e ...*pb.DnstapAttribute) bool

func AssertDNSMessage

func AssertDNSMessage(t *testing.T, desc string, rc int, m *dns.Msg, erc int, eMsg string) bool

func AssertDnstapAttributes

func AssertDnstapAttributes(t *testing.T, desc string, a []*pb.DnstapAttribute, e ...*pb.DnstapAttribute) bool

func AssertDnstapList

func AssertDnstapList(t *testing.T, actual []*pb.DnstapAttribute, expected ...*pb.DnstapAttribute)

func AssertPanicWithError

func AssertPanicWithError(t *testing.T, desc string, f func(), format string, args ...interface{})

func AssertPanicWithErrorContains

func AssertPanicWithErrorContains(t *testing.T, desc string, f func(), e string)

func AssertPdpResponse

func AssertPdpResponse(t *testing.T, r *pdp.Response, expEff int, o ...pdp.AttributeAssignment)

func AssertValue

func AssertValue(t *testing.T, i int, av pdp.AttributeValue, ev pdp.AttributeValue)

func CopyEdns0

func CopyEdns0(in ...*dns.OPT) []*dns.OPT

func MakeDnOrFail

func MakeDnOrFail(t *testing.T, qName string) domain.Name

func MakeTestDNSMsg

func MakeTestDNSMsg(n string, t uint16, c uint16) *dns.Msg

func MakeTestDNSMsgWithEdns0

func MakeTestDNSMsgWithEdns0(n string, t uint16, c uint16, o ...*dns.OPT) *dns.Msg

func MakeTestDomain

func MakeTestDomain(s string) domain.Name

func NewA

func NewA(a net.IP) dns.RR

func NewAAAA

func NewAAAA(a net.IP) dns.RR

func NewCNAME

func NewCNAME(s string) dns.RR

func NewEdns0

func NewEdns0(o ...dns.EDNS0) *dns.OPT

func NewEdns0Cookie

func NewEdns0Cookie(s string) dns.EDNS0

func NewEdns0Local

func NewEdns0Local(c uint16, b []byte) dns.EDNS0

func NewEdns0Subnet

func NewEdns0Subnet(ip net.IP) dns.EDNS0

func NewErraticPep

func NewErraticPep(c pep.Client, err ...error) *erraticPep

func NewIORoutine

func NewIORoutine() *testIORoutine

func NewLogGrabber

func NewLogGrabber() *logGrabber

func NewTestAddressedNonwriter

func NewTestAddressedNonwriter(ra string) *testAddressedNonwriter

func NewTestAddressedNonwriterWithAddr

func NewTestAddressedNonwriterWithAddr(ra net.Addr) *testAddressedNonwriter

func WaitForPortClosed

func WaitForPortClosed(address string) error

func WaitForPortOpened

func WaitForPortOpened(address string) error

Types

type LoggedServer

type LoggedServer struct {
	S *server.Server
	B *bytes.Buffer
}

func NewServer

func NewServer(opts ...server.Option) *LoggedServer

func StartPDPServer

func StartPDPServer(t *testing.T, p, endpoint string) *LoggedServer

func (*LoggedServer) Stop

func (s *LoggedServer) Stop() string

type MockPdpClient

type MockPdpClient struct {
	T      *testing.T
	In     []pdp.AttributeAssignment
	Out    []pdp.AttributeAssignment
	Effect int
	Status error
	Err    error
}

func NewMockPdpClient

func NewMockPdpClient(t *testing.T) *MockPdpClient

func (*MockPdpClient) Close

func (mpc *MockPdpClient) Close()

func (*MockPdpClient) Connect

func (mpc *MockPdpClient) Connect(addr string) error

func (*MockPdpClient) Validate

func (mpc *MockPdpClient) Validate(in, out interface{}) error

type MockPlugin

type MockPlugin struct {
	Ip   net.IP
	Err  error
	Rc   int
	Mode int
	Cnt  *uint32
}

func (*MockPlugin) Name

func (p *MockPlugin) Name() string

Name implements the plugin.Handler interface.

func (*MockPlugin) ServeDNS

func (p *MockPlugin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

Jump to

Keyboard shortcuts

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