Beispiel #1
0
	"errors"
	"fmt"
	"math/rand"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/ec2"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/rosenhouse/tubes/lib/awsclient"
	"github.com/rosenhouse/tubes/mocks"
)

var _ = Describe("Keypair operations", func() {
	var (
		client    awsclient.Client
		ec2Client *mocks.EC2Client
		keyName   string
	)

	BeforeEach(func() {
		ec2Client = &mocks.EC2Client{}
		client = awsclient.Client{
			EC2: ec2Client,
		}
		keyName = fmt.Sprintf("some-key-%x", rand.Int31()>>16)
	})

	Describe("CreateKeyPair", func() {
		It("should call the SDK CreateKeyPair function and return the resulting private key", func() {
			ec2Client.CreateKeyPairCall.Returns.Output = &ec2.CreateKeyPairOutput{}
			ec2Client.CreateKeyPairCall.Returns.Output.KeyMaterial = aws.String("some pem block")
Beispiel #2
0
	"math/rand"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/iam"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/rosenhouse/tubes/lib/awsclient"
	"github.com/rosenhouse/tubes/mocks"
)

var _ = Describe("User operations", func() {
	var (
		client    awsclient.Client
		iamClient *mocks.IAMClient
		userName  string
	)

	BeforeEach(func() {
		iamClient = &mocks.IAMClient{}
		client = awsclient.Client{
			IAM: iamClient,
		}
		userName = fmt.Sprintf("some-user-%x", rand.Int31()>>16)
	})

	Describe("CreateAccessKey", func() {
		It("should call the SDK CreateAccessKey function", func() {
			iamClient.CreateAccessKeyCall.Returns.Output = &iam.CreateAccessKeyOutput{
				AccessKey: &iam.AccessKey{
Beispiel #3
0
package awsclient_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/ec2"

	"github.com/rosenhouse/tubes/lib/awsclient"
	"github.com/rosenhouse/tubes/mocks"
)

var _ = Describe("Discovering the latest NAT AMI ID", func() {
	var (
		client    awsclient.Client
		ec2Client *mocks.EC2Client
	)

	var makeImage = func(id, arch, volumeType, creationDate string) *ec2.Image {
		return &ec2.Image{
			Architecture: aws.String(arch),
			BlockDeviceMappings: []*ec2.BlockDeviceMapping{
				&ec2.BlockDeviceMapping{
					Ebs: &ec2.EbsBlockDevice{
						VolumeType: aws.String(volumeType),
					},
				},
			},
			CreationDate: aws.String(creationDate),
			ImageId:      aws.String(id),
		}
	"errors"
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/cloudformation"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/rosenhouse/tubes/lib/awsclient"
	"github.com/rosenhouse/tubes/mocks"
)

var _ = Describe("Retrieving resource IDs from a CloudFormation stack", func() {
	var (
		client               awsclient.Client
		cloudFormationClient *mocks.CloudFormationClient
	)
	const (
		region              = "some-region"
		accountID    uint64 = 123456789012 // 12 digits
		stackName           = "some-stack-name"
		resourceGUID        = "some-resource-guid"
	)

	var newResource = func(logicalID, physicalID string) *cloudformation.StackResource {
		return &cloudformation.StackResource{
			LogicalResourceId:  aws.String(logicalID),
			PhysicalResourceId: aws.String(physicalID),
			StackId: aws.String(fmt.Sprintf("arn:aws:cloudformation:%s:%d:stack/%s/%s",
				region,
				accountID,
Beispiel #5
0
import (
	"errors"
	"fmt"
	"math/rand"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/rosenhouse/tubes/lib/awsclient"
	"github.com/rosenhouse/tubes/mocks"
)

var _ = Describe("Idempotent delete of a CloudFormation stack", func() {
	var (
		client               awsclient.Client
		cloudFormationClient *mocks.CloudFormationClient
		stackName            string
	)

	BeforeEach(func() {
		cloudFormationClient = &mocks.CloudFormationClient{}
		client = awsclient.Client{
			CloudFormation: cloudFormationClient,
		}
		stackName = fmt.Sprintf("some-stack-%x", rand.Int31()>>16)
	})

	It("should call DeleteStack", func() {
		Expect(client.DeleteStack(stackName)).To(Succeed())

		Expect(*cloudFormationClient.DeleteStackCall.Receives.Input.StackName).To(Equal(stackName))