helper

package
v0.3.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestCertificate

func CreateTestCertificate() tls.Certificate

func StartMockServer

func StartMockServer(t *testing.T) net.Listener

StartMockServer creates a mock TCP server and returns a network listener. The server listens on the specified TCP port on the loopback address, "127.0.0.1". The returned listener should be closed after use to free the associated resources.

func StartMockTLSServer

func StartMockTLSServer(t *testing.T) net.Listener

StartMockTLSServer creates a mock TLS TCP server and returns a network listener. It loads the X.509 key pair from the given PEM-encoded files, 'testcert.pem' and 'testkey.pem', for TLS configuration. If the key pair cannot be loaded, the function aborts with a fatal error. The server listens on the specified TCP port on the loopback address, "127.0.0.1". The returned listener should be closed after use to free the associated resources. To create these test certificate files, you can use OpenSSL with the following commands in your `test_data` folder under project root:

`openssl req -newkey rsa:2048 -nodes -keyout testkey.pem -x509 -days 365 -out testcert.pem`

Types

This section is empty.

Jump to

Keyboard shortcuts

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