testutil

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//EnvVPCID is a premade test vpc
	EnvVPCID = "VPC_ID"
	// EnvDatabaseSubnetGroup is a collection of database subnets
	EnvDatabaseSubnetGroup = "DATABASE_SUBNET_GROUP"
	// EnvPrivateSubnets is a comma separated list of private subnets
	EnvPrivateSubnets = "PRIVATE_SUBNETS"
	// EnvVPCCIDRBlock is the premate test vpc CIDR block
	EnvVPCCIDRBlock = "VPC_CIDR_BLOCK"
	// EnvRoute53ZoneID is the premade test route53 zone
	EnvRoute53ZoneID = "ROUTE53_ZONE_ID"
	// EnvRoute53ZoneName is the premate test route53 zone
	EnvRoute53ZoneName = "ROUTE53_ZONE_NAME"
	// EnvWildcardCertARN is a premade test ACM cert
	EnvWildcardCertARN = "WILDCARD_CERT_ARN"
	// EnvWildcardCloudfrontCertARN is a premate test ACM cert in us-east-1
	EnvWildcardCloudfrontCertARN = "CLOUDFRONT_WILDCARD_CERT_ARN"
	// EnvAccountID is the aws account id
	EnvAccountID = "ACCOUNT_ID"
	// EnvAWSProfile is the aws profile
	EnvAWSProfile = "AWS_PROFILE"
)
View Source
const (
	// IAMRegion IAM is allegedly hosted in us-east-1, so use this region for IAM related things
	IAMRegion     = "us-east-1"
	DefaultRegion = "us-west-2"
)
View Source
const Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
View Source
const AlphaNum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

Variables

View Source
var UserArn = "arn:aws:iam::119435350371:user/ci/cztack-ci"

Functions

func AWSCurrentAccountId

func AWSCurrentAccountId(t *testing.T) string

func Boolptr added in v0.36.0

func Boolptr(in bool) *bool

func Clean

func Clean(dir string)

func Cleanup

func Cleanup(t *testing.T, options *terraform.Options)

func CreateRole

func CreateRole(t *testing.T) string

CreateRole will create a new role with a random name and path and return the name.

func CreateSecurityGroup added in v0.14.0

func CreateSecurityGroup(t *testing.T, region, vpc string) string

func DeleteRole

func DeleteRole(t *testing.T, name string)

func DeleteSecurityGroup added in v0.14.0

func DeleteSecurityGroup(t *testing.T, region, id string)

func Destroy added in v0.15.0

func Destroy(t *testing.T, options *terraform.Options, retries ...int)

Destroy with retries

func EnvVar added in v0.14.0

func EnvVar(name string) string

func Int64ptr added in v0.36.0

func Int64ptr(in int64) *int64

func ListEnvVar added in v0.14.0

func ListEnvVar(name string) []string

func Options added in v0.14.0

func Options(region string, vars map[string]interface{}) *terraform.Options

func RandomString added in v0.14.0

func RandomString(chars string, length int) string

func Run

func Run(t *testing.T, options *terraform.Options)

func S3SimulateRequest added in v0.35.0

func S3SimulateRequest(t *testing.T, region, action, bucketArn, bucketPolicy string, secureTransport bool) *iam.EvaluationResult

S3S3SimulateRequest uses the IAM policy simulator to run end-to-end tests on permissions

func Strptr added in v0.35.0

func Strptr(in string) *string

func UniqueId added in v0.14.0

func UniqueId() string

UniqueId returns a unique (ish) id we can attach to resources and tfstate files so they don't conflict with each other Uses base 62 to generate a 6 character string that's unlikely to collide with the handful of tests we run in parallel. Based on code here: http://stackoverflow.com/a/9543797/483528

Types

type S3BucketPolicy added in v0.35.0

type S3BucketPolicy struct {
	Statement []struct {
		Sid       string
		Effect    string
		Principal string
		Action    string
		Resource  []string
		Condition map[string]map[string]string
	}
}

func UnmarshalS3BucketPolicy added in v0.35.0

func UnmarshalS3BucketPolicy(in string) (*S3BucketPolicy, error)

UnmarshalS3BucketPolicy will parse an s3 bucket policy and return as a go struct. Only parts that have been used are supported so far

type Test added in v0.35.0

type Test struct {
	Options  func(*testing.T) *terraform.Options
	Validate func(*testing.T, *terraform.Options)
	Cleanup  func(*testing.T, *terraform.Options)

	Mode TestMode
	// contains filtered or unexported fields
}

func (*Test) Run added in v0.35.0

func (tt *Test) Run(t *testing.T)

func (*Test) Stage added in v0.35.0

func (tt *Test) Stage(t *testing.T, stage string, f func())

type TestMode added in v0.36.0

type TestMode int
const (
	Apply TestMode = 0
	Plan  TestMode = 1
	Init  TestMode = 2
)

Jump to

Keyboard shortcuts

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