mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-19 10:52:04 +00:00
chore: move input validation into gateway (#264)
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreateEgressOnlyInternetGatewayInput validates the input parameters
|
||||
func ValidateCreateEgressOnlyInternetGatewayInput(input *ec2.CreateEgressOnlyInternetGatewayInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteEgressOnlyInternetGatewayInput validates the input parameters
|
||||
func ValidateDeleteEgressOnlyInternetGatewayInput(input *ec2.DeleteEgressOnlyInternetGatewayInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDescribeEgressOnlyInternetGatewaysInput validates the input parameters
|
||||
func ValidateDescribeEgressOnlyInternetGatewaysInput(input *ec2.DescribeEgressOnlyInternetGatewaysInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateAssociateAddressInput validates the input parameters
|
||||
func ValidateAssociateAddressInput(input *ec2.AssociateAddressInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDisassociateAddressInput validates the input parameters
|
||||
func ValidateDisassociateAddressInput(input *ec2.DisassociateAddressInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateReleaseAddressInput validates the input parameters
|
||||
func ValidateReleaseAddressInput(input *ec2.ReleaseAddressInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateAttachInternetGatewayInput validates the input parameters
|
||||
func ValidateAttachInternetGatewayInput(input *ec2.AttachInternetGatewayInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteInternetGatewayInput validates the input parameters
|
||||
func ValidateDeleteInternetGatewayInput(input *ec2.DeleteInternetGatewayInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDetachInternetGatewayInput validates the input parameters
|
||||
func ValidateDetachInternetGatewayInput(input *ec2.DetachInternetGatewayInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateGetConsoleOutputInput validates the input parameters
|
||||
func ValidateGetConsoleOutputInput(input *ec2.GetConsoleOutputInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateRebootInstancesInput validates the input parameters
|
||||
func ValidateRebootInstancesInput(input *ec2.RebootInstancesInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -17,7 +17,6 @@ type startStoppedInstanceRequest struct {
|
||||
InstanceID string `json:"instance_id"`
|
||||
}
|
||||
|
||||
// ValidateStartInstancesInput validates the input parameters
|
||||
func ValidateStartInstancesInput(input *ec2.StartInstancesInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateStopInstancesInput validates the input parameters
|
||||
func ValidateStopInstancesInput(input *ec2.StopInstancesInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -19,7 +19,6 @@ type terminateStoppedInstanceRequest struct {
|
||||
InstanceID string `json:"instance_id"`
|
||||
}
|
||||
|
||||
// ValidateTerminateInstancesInput validates the input parameters
|
||||
func ValidateTerminateInstancesInput(input *ec2.TerminateInstancesInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,10 +9,23 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateCreateNatGatewayInput(input *ec2.CreateNatGatewayInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.SubnetId == nil || *input.SubnetId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
if input.AllocationId == nil || *input.AllocationId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateNatGateway(input *ec2.CreateNatGatewayInput, natsConn *nats.Conn, accountID string) (ec2.CreateNatGatewayOutput, error) {
|
||||
var output ec2.CreateNatGatewayOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateCreateNatGatewayInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_natgw.NewNATSNatGatewayService(natsConn)
|
||||
result, err := svc.CreateNatGateway(input, accountID)
|
||||
|
||||
@@ -9,10 +9,20 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateDeleteNatGatewayInput(input *ec2.DeleteNatGatewayInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.NatGatewayId == nil || *input.NatGatewayId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteNatGateway(input *ec2.DeleteNatGatewayInput, natsConn *nats.Conn, accountID string) (ec2.DeleteNatGatewayOutput, error) {
|
||||
var output ec2.DeleteNatGatewayOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateDeleteNatGatewayInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_natgw.NewNATSNatGatewayService(natsConn)
|
||||
result, err := svc.DeleteNatGateway(input, accountID)
|
||||
|
||||
@@ -3,6 +3,7 @@ package gateway_ec2_natgw
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/mulgadc/spinifex/spinifex/awserrors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -12,25 +13,78 @@ const testAccountID = "123456789012"
|
||||
|
||||
// CreateNatGateway tests
|
||||
|
||||
func TestValidateCreateNatGatewayInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.CreateNatGatewayInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing SubnetId", &ec2.CreateNatGatewayInput{AllocationId: aws.String("eipalloc-1")}, awserrors.ErrorMissingParameter},
|
||||
{"empty SubnetId", &ec2.CreateNatGatewayInput{SubnetId: aws.String(""), AllocationId: aws.String("eipalloc-1")}, awserrors.ErrorMissingParameter},
|
||||
{"missing AllocationId", &ec2.CreateNatGatewayInput{SubnetId: aws.String("subnet-1")}, awserrors.ErrorMissingParameter},
|
||||
{"empty AllocationId", &ec2.CreateNatGatewayInput{SubnetId: aws.String("subnet-1"), AllocationId: aws.String("")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.CreateNatGatewayInput{SubnetId: aws.String("subnet-1"), AllocationId: aws.String("eipalloc-1")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateCreateNatGatewayInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateNatGateway_NilInput(t *testing.T) {
|
||||
_, err := CreateNatGateway(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestCreateNatGateway_NilNATS(t *testing.T) {
|
||||
_, err := CreateNatGateway(&ec2.CreateNatGatewayInput{}, nil, testAccountID)
|
||||
_, err := CreateNatGateway(&ec2.CreateNatGatewayInput{
|
||||
SubnetId: aws.String("subnet-1"),
|
||||
AllocationId: aws.String("eipalloc-1"),
|
||||
}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
// DeleteNatGateway tests
|
||||
|
||||
func TestValidateDeleteNatGatewayInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.DeleteNatGatewayInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing NatGatewayId", &ec2.DeleteNatGatewayInput{}, awserrors.ErrorMissingParameter},
|
||||
{"empty NatGatewayId", &ec2.DeleteNatGatewayInput{NatGatewayId: aws.String("")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.DeleteNatGatewayInput{NatGatewayId: aws.String("nat-1")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateDeleteNatGatewayInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteNatGateway_NilInput(t *testing.T) {
|
||||
_, err := DeleteNatGateway(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestDeleteNatGateway_NilNATS(t *testing.T) {
|
||||
_, err := DeleteNatGateway(&ec2.DeleteNatGatewayInput{}, nil, testAccountID)
|
||||
_, err := DeleteNatGateway(&ec2.DeleteNatGatewayInput{
|
||||
NatGatewayId: aws.String("nat-1"),
|
||||
}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreatePlacementGroupInput validates the input parameters
|
||||
func ValidateCreatePlacementGroupInput(input *ec2.CreatePlacementGroupInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeletePlacementGroupInput validates the input parameters
|
||||
func ValidateDeletePlacementGroupInput(input *ec2.DeletePlacementGroupInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,10 +9,23 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateAssociateRouteTableInput(input *ec2.AssociateRouteTableInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.RouteTableId == nil || *input.RouteTableId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
if input.SubnetId == nil || *input.SubnetId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func AssociateRouteTable(input *ec2.AssociateRouteTableInput, natsConn *nats.Conn, accountID string) (ec2.AssociateRouteTableOutput, error) {
|
||||
var output ec2.AssociateRouteTableOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateAssociateRouteTableInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_routetable.NewNATSRouteTableService(natsConn)
|
||||
result, err := svc.AssociateRouteTable(input, accountID)
|
||||
|
||||
@@ -9,10 +9,23 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateCreateRouteInput(input *ec2.CreateRouteInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.RouteTableId == nil || *input.RouteTableId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
if input.DestinationCidrBlock == nil || *input.DestinationCidrBlock == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateRoute(input *ec2.CreateRouteInput, natsConn *nats.Conn, accountID string) (ec2.CreateRouteOutput, error) {
|
||||
var output ec2.CreateRouteOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateCreateRouteInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_routetable.NewNATSRouteTableService(natsConn)
|
||||
result, err := svc.CreateRoute(input, accountID)
|
||||
|
||||
@@ -9,10 +9,20 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateCreateRouteTableInput(input *ec2.CreateRouteTableInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.VpcId == nil || *input.VpcId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateRouteTable(input *ec2.CreateRouteTableInput, natsConn *nats.Conn, accountID string) (ec2.CreateRouteTableOutput, error) {
|
||||
var output ec2.CreateRouteTableOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateCreateRouteTableInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_routetable.NewNATSRouteTableService(natsConn)
|
||||
result, err := svc.CreateRouteTable(input, accountID)
|
||||
|
||||
@@ -9,10 +9,23 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateDeleteRouteInput(input *ec2.DeleteRouteInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.RouteTableId == nil || *input.RouteTableId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
if input.DestinationCidrBlock == nil || *input.DestinationCidrBlock == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteRoute(input *ec2.DeleteRouteInput, natsConn *nats.Conn, accountID string) (ec2.DeleteRouteOutput, error) {
|
||||
var output ec2.DeleteRouteOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateDeleteRouteInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_routetable.NewNATSRouteTableService(natsConn)
|
||||
result, err := svc.DeleteRoute(input, accountID)
|
||||
|
||||
@@ -9,10 +9,20 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateDeleteRouteTableInput(input *ec2.DeleteRouteTableInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.RouteTableId == nil || *input.RouteTableId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteRouteTable(input *ec2.DeleteRouteTableInput, natsConn *nats.Conn, accountID string) (ec2.DeleteRouteTableOutput, error) {
|
||||
var output ec2.DeleteRouteTableOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateDeleteRouteTableInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_routetable.NewNATSRouteTableService(natsConn)
|
||||
result, err := svc.DeleteRouteTable(input, accountID)
|
||||
|
||||
@@ -9,10 +9,20 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateDisassociateRouteTableInput(input *ec2.DisassociateRouteTableInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.AssociationId == nil || *input.AssociationId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DisassociateRouteTable(input *ec2.DisassociateRouteTableInput, natsConn *nats.Conn, accountID string) (ec2.DisassociateRouteTableOutput, error) {
|
||||
var output ec2.DisassociateRouteTableOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateDisassociateRouteTableInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_routetable.NewNATSRouteTableService(natsConn)
|
||||
result, err := svc.DisassociateRouteTable(input, accountID)
|
||||
|
||||
@@ -9,10 +9,23 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateReplaceRouteInput(input *ec2.ReplaceRouteInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.RouteTableId == nil || *input.RouteTableId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
if input.DestinationCidrBlock == nil || *input.DestinationCidrBlock == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReplaceRoute(input *ec2.ReplaceRouteInput, natsConn *nats.Conn, accountID string) (ec2.ReplaceRouteOutput, error) {
|
||||
var output ec2.ReplaceRouteOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateReplaceRouteInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_routetable.NewNATSRouteTableService(natsConn)
|
||||
result, err := svc.ReplaceRoute(input, accountID)
|
||||
|
||||
@@ -9,10 +9,23 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
func ValidateReplaceRouteTableAssociationInput(input *ec2.ReplaceRouteTableAssociationInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
if input.AssociationId == nil || *input.AssociationId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
if input.RouteTableId == nil || *input.RouteTableId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReplaceRouteTableAssociation(input *ec2.ReplaceRouteTableAssociationInput, natsConn *nats.Conn, accountID string) (ec2.ReplaceRouteTableAssociationOutput, error) {
|
||||
var output ec2.ReplaceRouteTableAssociationOutput
|
||||
if input == nil {
|
||||
return output, errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
if err := ValidateReplaceRouteTableAssociationInput(input); err != nil {
|
||||
return output, err
|
||||
}
|
||||
svc := handlers_ec2_routetable.NewNATSRouteTableService(natsConn)
|
||||
result, err := svc.ReplaceRouteTableAssociation(input, accountID)
|
||||
|
||||
@@ -3,6 +3,7 @@ package gateway_ec2_routetable
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/mulgadc/spinifex/spinifex/awserrors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -12,25 +13,71 @@ const testAccountID = "123456789012"
|
||||
|
||||
// CreateRouteTable tests
|
||||
|
||||
func TestValidateCreateRouteTableInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.CreateRouteTableInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing VpcId", &ec2.CreateRouteTableInput{}, awserrors.ErrorMissingParameter},
|
||||
{"empty VpcId", &ec2.CreateRouteTableInput{VpcId: aws.String("")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.CreateRouteTableInput{VpcId: aws.String("vpc-1")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateCreateRouteTableInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateRouteTable_NilInput(t *testing.T) {
|
||||
_, err := CreateRouteTable(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestCreateRouteTable_NilNATS(t *testing.T) {
|
||||
_, err := CreateRouteTable(&ec2.CreateRouteTableInput{}, nil, testAccountID)
|
||||
_, err := CreateRouteTable(&ec2.CreateRouteTableInput{VpcId: aws.String("vpc-1")}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
// DeleteRouteTable tests
|
||||
|
||||
func TestValidateDeleteRouteTableInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.DeleteRouteTableInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing RouteTableId", &ec2.DeleteRouteTableInput{}, awserrors.ErrorMissingParameter},
|
||||
{"empty RouteTableId", &ec2.DeleteRouteTableInput{RouteTableId: aws.String("")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.DeleteRouteTableInput{RouteTableId: aws.String("rtb-1")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateDeleteRouteTableInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteRouteTable_NilInput(t *testing.T) {
|
||||
_, err := DeleteRouteTable(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestDeleteRouteTable_NilNATS(t *testing.T) {
|
||||
_, err := DeleteRouteTable(&ec2.DeleteRouteTableInput{}, nil, testAccountID)
|
||||
_, err := DeleteRouteTable(&ec2.DeleteRouteTableInput{RouteTableId: aws.String("rtb-1")}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -48,72 +95,229 @@ func TestDescribeRouteTables_NilNATS(t *testing.T) {
|
||||
|
||||
// CreateRoute tests
|
||||
|
||||
func TestValidateCreateRouteInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.CreateRouteInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing RouteTableId", &ec2.CreateRouteInput{DestinationCidrBlock: aws.String("0.0.0.0/0")}, awserrors.ErrorMissingParameter},
|
||||
{"empty RouteTableId", &ec2.CreateRouteInput{RouteTableId: aws.String(""), DestinationCidrBlock: aws.String("0.0.0.0/0")}, awserrors.ErrorMissingParameter},
|
||||
{"missing DestinationCidrBlock", &ec2.CreateRouteInput{RouteTableId: aws.String("rtb-1")}, awserrors.ErrorMissingParameter},
|
||||
{"empty DestinationCidrBlock", &ec2.CreateRouteInput{RouteTableId: aws.String("rtb-1"), DestinationCidrBlock: aws.String("")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.CreateRouteInput{RouteTableId: aws.String("rtb-1"), DestinationCidrBlock: aws.String("0.0.0.0/0")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateCreateRouteInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateRoute_NilInput(t *testing.T) {
|
||||
_, err := CreateRoute(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestCreateRoute_NilNATS(t *testing.T) {
|
||||
_, err := CreateRoute(&ec2.CreateRouteInput{}, nil, testAccountID)
|
||||
_, err := CreateRoute(&ec2.CreateRouteInput{
|
||||
RouteTableId: aws.String("rtb-1"),
|
||||
DestinationCidrBlock: aws.String("0.0.0.0/0"),
|
||||
}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
// DeleteRoute tests
|
||||
|
||||
func TestValidateDeleteRouteInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.DeleteRouteInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing RouteTableId", &ec2.DeleteRouteInput{DestinationCidrBlock: aws.String("0.0.0.0/0")}, awserrors.ErrorMissingParameter},
|
||||
{"missing DestinationCidrBlock", &ec2.DeleteRouteInput{RouteTableId: aws.String("rtb-1")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.DeleteRouteInput{RouteTableId: aws.String("rtb-1"), DestinationCidrBlock: aws.String("0.0.0.0/0")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateDeleteRouteInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteRoute_NilInput(t *testing.T) {
|
||||
_, err := DeleteRoute(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestDeleteRoute_NilNATS(t *testing.T) {
|
||||
_, err := DeleteRoute(&ec2.DeleteRouteInput{}, nil, testAccountID)
|
||||
_, err := DeleteRoute(&ec2.DeleteRouteInput{
|
||||
RouteTableId: aws.String("rtb-1"),
|
||||
DestinationCidrBlock: aws.String("0.0.0.0/0"),
|
||||
}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
// ReplaceRoute tests
|
||||
|
||||
func TestValidateReplaceRouteInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.ReplaceRouteInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing RouteTableId", &ec2.ReplaceRouteInput{DestinationCidrBlock: aws.String("0.0.0.0/0")}, awserrors.ErrorMissingParameter},
|
||||
{"missing DestinationCidrBlock", &ec2.ReplaceRouteInput{RouteTableId: aws.String("rtb-1")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.ReplaceRouteInput{RouteTableId: aws.String("rtb-1"), DestinationCidrBlock: aws.String("0.0.0.0/0")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateReplaceRouteInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplaceRoute_NilInput(t *testing.T) {
|
||||
_, err := ReplaceRoute(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestReplaceRoute_NilNATS(t *testing.T) {
|
||||
_, err := ReplaceRoute(&ec2.ReplaceRouteInput{}, nil, testAccountID)
|
||||
_, err := ReplaceRoute(&ec2.ReplaceRouteInput{
|
||||
RouteTableId: aws.String("rtb-1"),
|
||||
DestinationCidrBlock: aws.String("0.0.0.0/0"),
|
||||
}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
// AssociateRouteTable tests
|
||||
|
||||
func TestValidateAssociateRouteTableInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.AssociateRouteTableInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing RouteTableId", &ec2.AssociateRouteTableInput{SubnetId: aws.String("subnet-1")}, awserrors.ErrorMissingParameter},
|
||||
{"missing SubnetId", &ec2.AssociateRouteTableInput{RouteTableId: aws.String("rtb-1")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.AssociateRouteTableInput{RouteTableId: aws.String("rtb-1"), SubnetId: aws.String("subnet-1")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateAssociateRouteTableInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAssociateRouteTable_NilInput(t *testing.T) {
|
||||
_, err := AssociateRouteTable(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestAssociateRouteTable_NilNATS(t *testing.T) {
|
||||
_, err := AssociateRouteTable(&ec2.AssociateRouteTableInput{}, nil, testAccountID)
|
||||
_, err := AssociateRouteTable(&ec2.AssociateRouteTableInput{
|
||||
RouteTableId: aws.String("rtb-1"),
|
||||
SubnetId: aws.String("subnet-1"),
|
||||
}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
// DisassociateRouteTable tests
|
||||
|
||||
func TestValidateDisassociateRouteTableInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.DisassociateRouteTableInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing AssociationId", &ec2.DisassociateRouteTableInput{}, awserrors.ErrorMissingParameter},
|
||||
{"empty AssociationId", &ec2.DisassociateRouteTableInput{AssociationId: aws.String("")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.DisassociateRouteTableInput{AssociationId: aws.String("rtbassoc-1")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateDisassociateRouteTableInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisassociateRouteTable_NilInput(t *testing.T) {
|
||||
_, err := DisassociateRouteTable(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestDisassociateRouteTable_NilNATS(t *testing.T) {
|
||||
_, err := DisassociateRouteTable(&ec2.DisassociateRouteTableInput{}, nil, testAccountID)
|
||||
_, err := DisassociateRouteTable(&ec2.DisassociateRouteTableInput{
|
||||
AssociationId: aws.String("rtbassoc-1"),
|
||||
}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
// ReplaceRouteTableAssociation tests
|
||||
|
||||
func TestValidateReplaceRouteTableAssociationInput(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *ec2.ReplaceRouteTableAssociationInput
|
||||
wantErr string
|
||||
}{
|
||||
{"nil input", nil, awserrors.ErrorInvalidParameterValue},
|
||||
{"missing AssociationId", &ec2.ReplaceRouteTableAssociationInput{RouteTableId: aws.String("rtb-1")}, awserrors.ErrorMissingParameter},
|
||||
{"missing RouteTableId", &ec2.ReplaceRouteTableAssociationInput{AssociationId: aws.String("rtbassoc-1")}, awserrors.ErrorMissingParameter},
|
||||
{"valid input", &ec2.ReplaceRouteTableAssociationInput{AssociationId: aws.String("rtbassoc-1"), RouteTableId: aws.String("rtb-1")}, ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := ValidateReplaceRouteTableAssociationInput(tt.input)
|
||||
if tt.wantErr == "" {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.EqualError(t, err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplaceRouteTableAssociation_NilInput(t *testing.T) {
|
||||
_, err := ReplaceRouteTableAssociation(nil, nil, testAccountID)
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestReplaceRouteTableAssociation_NilNATS(t *testing.T) {
|
||||
_, err := ReplaceRouteTableAssociation(&ec2.ReplaceRouteTableAssociationInput{}, nil, testAccountID)
|
||||
_, err := ReplaceRouteTableAssociation(&ec2.ReplaceRouteTableAssociationInput{
|
||||
AssociationId: aws.String("rtbassoc-1"),
|
||||
RouteTableId: aws.String("rtb-1"),
|
||||
}, nil, testAccountID)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreateVolumeInput validates the input parameters
|
||||
func ValidateCreateVolumeInput(input *ec2.CreateVolumeInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteVolumeInput validates the input parameters
|
||||
func ValidateDeleteVolumeInput(input *ec2.DeleteVolumeInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDescribeVolumeStatusInput validates the input parameters
|
||||
func ValidateDescribeVolumeStatusInput(input *ec2.DescribeVolumeStatusInput) error {
|
||||
if input == nil {
|
||||
return nil
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDescribeVolumesInput validates the input parameters
|
||||
func ValidateDescribeVolumesInput(input *ec2.DescribeVolumesInput) error {
|
||||
if input == nil {
|
||||
return nil
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDescribeVolumesModificationsInput validates the input parameters
|
||||
func ValidateDescribeVolumesModificationsInput(input *ec2.DescribeVolumesModificationsInput) error {
|
||||
if input == nil {
|
||||
return nil
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateModifyVolumeInput validates the input parameters
|
||||
func ValidateModifyVolumeInput(input *ec2.ModifyVolumeInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreateNetworkInterfaceInput validates the input parameters
|
||||
func ValidateCreateNetworkInterfaceInput(input *ec2.CreateNetworkInterfaceInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreateSubnetInput validates the input parameters
|
||||
func ValidateCreateSubnetInput(input *ec2.CreateSubnetInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreateVpcInput validates the input parameters
|
||||
func ValidateCreateVpcInput(input *ec2.CreateVpcInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteNetworkInterfaceInput validates the input parameters
|
||||
func ValidateDeleteNetworkInterfaceInput(input *ec2.DeleteNetworkInterfaceInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteSubnetInput validates the input parameters
|
||||
func ValidateDeleteSubnetInput(input *ec2.DeleteSubnetInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteVpcInput validates the input parameters
|
||||
func ValidateDeleteVpcInput(input *ec2.DeleteVpcInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDescribeVpcAttributeInput validates the input parameters
|
||||
func ValidateDescribeVpcAttributeInput(input *ec2.DescribeVpcAttributeInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateModifyNetworkInterfaceAttributeInput validates the input parameters
|
||||
func ValidateModifyNetworkInterfaceAttributeInput(input *ec2.ModifyNetworkInterfaceAttributeInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
@@ -17,6 +16,9 @@ func ValidateModifyNetworkInterfaceAttributeInput(input *ec2.ModifyNetworkInterf
|
||||
if input.NetworkInterfaceId == nil || *input.NetworkInterfaceId == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
if len(input.Groups) == 0 && input.Description == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,17 @@ func TestModifyNetworkInterfaceAttribute_EmptyNetworkInterfaceId(t *testing.T) {
|
||||
assert.EqualError(t, err, awserrors.ErrorMissingParameter)
|
||||
}
|
||||
|
||||
func TestModifyNetworkInterfaceAttribute_NilNATS(t *testing.T) {
|
||||
func TestModifyNetworkInterfaceAttribute_NoAttributes(t *testing.T) {
|
||||
_, err := ModifyNetworkInterfaceAttribute(&ec2.ModifyNetworkInterfaceAttributeInput{
|
||||
NetworkInterfaceId: aws.String("eni-abc123"),
|
||||
}, nil, "123456789012")
|
||||
assert.EqualError(t, err, awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
func TestModifyNetworkInterfaceAttribute_NilNATS(t *testing.T) {
|
||||
_, err := ModifyNetworkInterfaceAttribute(&ec2.ModifyNetworkInterfaceAttributeInput{
|
||||
NetworkInterfaceId: aws.String("eni-abc123"),
|
||||
Description: &ec2.AttributeValue{Value: aws.String("desc")},
|
||||
}, nil, "123456789012")
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateModifySubnetAttributeInput validates the input parameters
|
||||
func ValidateModifySubnetAttributeInput(input *ec2.ModifySubnetAttributeInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateModifyVpcAttributeInput validates the input parameters
|
||||
func ValidateModifyVpcAttributeInput(input *ec2.ModifyVpcAttributeInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreateListenerInput validates the input parameters
|
||||
func ValidateCreateListenerInput(input *elbv2.CreateListenerInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreateLoadBalancerInput validates the input parameters
|
||||
func ValidateCreateLoadBalancerInput(input *elbv2.CreateLoadBalancerInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateCreateTargetGroupInput validates the input parameters
|
||||
func ValidateCreateTargetGroupInput(input *elbv2.CreateTargetGroupInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteListenerInput validates the input parameters
|
||||
func ValidateDeleteListenerInput(input *elbv2.DeleteListenerInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteLoadBalancerInput validates the input parameters
|
||||
func ValidateDeleteLoadBalancerInput(input *elbv2.DeleteLoadBalancerInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeleteTargetGroupInput validates the input parameters
|
||||
func ValidateDeleteTargetGroupInput(input *elbv2.DeleteTargetGroupInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDeregisterTargetsInput validates the input parameters
|
||||
func ValidateDeregisterTargetsInput(input *elbv2.DeregisterTargetsInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDescribeLoadBalancerAttributesInput validates the input parameters
|
||||
func ValidateDescribeLoadBalancerAttributesInput(input *elbv2.DescribeLoadBalancerAttributesInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDescribeTargetGroupAttributesInput validates the input parameters
|
||||
func ValidateDescribeTargetGroupAttributesInput(input *elbv2.DescribeTargetGroupAttributesInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateDescribeTargetHealthInput validates the input parameters
|
||||
func ValidateDescribeTargetHealthInput(input *elbv2.DescribeTargetHealthInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateGetLBConfigInput validates the input parameters
|
||||
func ValidateGetLBConfigInput(input *handlers_elbv2.GetLBConfigInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateLBAgentHeartbeatInput validates the input parameters
|
||||
func ValidateLBAgentHeartbeatInput(input *handlers_elbv2.LBAgentHeartbeatInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateModifyLoadBalancerAttributesInput validates the input parameters
|
||||
func ValidateModifyLoadBalancerAttributesInput(input *elbv2.ModifyLoadBalancerAttributesInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateModifyTargetGroupAttributesInput validates the input parameters
|
||||
func ValidateModifyTargetGroupAttributesInput(input *elbv2.ModifyTargetGroupAttributesInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/nats-io/nats.go"
|
||||
)
|
||||
|
||||
// ValidateRegisterTargetsInput validates the input parameters
|
||||
func ValidateRegisterTargetsInput(input *elbv2.RegisterTargetsInput) error {
|
||||
if input == nil {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
|
||||
Reference in New Issue
Block a user