test

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCertificateTemplate

func GenerateCertificateTemplate(expiry time.Time) *x509.Certificate

GenerateCertificateTemplate generates the template used to issue test certificates

func GenerateSelfSignedCertificateWithPrivateKey

func GenerateSelfSignedCertificateWithPrivateKey(cert *x509.Certificate, privateKey *rsa.PrivateKey) (*x509.Certificate, []byte)

GenerateSelfSignedCertificateWithPrivateKey generates a self signed certificate with the given private key

func GenerateSignedCertificate

func GenerateSignedCertificate(cert, parentCert *x509.Certificate, parentKey *rsa.PrivateKey) (*x509.Certificate, []byte, []byte)

GenerateSignedCertificate generates a certificate that is signed

func GenerateTestCertificate

func GenerateTestCertificate(expiry time.Time) ([]byte, []byte)

GenerateTestCertificate generates a test certificate with the given expiry date

func SetupHTTPProxyServer

func SetupHTTPProxyServer() (*httptest.Server, error)

SetupHTTPProxyServer sets up a proxy server

func SetupHTTPSServer

func SetupHTTPSServer() (*httptest.Server, []byte, []byte, string, func(), error)

SetupHTTPSServer sets up a server for testing with a generated cert and key pair

func SetupHTTPSServerWithCertAndKey

func SetupHTTPSServerWithCertAndKey(caPEM, certPEM, keyPEM []byte) (*httptest.Server, string, func(), error)

SetupHTTPSServerWithCertAndKey sets up a server with a provided certs and key

func WriteFile

func WriteFile(filename string, contents []byte) (string, error)

WriteFile writes some content to a temporary file

Types

type TCPServer

type TCPServer struct {
	Listener net.Listener
	TLS      *tls.Config
	// contains filtered or unexported fields
}

TCPServer allows manipulation of the tls.Config before starting the listener

func SetupTCPServer

func SetupTCPServer() (*TCPServer, []byte, []byte, string, func(), error)

SetupTCPServer sets up a server for testing with a generated cert and key pair

func SetupTCPServerWithCertAndKey

func SetupTCPServerWithCertAndKey(caPEM, certPEM, keyPEM []byte) (*TCPServer, string, func(), error)

SetupTCPServerWithCertAndKey sets up a server with the provided certs and key

func (*TCPServer) Close

func (t *TCPServer) Close()

Close stops the server and closes the listener

func (*TCPServer) StartFTP

func (t *TCPServer) StartFTP()

StartFTP starts a listener that negotiates a TLS connection with an ftp client using AUTH TLS

func (*TCPServer) StartIMAP

func (t *TCPServer) StartIMAP()

StartIMAP starts a listener that negotiates a TLS connection with an imap client using STARTTLS

func (*TCPServer) StartPOP3

func (t *TCPServer) StartPOP3()

StartPOP3 starts a listener that negotiates a TLS connection with an pop3 client using STARTTLS

func (*TCPServer) StartPostgreSQL

func (t *TCPServer) StartPostgreSQL()

StartPostgreSQL starts a listener that negotiates a TLS connection with an postgresql client using STARTTLS

func (*TCPServer) StartSMTP

func (t *TCPServer) StartSMTP()

StartSMTP starts a listener that negotiates a TLS connection with an smtp client using STARTTLS

func (*TCPServer) StartTLS

func (t *TCPServer) StartTLS()

StartTLS starts a listener that performs an immediate TLS handshake

func (*TCPServer) StartTLSWait

func (t *TCPServer) StartTLSWait(d time.Duration)

StartTLSWait starts a listener and waits for duration 'd' before performing the TLS handshake

Jump to

Keyboard shortcuts

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