acctest

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MPL-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// CharSetAlphaNum is the alphanumeric character set for use with
	// RandStringFromCharSet
	CharSetAlphaNum = "abcdefghijklmnopqrstuvwxyz012346789"

	// CharSetAlpha is the alphabetical character set for use with
	// RandStringFromCharSet
	CharSetAlpha = "abcdefghijklmnopqrstuvwxyz"
)

Variables

This section is empty.

Functions

func RandInt

func RandInt() int

RandInt generates a random integer

func RandIntRange

func RandIntRange(min int, max int) int

RandIntRange returns a random integer between min (inclusive) and max (exclusive)

func RandIpAddress

func RandIpAddress(s string) (string, error)

RandIpAddress returns a random IP address in the specified CIDR block. The prefix length must be less than 31.

func RandSSHKeyPair

func RandSSHKeyPair(comment string) (string, string, error)

RandSSHKeyPair generates a random public and private SSH key pair.

The public key is returned in OpenSSH authorized key format, for example:

ssh-rsa XXX comment

The private key is RSA algorithm, 1024 bits, PEM encoded, and has no passphrase. Testing with different or stricter security requirements should use the standard library crypto and golang.org/x/crypto/ssh packages directly.

func RandString

func RandString(strlen int) string

RandString generates a random alphanumeric string of the length specified

func RandStringFromCharSet

func RandStringFromCharSet(strlen int, charSet string) string

RandStringFromCharSet generates a random string by selecting characters from the charset provided

func RandTLSCert

func RandTLSCert(orgName string) (string, string, error)

RandTLSCert generates a self-signed TLS certificate with a newly created private key, and returns both the cert and the private key PEM encoded.

The private key uses RSA algorithm, 1024 bits, and has no passphrase.

The certificate expires in 24 hours, has a random serial number, and is set for Encipherment, Digital Signature, and Server Auth key usage. Only the organization name of the subject is configurable.

Testing with different or stricter security requirements should use the standard library crypto and golang.org/x/crypto packages directly.

func RandomWithPrefix

func RandomWithPrefix(name string) string

RandomWithPrefix is used to generate a unique name with a prefix, for randomizing names in acceptance tests

Types

This section is empty.

Jump to

Keyboard shortcuts

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