zaws 0.0.5 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +9 -18
- data/Gemfile +0 -0
- data/Gemfile.lock +26 -35
- data/Gemfile.lock.linux +69 -0
- data/Gemfile.lock.mac +81 -0
- data/Gemfile.lock.windows +77 -0
- data/LICENSE +0 -0
- data/README.md +11 -0
- data/Rakefile +1 -7
- data/archive/cloud_trail/cloud_trail.feature +124 -0
- data/bin/win_zaws.bat +2 -0
- data/lib/zaws.rb +54 -41
- data/lib/zaws/command/ai.rb +34 -0
- data/lib/zaws/command/bucket.rb +35 -0
- data/lib/zaws/command/cloud_trail.rb +43 -0
- data/lib/zaws/command/compute.rb +152 -87
- data/lib/zaws/command/config.rb +42 -0
- data/lib/zaws/command/elasticip.rb +19 -9
- data/lib/zaws/command/hosted_zone.rb +31 -18
- data/lib/zaws/command/iam.rb +37 -0
- data/lib/zaws/command/load_balancer.rb +54 -51
- data/lib/zaws/command/nessus.rb +41 -0
- data/lib/zaws/command/newrelic.rb +30 -0
- data/lib/zaws/command/route_table.rb +135 -122
- data/lib/zaws/command/security_group.rb +95 -82
- data/lib/zaws/command/subnet.rb +58 -46
- data/lib/zaws/command/sumo.rb +34 -0
- data/lib/zaws/command/vpc.rb +53 -0
- data/lib/zaws/external/awscli/awscli.rb +65 -0
- data/lib/zaws/external/awscli/commands.rb +10 -0
- data/lib/zaws/external/awscli/commands/aws.rb +40 -0
- data/lib/zaws/external/awscli/commands/ec2.rb +74 -0
- data/lib/zaws/external/awscli/commands/ec2/allocate_address.rb +42 -0
- data/lib/zaws/external/awscli/commands/ec2/assign_private_ip_addresses.rb +49 -0
- data/lib/zaws/external/awscli/commands/ec2/associate_address.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/associate_route_table.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/authorize_security_group_ingress.rb +70 -0
- data/lib/zaws/external/awscli/commands/ec2/create_route.rb +60 -0
- data/lib/zaws/external/awscli/commands/ec2/create_route_table.rb +40 -0
- data/lib/zaws/external/awscli/commands/ec2/create_security_group.rb +58 -0
- data/lib/zaws/external/awscli/commands/ec2/create_subnet.rb +62 -0
- data/lib/zaws/external/awscli/commands/ec2/create_tags.rb +53 -0
- data/lib/zaws/external/awscli/commands/ec2/create_vpc.rb +21 -0
- data/lib/zaws/external/awscli/commands/ec2/delete_route.rb +54 -0
- data/lib/zaws/external/awscli/commands/ec2/delete_route_table.rb +46 -0
- data/lib/zaws/external/awscli/commands/ec2/delete_security_group.rb +46 -0
- data/lib/zaws/external/awscli/commands/ec2/delete_subnet.rb +46 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_addresses.rb +41 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_images.rb +58 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_instances.rb +56 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_route_tables.rb +44 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_security_groups.rb +50 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_subnets.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_vpc_peering_connections.rb +23 -0
- data/lib/zaws/external/awscli/commands/ec2/describe_vpcs.rb +26 -0
- data/lib/zaws/external/awscli/commands/ec2/disable_vgw_route_propagation.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/disassociate-address.rb +42 -0
- data/lib/zaws/external/awscli/commands/ec2/disassociate_route_table.rb +41 -0
- data/lib/zaws/external/awscli/commands/ec2/enable_vgw_route_propagation.rb +48 -0
- data/lib/zaws/external/awscli/commands/ec2/filter.rb +115 -0
- data/lib/zaws/external/awscli/commands/ec2/modify_instance_attribute.rb +62 -0
- data/lib/zaws/external/awscli/commands/ec2/network_interfaces.rb +63 -0
- data/lib/zaws/external/awscli/commands/ec2/release_address.rb +42 -0
- data/lib/zaws/external/awscli/commands/ec2/revoke_security_group_ingress.rb +70 -0
- data/lib/zaws/external/awscli/commands/ec2/run_instances.rb +21 -0
- data/lib/zaws/external/awscli/commands/ec2/stop_instances.rb +21 -0
- data/lib/zaws/external/awscli/commands/ec2/terminate_instances.rb +40 -0
- data/lib/zaws/external/awscli/commands/ec2/unassign_private_ip_addresses.rb +49 -0
- data/lib/zaws/external/awscli/commands/elb.rb +19 -0
- data/lib/zaws/external/awscli/commands/elb/create_load_balancer.rb +64 -0
- data/lib/zaws/external/awscli/commands/elb/create_load_balancer_listeners.rb +47 -0
- data/lib/zaws/external/awscli/commands/elb/delete_load_balancer.rb +40 -0
- data/lib/zaws/external/awscli/commands/elb/delete_load_balancer_listeners.rb +49 -0
- data/lib/zaws/external/awscli/commands/elb/deregister_instances_with_load_balancer.rb +49 -0
- data/lib/zaws/external/awscli/commands/elb/describe_load_balancers.rb +30 -0
- data/lib/zaws/external/awscli/commands/elb/register_instances_with_load_balancer.rb +49 -0
- data/lib/zaws/external/awscli/commands/iam.rb +31 -0
- data/lib/zaws/external/awscli/commands/iam/GetPolicy.rb +21 -0
- data/lib/zaws/external/awscli/commands/iam/GetPolicyVersion.rb +21 -0
- data/lib/zaws/external/awscli/commands/iam/GetRolePolicy.rb +21 -0
- data/lib/zaws/external/awscli/commands/route53.rb +19 -0
- data/lib/zaws/external/awscli/commands/route53/list_hosted_zones.rb +30 -0
- data/lib/zaws/external/awscli/commands/route53/list_resource_record_sets.rb +41 -0
- data/lib/zaws/external/awscli/commands/s3/ls.rb +34 -0
- data/lib/zaws/external/awscli/commands/s3/mb.rb +41 -0
- data/lib/zaws/external/awscli/commands/s3/sync.rb +48 -0
- data/lib/zaws/external/awscli/credentials.rb +22 -0
- data/lib/zaws/external/awscli/data.rb +10 -0
- data/lib/zaws/external/awscli/data/ec2.rb +33 -0
- data/lib/zaws/external/awscli/data/ec2/instance.rb +162 -0
- data/lib/zaws/external/awscli/data/ec2/security_group.rb +51 -0
- data/lib/zaws/external/awscli/data/ec2/subnet.rb +59 -0
- data/lib/zaws/external/awscli/data/ec2/vpc.rb +85 -0
- data/lib/zaws/external/awscli/data/iam.rb +34 -0
- data/lib/zaws/external/awscli/data/iam/policy.rb +42 -0
- data/lib/zaws/external/awscli/data/iam/policy_document.rb +52 -0
- data/lib/zaws/external/awscli/data/iam/policy_version.rb +42 -0
- data/lib/zaws/external/awscli/data/iam/role_policy.rb +52 -0
- data/lib/zaws/external/awscli/generators/result/ec2/addresses.rb +70 -0
- data/lib/zaws/external/awscli/generators/result/ec2/allocation_id.rb +39 -0
- data/lib/zaws/external/awscli/generators/result/ec2/association_id.rb +29 -0
- data/lib/zaws/external/awscli/generators/result/ec2/images.rb +46 -0
- data/lib/zaws/external/awscli/generators/result/ec2/instances.rb +57 -0
- data/lib/zaws/external/awscli/generators/result/ec2/ip_permissions.rb +70 -0
- data/lib/zaws/external/awscli/generators/result/ec2/network_interfaces.rb +53 -0
- data/lib/zaws/external/awscli/generators/result/ec2/private_ip_addresses.rb +41 -0
- data/lib/zaws/external/awscli/generators/result/ec2/route_tables.rb +80 -0
- data/lib/zaws/external/awscli/generators/result/ec2/routes.rb +58 -0
- data/lib/zaws/external/awscli/generators/result/ec2/security_groups.rb +73 -0
- data/lib/zaws/external/awscli/generators/result/ec2/subnets.rb +88 -0
- data/lib/zaws/external/awscli/generators/result/ec2/tags.rb +34 -0
- data/lib/zaws/external/awscli/generators/result/ec2/virtual_gateway.rb +32 -0
- data/lib/zaws/external/awscli/generators/result/elb/listeners.rb +65 -0
- data/lib/zaws/external/awscli/generators/result/elb/load_balancers.rb +61 -0
- data/lib/zaws/external/awscli/generators/result/route53/hosted_zones.rb +52 -0
- data/lib/zaws/external/awscli/regions.rb +13 -0
- data/lib/zaws/external/nessusapi/data/agents.rb +36 -0
- data/lib/zaws/external/nessusapi/data/scanners.rb +35 -0
- data/lib/zaws/external/nessusapi/nessusapi.rb +57 -0
- data/lib/zaws/external/nessusapi/reources.rb +10 -0
- data/lib/zaws/external/nessusapi/resources/agents.rb +18 -0
- data/lib/zaws/external/nessusapi/resources/agents/list.rb +20 -0
- data/lib/zaws/external/nessusapi/resources/scanners.rb +18 -0
- data/lib/zaws/external/nessusapi/resources/scanners/list.rb +20 -0
- data/lib/zaws/external/newrelicapi/data/servers.rb +36 -0
- data/lib/zaws/external/newrelicapi/newrelic_client.rb +64 -0
- data/lib/zaws/external/newrelicapi/newrelic_creds.rb +60 -0
- data/lib/zaws/external/newrelicapi/newrelicapi.rb +46 -0
- data/lib/zaws/external/newrelicapi/resources/servers.rb +18 -0
- data/lib/zaws/external/newrelicapi/resources/servers/list.rb +20 -0
- data/lib/zaws/external/sumoapi/data/collectors.rb +35 -0
- data/lib/zaws/external/sumoapi/data/sources.rb +35 -0
- data/lib/zaws/external/sumoapi/resources/collectors.rb +18 -0
- data/lib/zaws/external/sumoapi/resources/collectors/list.rb +20 -0
- data/lib/zaws/external/sumoapi/resources/sources.rb +18 -0
- data/lib/zaws/external/sumoapi/resources/sources/list.rb +20 -0
- data/lib/zaws/external/sumoapi/sumo_client.rb +63 -0
- data/lib/zaws/external/sumoapi/sumo_creds.rb +67 -0
- data/lib/zaws/external/sumoapi/sumoapi.rb +56 -0
- data/lib/zaws/helper/data_lattice.rb +22 -0
- data/lib/zaws/helper/filestore.rb +48 -0
- data/lib/zaws/helper/filter.rb +15 -0
- data/lib/zaws/helper/inifile.rb +632 -0
- data/lib/zaws/helper/nessus_client.rb +143 -0
- data/lib/zaws/helper/nessus_creds.rb +67 -0
- data/lib/zaws/helper/option.rb +14 -15
- data/lib/zaws/helper/output.rb +81 -29
- data/lib/zaws/helper/process_hash.rb +47 -0
- data/lib/zaws/helper/shell.rb +0 -0
- data/lib/zaws/helper/verbose.rb +15 -0
- data/lib/zaws/helper/zfile.rb +8 -8
- data/lib/zaws/services/ai.rb +35 -0
- data/lib/zaws/services/ai/query.rb +135 -0
- data/lib/zaws/services/aws.rb +41 -0
- data/lib/zaws/services/chef.rb +0 -0
- data/lib/zaws/services/cloud_trail.rb +76 -0
- data/lib/zaws/services/config.rb +31 -0
- data/lib/zaws/services/ec2.rb +47 -0
- data/lib/zaws/services/ec2/compute.rb +352 -0
- data/lib/zaws/services/ec2/elasticip.rb +82 -0
- data/lib/zaws/services/ec2/route_table.rb +210 -0
- data/lib/zaws/services/ec2/security_group.rb +186 -0
- data/lib/zaws/services/ec2/subnet.rb +111 -0
- data/lib/zaws/services/ec2/vpc.rb +69 -0
- data/lib/zaws/{elb.rb → services/elb.rb} +3 -2
- data/lib/zaws/services/elb/load_balancer.rb +160 -0
- data/lib/zaws/services/iam.rb +25 -0
- data/lib/zaws/services/iam/policy.rb +25 -0
- data/lib/zaws/services/iam/role.rb +23 -0
- data/lib/zaws/services/nessus.rb +24 -0
- data/lib/zaws/services/nessus/agents.rb +19 -0
- data/lib/zaws/services/nessus/scanners.rb +19 -0
- data/lib/zaws/services/newrelic.rb +21 -0
- data/lib/zaws/services/newrelic/servers.rb +19 -0
- data/lib/zaws/{route53.rb → services/route53.rb} +1 -1
- data/lib/zaws/services/route53/hosted_zone.rb +36 -0
- data/lib/zaws/services/s3.rb +15 -0
- data/lib/zaws/services/s3/bucket.rb +42 -0
- data/lib/zaws/services/sumo.rb +21 -0
- data/lib/zaws/services/sumo/collectors.rb +19 -0
- data/lib/zaws/services/vmware.rb +0 -0
- data/lib/zaws/version.rb +1 -1
- data/shove_all.sh +6 -0
- data/shove_all_mac.sh +6 -0
- data/shove_all_windows.sh +6 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/zaws/command/ec2/compute/assoc_security_group_spec.rb +135 -0
- data/spec/zaws/command/ec2/compute/compute_spec.rb +321 -0
- data/spec/zaws/command/ec2/compute/images_spec.rb +69 -0
- data/spec/zaws/command/ec2/compute/management_spec.rb +364 -0
- data/spec/zaws/command/ec2/compute/network_spec.rb +93 -0
- data/spec/zaws/command/ec2/compute/node_spec.rb +70 -0
- data/spec/zaws/command/ec2/compute/secondary_ip_spec.rb +212 -0
- data/spec/zaws/command/ec2/compute/storage_spec.rb +63 -0
- data/spec/zaws/command/ec2/elasticip_spec.rb +271 -0
- data/spec/zaws/command/ec2/route_table_spec.rb +844 -0
- data/spec/zaws/command/ec2/security_group_spec.rb +710 -0
- data/spec/zaws/command/ec2/subnet_spec.rb +273 -0
- data/spec/zaws/command/ec2/vpc_spec.rb +180 -0
- data/spec/zaws/command/elb/load_balancer_spec.rb +633 -0
- data/spec/zaws/command/iam/policy_spec.rb +101 -0
- data/spec/zaws/command/iam/role_policy_spec.rb +35 -0
- data/spec/zaws/command/route53/hosted_zone_spec.rb +100 -0
- data/spec/zaws/command/s3/bucket_spec.rb +70 -0
- data/spec/zaws/external/awscli/data/ec2/instance_spec.rb +90 -0
- data/spec/zaws/external/awscli/data/iam/policy_document_spec.rb +56 -0
- data/spec/zaws/external/awscli/data/iam/role_policy_spec.rb +54 -0
- data/spec/zaws/external/awscli/get_aws_version_spec.rb +18 -0
- data/spec/zaws/helper/option_spec.rb +54 -0
- data/spec/zaws/helper/output_spec.rb +144 -0
- data/spec/zaws/helper/process_hash_spec.rb +48 -0
- data/spec/zaws/helper/shell_spec.rb +56 -0
- data/spec/zaws/nessus/scanners.json +0 -0
- data/spec/zaws/version_spec.rb +18 -0
- data/zaws.gemspec +1 -3
- metadata +260 -189
- data/feature/compute/assoc_security_group.feature +0 -55
- data/feature/compute/compute.feature +0 -138
- data/feature/compute/secondary_ip.feature +0 -107
- data/feature/compute/view.feature +0 -23
- data/feature/compute/view_images.feature +0 -24
- data/feature/elasticip/elasticip.feature +0 -138
- data/feature/elasticip/view.feature +0 -18
- data/feature/hosted_zone/view.feature +0 -17
- data/feature/hosted_zone/view_record.feature +0 -29
- data/feature/load_balancer/instance_registration.feature +0 -120
- data/feature/load_balancer/listener.feature +0 -86
- data/feature/load_balancer/load_balancer.feature +0 -101
- data/feature/load_balancer/view.feature +0 -18
- data/feature/route_table/assoc_subnet.feature +0 -128
- data/feature/route_table/route_propagation.feature +0 -93
- data/feature/route_table/route_table.feature +0 -91
- data/feature/route_table/route_to_gateway.feature +0 -69
- data/feature/route_table/route_to_instance.feature +0 -115
- data/feature/route_table/view.feature +0 -25
- data/feature/security_group/ingress_cidr.feature +0 -144
- data/feature/security_group/ingress_group.feature +0 -184
- data/feature/security_group/security_group.feature +0 -107
- data/feature/security_group/view.feature +0 -23
- data/feature/subnet/subnet.feature +0 -94
- data/feature/subnet/view.feature +0 -24
- data/feature/support/env.rb +0 -14
- data/feature/version.feature +0 -6
- data/lib/zaws/aws.rb +0 -26
- data/lib/zaws/ec2.rb +0 -40
- data/lib/zaws/ec2/compute.rb +0 -247
- data/lib/zaws/ec2/elasticip.rb +0 -79
- data/lib/zaws/ec2/route_table.rb +0 -207
- data/lib/zaws/ec2/security_group.rb +0 -154
- data/lib/zaws/ec2/subnet.rb +0 -109
- data/lib/zaws/elb/load_balancer.rb +0 -157
- data/lib/zaws/route53/hosted_zone.rb +0 -36
- data/spec/zaws/ec2/compute/add_volume_spec.rb +0 -39
- data/spec/zaws/ec2/compute/block_device_mapping_spec.rb +0 -31
- data/spec/zaws/ec2/compute/instance_id_by_external_id_spec.rb +0 -23
- data/spec/zaws/ec2/compute/instance_ping_spec.rb +0 -34
- data/spec/zaws/ec2/compute/instance_running_spec.rb +0 -47
- data/spec/zaws/ec2/compute/network_interface_json_spec.rb +0 -57
- data/spec/zaws/ec2/compute/nosdcheck_spec.rb +0 -17
- data/spec/zaws/ec2/compute/tag_instance_spec.rb +0 -21
- data/spec/zaws/ec2/security_group/id_by_name_spec.rb +0 -32
- data/spec/zaws/ec2/subnet/available_spec.rb +0 -22
- data/spec/zaws/ec2/subnet/declare_spec.rb +0 -31
- data/spec/zaws/ec2/subnet/exists_spec.rb +0 -33
- data/spec/zaws/ec2/subnet/id_array_by_cidrblock_array_spec.rb +0 -48
- data/spec/zaws/ec2/subnet/id_by_cidrblock_spec.rb +0 -35
- data/spec/zaws/ec2/subnet/id_by_ip_spec.rb +0 -42
- data/spec/zaws/ec2/subnet/view_spec.rb +0 -34
- data/spec/zaws/elb/load_balancer/calculated_listener_spec.rb +0 -18
- data/spec/zaws/helper/option/absent_spec.rb +0 -14
- data/spec/zaws/helper/option/exclusive_spec.rb +0 -14
- data/spec/zaws/helper/option/exists_spec.rb +0 -18
- data/spec/zaws/helper/option/minimum_spec.rb +0 -14
- data/spec/zaws/helper/output/binary_nagios_check_spec.rb +0 -19
- data/spec/zaws/helper/output/colorize_spec.rb +0 -30
- data/spec/zaws/helper/output/opt_exclusive_spec.rb +0 -14
- data/spec/zaws/helper/output/opt_minimum_spec.rb +0 -15
- data/spec/zaws/helper/output/opt_required_spec.rb +0 -12
- data/spec/zaws/helper/shell/cli_spec.rb +0 -33
- data/spec/zaws/helper/shell/if_then_spec.rb +0 -24
@@ -0,0 +1,844 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZAWS::Services::EC2::RouteTable do
|
4
|
+
|
5
|
+
let(:route_table_created) { ZAWS::Helper::Output.colorize("Route table created with external id: my_route_table.", AWS_consts::COLOR_YELLOW) }
|
6
|
+
let(:route_table_exist) { ZAWS::Helper::Output.colorize("Route table exists already. Skipping Creation.", AWS_consts::COLOR_GREEN) }
|
7
|
+
let(:route_table_not_deleted) { ZAWS::Helper::Output.colorize("Route table does not exist. Skipping deletion.", AWS_consts::COLOR_GREEN) }
|
8
|
+
let(:route_table_deleted) { ZAWS::Helper::Output.colorize("Route table deleted.", AWS_consts::COLOR_YELLOW) }
|
9
|
+
let(:route_table_ok) { ZAWS::Helper::Output.colorize("OK: Route table exists.", AWS_consts::COLOR_GREEN) }
|
10
|
+
let(:route_table_critical) { ZAWS::Helper::Output.colorize("CRITICAL: Route table does not exist.", AWS_consts::COLOR_RED) }
|
11
|
+
|
12
|
+
let(:route_created) { ZAWS::Helper::Output.colorize("Route created to instance.", AWS_consts::COLOR_YELLOW) }
|
13
|
+
let(:route_not_created) { ZAWS::Helper::Output.colorize("Route not created to instance. Skip creation.", AWS_consts::COLOR_GREEN) }
|
14
|
+
|
15
|
+
let(:ok_route_propagation) { ZAWS::Helper::Output.colorize("OK: Route propagation from gateway enabled.", AWS_consts::COLOR_GREEN) }
|
16
|
+
let(:critical_route_propagation) { ZAWS::Helper::Output.colorize("CRITICAL: Route propagation from gateway not enabled.", AWS_consts::COLOR_RED) }
|
17
|
+
|
18
|
+
let(:ok_declare_route) { ZAWS::Helper::Output.colorize("OK: Route to instance exists.", AWS_consts::COLOR_GREEN) }
|
19
|
+
let(:critical_declare_route) { ZAWS::Helper::Output.colorize("CRITICAL: Route to instance does not exist.", AWS_consts::COLOR_RED) }
|
20
|
+
|
21
|
+
let(:ok_assoc_subnet) { ZAWS::Helper::Output.colorize("OK: Route table association to subnet exists.", AWS_consts::COLOR_GREEN) }
|
22
|
+
let(:critical_assoc_subnet) { ZAWS::Helper::Output.colorize("CRITICAL: Route table association to subnet does not exist.", AWS_consts::COLOR_RED) }
|
23
|
+
|
24
|
+
let(:ok_declare_route_to_gateway) { ZAWS::Helper::Output.colorize("OK: Route to gateway exists.", AWS_consts::COLOR_GREEN) }
|
25
|
+
let(:critical_declare_route_to_gateway) { ZAWS::Helper::Output.colorize("CRITICAL: Route to gateway does not exist.", AWS_consts::COLOR_RED) }
|
26
|
+
|
27
|
+
let(:route_not_deleted) { ZAWS::Helper::Output.colorize("Route does not exist. Skipping deletion.", AWS_consts::COLOR_GREEN) }
|
28
|
+
let(:route_deleted) { ZAWS::Helper::Output.colorize("Route deleted.", AWS_consts::COLOR_YELLOW) }
|
29
|
+
|
30
|
+
let(:route_to_gateway_not_created) { ZAWS::Helper::Output.colorize("Route to gateway exists. Skipping creation.", AWS_consts::COLOR_GREEN) }
|
31
|
+
let(:route_to_gateway_created) { ZAWS::Helper::Output.colorize("Route created to gateway.", AWS_consts::COLOR_YELLOW) }
|
32
|
+
|
33
|
+
let(:route_propagated_to_gateway) { ZAWS::Helper::Output.colorize("Route propagation from gateway enabled.", AWS_consts::COLOR_YELLOW) }
|
34
|
+
let(:route_propagated_to_gateway_already) { ZAWS::Helper::Output.colorize("Route propagation from gateway already enabled. Skipping propagation.", AWS_consts::COLOR_GREEN) }
|
35
|
+
|
36
|
+
let(:delete_route_propagation_from_gateway) { ZAWS::Helper::Output.colorize("Deleted route propagation from gateway.", AWS_consts::COLOR_YELLOW) }
|
37
|
+
let(:not_delete_route_propagation_from_gateway) { ZAWS::Helper::Output.colorize("Route propagation from gateway does not exist, skipping deletion.", AWS_consts::COLOR_GREEN) }
|
38
|
+
|
39
|
+
let(:assoc_subnet_skipped) { ZAWS::Helper::Output.colorize("Route table already associated to subnet. Skipping association.", AWS_consts::COLOR_GREEN) }
|
40
|
+
let(:assoc_subnet_executed) { ZAWS::Helper::Output.colorize("Route table associated to subnet.", AWS_consts::COLOR_YELLOW) }
|
41
|
+
|
42
|
+
let(:assoc_subnet_not_deleted) { ZAWS::Helper::Output.colorize("Route table association to subnet not deleted because it does not exist.", AWS_consts::COLOR_GREEN) }
|
43
|
+
let(:assoc_subnet_deleted) { ZAWS::Helper::Output.colorize("Route table association to subnet deleted.", AWS_consts::COLOR_YELLOW) }
|
44
|
+
|
45
|
+
let(:region) { "us-west-1" }
|
46
|
+
let(:security_group_name) { "my_security_group_name" }
|
47
|
+
let(:security_group_id) { "sg-abcd1234" }
|
48
|
+
let(:output_json) { "json" }
|
49
|
+
let(:output_table) { "table" }
|
50
|
+
let(:vpc_id) { "my_vpc_id" }
|
51
|
+
let(:externalid_route_table) { "my_route_table" }
|
52
|
+
let(:route_table_id) { "rtb-XXXXXXX" }
|
53
|
+
let(:cidr) { "10.0.0.0/24" }
|
54
|
+
let(:vgw) { 'vgw-????????' }
|
55
|
+
let(:external_id) { "my_instance" }
|
56
|
+
let(:instance_id) { "i-12345678" }
|
57
|
+
let(:gateway_id) { "igw-XXXXXXX" }
|
58
|
+
let(:subnet_id) { "subnet-YYYYYY" }
|
59
|
+
let(:route_table_association_id) { "rtbassoc-????????" }
|
60
|
+
|
61
|
+
let (:describe_instances) {
|
62
|
+
tags = ZAWS::External::AWSCLI::Generators::Result::EC2::Tags.new
|
63
|
+
tags = tags.add("externalid", external_id)
|
64
|
+
desc_instances = ZAWS::External::AWSCLI::Commands::EC2::DescribeInstances.new
|
65
|
+
desc_instances.filter.vpc_id(vpc_id).tags(tags)
|
66
|
+
desc_instances.aws.output(output_json).region(region)
|
67
|
+
desc_instances
|
68
|
+
}
|
69
|
+
|
70
|
+
let (:instances) {
|
71
|
+
tags = ZAWS::External::AWSCLI::Generators::Result::EC2::Tags.new
|
72
|
+
tags = tags.add("externalid", external_id)
|
73
|
+
instances = ZAWS::External::AWSCLI::Generators::Result::EC2::Instances.new
|
74
|
+
instances.instance_id(0, instance_id).tags(0, tags)
|
75
|
+
}
|
76
|
+
|
77
|
+
let(:empty_route_tables) {
|
78
|
+
ZAWS::External::AWSCLI::Generators::Result::EC2::RouteTables.new
|
79
|
+
}
|
80
|
+
|
81
|
+
let(:single_route_tables) {
|
82
|
+
single_route_table=ZAWS::External::AWSCLI::Generators::Result::EC2::RouteTables.new
|
83
|
+
single_route_table.vpc_id(0, vpc_id).route_table_id(0, route_table_id)
|
84
|
+
}
|
85
|
+
|
86
|
+
let(:single_route_tables_with_gateway) {
|
87
|
+
routes=ZAWS::External::AWSCLI::Generators::Result::EC2::Routes.new
|
88
|
+
routes.gateway_id(0, gateway_id)
|
89
|
+
routes.destination_cidr_block(0, cidr)
|
90
|
+
single_route_table=ZAWS::External::AWSCLI::Generators::Result::EC2::RouteTables.new
|
91
|
+
single_route_table.vpc_id(0, vpc_id).route_table_id(0, route_table_id).routes(0, routes)
|
92
|
+
}
|
93
|
+
|
94
|
+
let(:single_route_tables_with_instance) {
|
95
|
+
routes=ZAWS::External::AWSCLI::Generators::Result::EC2::Routes.new
|
96
|
+
routes.instance_id(0, instance_id)
|
97
|
+
routes.destination_cidr_block(0, cidr)
|
98
|
+
single_route_table=ZAWS::External::AWSCLI::Generators::Result::EC2::RouteTables.new
|
99
|
+
single_route_table.vpc_id(0, vpc_id).route_table_id(0, route_table_id).routes(0, routes)
|
100
|
+
}
|
101
|
+
|
102
|
+
let(:single_route_tables_with_prop_gateway) {
|
103
|
+
virtualgw = ZAWS::External::AWSCLI::Generators::Result::EC2::VirtualGateway.new
|
104
|
+
single_route_table=ZAWS::External::AWSCLI::Generators::Result::EC2::RouteTables.new
|
105
|
+
virtualgw.gateway_id(vgw)
|
106
|
+
single_route_table.vpc_id(0, vpc_id).route_table_id(0, route_table_id).propagate_to_virtual_gateway(0, virtualgw)
|
107
|
+
}
|
108
|
+
|
109
|
+
let (:describe_route_tables) {
|
110
|
+
tags = ZAWS::External::AWSCLI::Generators::Result::EC2::Tags.new
|
111
|
+
tags = tags.add("externalid", externalid_route_table)
|
112
|
+
desc_route_tables = ZAWS::External::AWSCLI::Commands::EC2::DescribeRouteTables.new
|
113
|
+
desc_route_tables.filter.vpc_id(vpc_id).tags(tags)
|
114
|
+
desc_route_tables.aws.output(output_json).region(region)
|
115
|
+
desc_route_tables
|
116
|
+
}
|
117
|
+
|
118
|
+
let(:create_route_table) {
|
119
|
+
create_route_table = ZAWS::External::AWSCLI::Commands::EC2::CreateRouteTable.new
|
120
|
+
create_route_table.vpc_id(vpc_id)
|
121
|
+
create_route_table.aws.region(region)
|
122
|
+
create_route_table
|
123
|
+
}
|
124
|
+
|
125
|
+
let(:delete_route_table) {
|
126
|
+
drt = ZAWS::External::AWSCLI::Commands::EC2::DeleteRouteTable.new
|
127
|
+
drt.route_table_id(route_table_id)
|
128
|
+
drt.aws.region(region)
|
129
|
+
drt
|
130
|
+
}
|
131
|
+
|
132
|
+
let(:create_tags) {
|
133
|
+
tags = ZAWS::External::AWSCLI::Generators::Result::EC2::Tags.new
|
134
|
+
tags = tags.add("externalid", externalid_route_table)
|
135
|
+
create_tags = ZAWS::External::AWSCLI::Commands::EC2::CreateTags.new
|
136
|
+
create_tags.resource(route_table_id).tags(tags)
|
137
|
+
create_tags.aws.region(region)
|
138
|
+
create_tags
|
139
|
+
}
|
140
|
+
|
141
|
+
let(:single_subnets) {
|
142
|
+
subnets = ZAWS::External::AWSCLI::Generators::Result::EC2::Subnets.new
|
143
|
+
subnets.subnet_id(0, subnet_id).route_table_association_id(0,route_table_association_id)
|
144
|
+
}
|
145
|
+
|
146
|
+
let(:single_route_tables_with_associations) {
|
147
|
+
single_route_table=ZAWS::External::AWSCLI::Generators::Result::EC2::RouteTables.new
|
148
|
+
single_route_table.vpc_id(0, vpc_id).route_table_id(0, route_table_id).associate_subnets(0, single_subnets)
|
149
|
+
}
|
150
|
+
|
151
|
+
let(:describe_subnets) {
|
152
|
+
desc_subnets = ZAWS::External::AWSCLI::Commands::EC2::DescribeSubnets.new
|
153
|
+
desc_subnets.filter.vpc_id(vpc_id).cidr(cidr)
|
154
|
+
desc_subnets.aws.output("json").region(region)
|
155
|
+
desc_subnets
|
156
|
+
}
|
157
|
+
|
158
|
+
let(:create_route) {
|
159
|
+
cr = ZAWS::External::AWSCLI::Commands::EC2::CreateRoute.new
|
160
|
+
cr.aws.region(region)
|
161
|
+
cr.route_table_id(route_table_id).destination_cidr_block(cidr).instance_id(instance_id)
|
162
|
+
}
|
163
|
+
|
164
|
+
let(:create_route_to_gateway) {
|
165
|
+
cr = ZAWS::External::AWSCLI::Commands::EC2::CreateRoute.new
|
166
|
+
cr.aws.region(region)
|
167
|
+
cr.route_table_id(route_table_id).destination_cidr_block(cidr).gateway_id(gateway_id)
|
168
|
+
}
|
169
|
+
|
170
|
+
let(:associate_route_table) {
|
171
|
+
art = ZAWS::External::AWSCLI::Commands::EC2::AssociateRouteTable.new
|
172
|
+
art.aws.region(region)
|
173
|
+
art.route_table_id(route_table_id).subnet_id(subnet_id)
|
174
|
+
}
|
175
|
+
|
176
|
+
let(:disassociate_route_table) {
|
177
|
+
art = ZAWS::External::AWSCLI::Commands::EC2::DisassociateRouteTable.new
|
178
|
+
art.aws.region(region)
|
179
|
+
art.association_id(route_table_association_id)
|
180
|
+
}
|
181
|
+
|
182
|
+
let(:delete_route) {
|
183
|
+
cr = ZAWS::External::AWSCLI::Commands::EC2::DeleteRoute.new
|
184
|
+
cr.aws.region(region)
|
185
|
+
cr.route_table_id(route_table_id).destination_cidr_block(cidr)
|
186
|
+
}
|
187
|
+
|
188
|
+
let(:create_route_to_gateway) {
|
189
|
+
cr = ZAWS::External::AWSCLI::Commands::EC2::CreateRoute.new
|
190
|
+
cr.aws.region(region)
|
191
|
+
cr.route_table_id(route_table_id).destination_cidr_block(cidr).gateway_id(gateway_id)
|
192
|
+
}
|
193
|
+
|
194
|
+
let(:enable_vgw_route_propagation) {
|
195
|
+
evrp = ZAWS::External::AWSCLI::Commands::EC2::EnableVgwRoutePropagation.new
|
196
|
+
evrp.aws.region(region)
|
197
|
+
evrp.route_table_id(route_table_id).gateway_id('vgw-????????')
|
198
|
+
}
|
199
|
+
|
200
|
+
let(:disable_vgw_route_propagation) {
|
201
|
+
dvrp = ZAWS::External::AWSCLI::Commands::EC2::DisableVgwRoutePropagation.new
|
202
|
+
dvrp.aws.region(region)
|
203
|
+
dvrp.route_table_id(route_table_id).gateway_id('vgw-????????')
|
204
|
+
}
|
205
|
+
|
206
|
+
before(:each) {
|
207
|
+
|
208
|
+
@var_security_group_id="sg-abcd1234"
|
209
|
+
@var_output_json="json"
|
210
|
+
@var_output_table="table"
|
211
|
+
@var_region="us-west-1"
|
212
|
+
@var_vpc_id="my_vpc_id"
|
213
|
+
@var_sec_group_name="my_security_group_name"
|
214
|
+
|
215
|
+
|
216
|
+
options_json = {:region => @var_region,
|
217
|
+
:verbose => false,
|
218
|
+
:check => false,
|
219
|
+
:undofile => false,
|
220
|
+
:viewtype => 'json'
|
221
|
+
}
|
222
|
+
|
223
|
+
options = {:region => @var_region,
|
224
|
+
:verbose => false,
|
225
|
+
:check => false,
|
226
|
+
:undofile => false
|
227
|
+
}
|
228
|
+
|
229
|
+
options_json_vpcid = {:region => @var_region,
|
230
|
+
:verbose => false,
|
231
|
+
:check => false,
|
232
|
+
:undofile => false,
|
233
|
+
:viewtype => 'json',
|
234
|
+
:vpcid => @var_vpc_id
|
235
|
+
|
236
|
+
}
|
237
|
+
|
238
|
+
options_json_vpcid_check = {:region => @var_region,
|
239
|
+
:verbose => false,
|
240
|
+
:check => true,
|
241
|
+
:undofile => false,
|
242
|
+
:viewtype => 'json',
|
243
|
+
:vpcid => @var_vpc_id
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
options_json_vpcid_undo = {:region => @var_region,
|
248
|
+
:verbose => false,
|
249
|
+
:check => false,
|
250
|
+
:undofile => 'undo.sh',
|
251
|
+
:viewtype => 'json',
|
252
|
+
:vpcid => @var_vpc_id
|
253
|
+
|
254
|
+
}
|
255
|
+
|
256
|
+
options_table = {:region => @var_region,
|
257
|
+
:verbose => false,
|
258
|
+
:check => false,
|
259
|
+
:undofile => false,
|
260
|
+
:viewtype => 'table'
|
261
|
+
}
|
262
|
+
|
263
|
+
|
264
|
+
@textout=double('outout')
|
265
|
+
@shellout=double('ZAWS::Helper::Shell')
|
266
|
+
@undofile=double('ZAWS::Helper::ZFile')
|
267
|
+
@aws=ZAWS::AWS.new(@shellout, ZAWS::AWSCLI.new(@shellout, true), @undofile)
|
268
|
+
@command_route_table_noview = ZAWS::Command::Route_Table.new([], options, {})
|
269
|
+
@command_route_table_noview.aws=@aws
|
270
|
+
@command_route_table_noview.out=@textout
|
271
|
+
@command_route_table_noview.print_exit_code = true
|
272
|
+
|
273
|
+
@command_route_table = ZAWS::Command::Route_Table.new([], options_table, {})
|
274
|
+
@command_route_table.aws=@aws
|
275
|
+
@command_route_table.out=@textout
|
276
|
+
@command_route_table.print_exit_code = true
|
277
|
+
@command_route_table_json = ZAWS::Command::Route_Table.new([], options_json, {})
|
278
|
+
@command_route_table_json.aws=@aws
|
279
|
+
@command_route_table_json.out=@textout
|
280
|
+
@command_route_table_json.print_exit_code = true
|
281
|
+
@command_route_table_json_vpcid = ZAWS::Command::Route_Table.new([], options_json_vpcid, {})
|
282
|
+
@command_route_table_json_vpcid.aws=@aws
|
283
|
+
@command_route_table_json_vpcid.out=@textout
|
284
|
+
@command_route_table_json_vpcid.print_exit_code = true
|
285
|
+
|
286
|
+
@command_route_table_json_vpcid_check = ZAWS::Command::Route_Table.new([], options_json_vpcid_check, {})
|
287
|
+
@command_route_table_json_vpcid_check.aws=@aws
|
288
|
+
@command_route_table_json_vpcid_check.out=@textout
|
289
|
+
@command_route_table_json_vpcid_check.print_exit_code = true
|
290
|
+
|
291
|
+
@command_route_table_json_vpcid_undo = ZAWS::Command::Route_Table.new([], options_json_vpcid_undo, {})
|
292
|
+
@command_route_table_json_vpcid_undo.aws=@aws
|
293
|
+
@command_route_table_json_vpcid_undo.out=@textout
|
294
|
+
@command_route_table_json_vpcid_undo.print_exit_code = true
|
295
|
+
|
296
|
+
}
|
297
|
+
|
298
|
+
describe "#view" do
|
299
|
+
|
300
|
+
it "Get route table in a human readable table." do
|
301
|
+
desc_route_tbls = ZAWS::External::AWSCLI::Commands::EC2::DescribeRouteTables.new
|
302
|
+
aws_command = ZAWS::External::AWSCLI::Commands::AWS.new
|
303
|
+
aws_command = aws_command.output(@var_output_table).region(@var_region).subcommand(desc_route_tbls)
|
304
|
+
expect(@shellout).to receive(:cli).with(aws_command.get_command, nil).ordered.and_return('test output')
|
305
|
+
expect(@textout).to receive(:puts).with('test output').ordered
|
306
|
+
@command_route_table.view
|
307
|
+
end
|
308
|
+
|
309
|
+
it "Get route table in JSON form" do
|
310
|
+
desc_route_tbls = ZAWS::External::AWSCLI::Commands::EC2::DescribeRouteTables.new
|
311
|
+
aws_command = ZAWS::External::AWSCLI::Commands::AWS.new
|
312
|
+
aws_command = aws_command.output(@var_output_json).region(@var_region).subcommand(desc_route_tbls)
|
313
|
+
expect(@shellout).to receive(:cli).with(aws_command.get_command, nil).ordered.and_return('test output')
|
314
|
+
expect(@textout).to receive(:puts).with('test output').ordered
|
315
|
+
@command_route_table_json.view
|
316
|
+
end
|
317
|
+
|
318
|
+
it "Get route table from specified vpcid" do
|
319
|
+
desc_route_tbls = ZAWS::External::AWSCLI::Commands::EC2::DescribeRouteTables.new
|
320
|
+
desc_route_tbls.filter.vpc_id(@var_vpc_id)
|
321
|
+
desc_route_tbls.aws.output(@var_output_json).region(@var_region).subcommand(desc_route_tbls)
|
322
|
+
expect(@shellout).to receive(:cli).with(desc_route_tbls.aws.get_command, nil).ordered.and_return('test output')
|
323
|
+
expect(@textout).to receive(:puts).with('test output').ordered
|
324
|
+
@command_route_table_json_vpcid.view
|
325
|
+
end
|
326
|
+
|
327
|
+
end
|
328
|
+
|
329
|
+
describe "#exists_by_external_id" do
|
330
|
+
context "route table does not exist" do
|
331
|
+
it "Determine a route table DOES NOT exists by external id" do
|
332
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(empty_route_tables.get_json)
|
333
|
+
expect(@textout).to receive(:puts).with('false')
|
334
|
+
@command_route_table_json_vpcid.exists_by_external_id(externalid_route_table)
|
335
|
+
end
|
336
|
+
end
|
337
|
+
context "route table does exist" do
|
338
|
+
it "Determine a route table exists by external id" do
|
339
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
340
|
+
expect(@textout).to receive(:puts).with('true')
|
341
|
+
@command_route_table_json_vpcid.exists_by_external_id(externalid_route_table)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
describe "#declare" do
|
347
|
+
|
348
|
+
context "route table does not exist by external id" do
|
349
|
+
it "create route table by external id" do
|
350
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(empty_route_tables.get_json)
|
351
|
+
expect(@shellout).to receive(:cli).with(create_route_table.aws.get_command, nil).and_return(single_route_tables.get_json_single_route_table(0))
|
352
|
+
expect(@shellout).to receive(:cli).with(create_tags.aws.get_command, nil).and_return('{ "return": "true" }')
|
353
|
+
expect(@textout).to receive(:puts).with(route_table_created)
|
354
|
+
begin
|
355
|
+
@command_route_table_json_vpcid.declare(externalid_route_table, vpc_id)
|
356
|
+
rescue SystemExit => e
|
357
|
+
expect(e.status).to eq(0)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
context "route table does not exist by external id and check flag present" do
|
362
|
+
it "check returns critical" do
|
363
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(empty_route_tables.get_json)
|
364
|
+
expect(@textout).to receive(:puts).with(route_table_critical)
|
365
|
+
begin
|
366
|
+
@command_route_table_json_vpcid_check.declare(externalid_route_table, vpc_id)
|
367
|
+
rescue SystemExit => e
|
368
|
+
expect(e.status).to eq(2)
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
context "route table does exist" do
|
374
|
+
it "does not create the route table" do
|
375
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
376
|
+
expect(@textout).to receive(:puts).with(route_table_exist)
|
377
|
+
begin
|
378
|
+
@command_route_table_json_vpcid.declare(externalid_route_table, vpc_id)
|
379
|
+
rescue SystemExit => e
|
380
|
+
expect(e.status).to eq(0)
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
context "route table does exist and check flag present" do
|
385
|
+
it "check returns ok" do
|
386
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
387
|
+
expect(@textout).to receive(:puts).with(route_table_ok)
|
388
|
+
begin
|
389
|
+
@command_route_table_json_vpcid_check.declare(externalid_route_table, vpc_id)
|
390
|
+
rescue SystemExit => e
|
391
|
+
expect(e.status).to eq(0)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
|
397
|
+
context "undo file provided and route table exists" do
|
398
|
+
it "output delete statement to undo file" do
|
399
|
+
expect(@undofile).to receive(:prepend).with("zaws route_table delete #{externalid_route_table} --region #{region} --vpcid #{vpc_id} $XTRA_OPTS", '#Delete route table', 'undo.sh')
|
400
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).ordered.and_return(single_route_tables.get_json)
|
401
|
+
expect(@textout).to receive(:puts).with(route_table_exist)
|
402
|
+
begin
|
403
|
+
@command_route_table_json_vpcid_undo.declare(externalid_route_table, vpc_id)
|
404
|
+
rescue SystemExit => e
|
405
|
+
expect(e.status).to eq(0)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
end
|
411
|
+
|
412
|
+
describe "#delete" do
|
413
|
+
context "route table does not exist by external id" do
|
414
|
+
it "does nothing" do
|
415
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(empty_route_tables.get_json)
|
416
|
+
expect(@textout).to receive(:puts).with(route_table_not_deleted)
|
417
|
+
@command_route_table_json_vpcid.delete(externalid_route_table)
|
418
|
+
end
|
419
|
+
end
|
420
|
+
context "route table does exist by external id" do
|
421
|
+
it "delete route table" do
|
422
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
423
|
+
expect(@shellout).to receive(:cli).with(delete_route_table.aws.get_command, nil).and_return('{ "return": "true" }')
|
424
|
+
expect(@textout).to receive(:puts).with(route_table_deleted)
|
425
|
+
@command_route_table_json_vpcid.delete(externalid_route_table)
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
|
431
|
+
describe "#subnet_assoc_exists" do
|
432
|
+
context "subnet is associated to a route table " do
|
433
|
+
it "returns true" do
|
434
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
435
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_associations.get_json)
|
436
|
+
expect(@textout).to receive(:puts).with('true')
|
437
|
+
@command_route_table_json_vpcid.subnet_assoc_exists(externalid_route_table, cidr)
|
438
|
+
end
|
439
|
+
end
|
440
|
+
context "subnet is associated to a route table " do
|
441
|
+
it "returns true" do
|
442
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
443
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
444
|
+
expect(@textout).to receive(:puts).with('false')
|
445
|
+
@command_route_table_json_vpcid.subnet_assoc_exists(externalid_route_table, cidr)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
describe "#delete_assoc_subnet" do
|
451
|
+
context "Route table association to subnet does not exists." do
|
452
|
+
it "Skip deletion" do
|
453
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
454
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
455
|
+
expect(@textout).to receive(:puts).with(assoc_subnet_not_deleted)
|
456
|
+
begin
|
457
|
+
@command_route_table_json_vpcid.delete_assoc_subnet(externalid_route_table, cidr)
|
458
|
+
rescue SystemExit => e
|
459
|
+
expect(e.status).to eq(0)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
end
|
463
|
+
context "Route table association to subnet exists." do
|
464
|
+
it "Delete association" do
|
465
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
466
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_associations.get_json)
|
467
|
+
expect(@shellout).to receive(:cli).with(disassociate_route_table.aws.get_command, nil).and_return('{ "return" : "true" }')
|
468
|
+
expect(@textout).to receive(:puts).with(assoc_subnet_deleted)
|
469
|
+
begin
|
470
|
+
@command_route_table_json_vpcid.delete_assoc_subnet(externalid_route_table, cidr)
|
471
|
+
rescue SystemExit => e
|
472
|
+
expect(e.status).to eq(0)
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
describe "#assoc_subnet" do
|
479
|
+
context "Route table association to subnet exists." do
|
480
|
+
it "skips association" do
|
481
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
482
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_associations.get_json)
|
483
|
+
expect(@textout).to receive(:puts).with(assoc_subnet_skipped)
|
484
|
+
begin
|
485
|
+
@command_route_table_json_vpcid.assoc_subnet(externalid_route_table, cidr)
|
486
|
+
rescue SystemExit => e
|
487
|
+
expect(e.status).to eq(0)
|
488
|
+
end
|
489
|
+
end
|
490
|
+
end
|
491
|
+
context "Route table association to subnet does not exists." do
|
492
|
+
it "associate route table to subnet" do
|
493
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
494
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
495
|
+
expect(@shellout).to receive(:cli).with(associate_route_table.aws.get_command, nil).and_return('{ "AssociationId": "rtbassoc-???????" }')
|
496
|
+
expect(@textout).to receive(:puts).with(assoc_subnet_executed)
|
497
|
+
begin
|
498
|
+
@command_route_table_json_vpcid.assoc_subnet(externalid_route_table, cidr)
|
499
|
+
rescue SystemExit => e
|
500
|
+
expect(e.status).to eq(0)
|
501
|
+
end
|
502
|
+
end
|
503
|
+
end
|
504
|
+
context "Undo file set, and route table association to subnet exists." do
|
505
|
+
it "Writes to undo file skips association" do
|
506
|
+
expect(@undofile).to receive(:prepend).with("zaws route_table delete_assoc_subnet #{externalid_route_table} #{cidr} --region #{region} --vpcid #{vpc_id} $XTRA_OPTS", '#Delete route table association to subnet', 'undo.sh')
|
507
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
508
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_associations.get_json)
|
509
|
+
expect(@textout).to receive(:puts).with(assoc_subnet_skipped)
|
510
|
+
begin
|
511
|
+
@command_route_table_json_vpcid_undo.assoc_subnet(externalid_route_table, cidr)
|
512
|
+
rescue SystemExit => e
|
513
|
+
expect(e.status).to eq(0)
|
514
|
+
end
|
515
|
+
end
|
516
|
+
end
|
517
|
+
context "Route table association to subnet exists." do
|
518
|
+
it "return ok" do
|
519
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
520
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_associations.get_json)
|
521
|
+
expect(@textout).to receive(:puts).with(ok_assoc_subnet)
|
522
|
+
begin
|
523
|
+
@command_route_table_json_vpcid_check.assoc_subnet(externalid_route_table, cidr)
|
524
|
+
rescue SystemExit => e
|
525
|
+
expect(e.status).to eq(0)
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
context "Route table association to subnet does not exists." do
|
530
|
+
it "return critical" do
|
531
|
+
expect(@shellout).to receive(:cli).with(describe_subnets.aws.get_command, nil).and_return(single_subnets.get_json)
|
532
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
533
|
+
expect(@textout).to receive(:puts).with(critical_assoc_subnet)
|
534
|
+
begin
|
535
|
+
@command_route_table_json_vpcid_check.assoc_subnet(externalid_route_table, cidr)
|
536
|
+
rescue SystemExit => e
|
537
|
+
expect(e.status).to eq(2)
|
538
|
+
end
|
539
|
+
end
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
describe "#propagation_exists_from_gateway" do
|
544
|
+
context "route table propagates to virtual gatway already" do
|
545
|
+
it "return true" do
|
546
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_prop_gateway.get_json)
|
547
|
+
expect(@textout).to receive(:puts).with('true')
|
548
|
+
@command_route_table_json_vpcid_check.propagation_exists_from_gateway(externalid_route_table, vgw)
|
549
|
+
end
|
550
|
+
end
|
551
|
+
context "check flag is set and route table is not propagating to virtual gatway" do
|
552
|
+
it "check critical" do
|
553
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
554
|
+
expect(@textout).to receive(:puts).with('false')
|
555
|
+
@command_route_table_json_vpcid_check.propagation_exists_from_gateway(externalid_route_table, vgw)
|
556
|
+
end
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
560
|
+
describe "#delete_propagation_from_gateway" do
|
561
|
+
context "route table propagates to virtual gatway currently" do
|
562
|
+
it "delete propagation" do
|
563
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_prop_gateway.get_json)
|
564
|
+
expect(@shellout).to receive(:cli).with(disable_vgw_route_propagation.aws.get_command, nil).and_return('{ "return": "true" }')
|
565
|
+
expect(@textout).to receive(:puts).with(delete_route_propagation_from_gateway)
|
566
|
+
begin
|
567
|
+
@command_route_table_json_vpcid.delete_propagation_from_gateway(externalid_route_table, vgw)
|
568
|
+
rescue SystemExit => e
|
569
|
+
expect(e.status).to eq(0)
|
570
|
+
end
|
571
|
+
|
572
|
+
end
|
573
|
+
end
|
574
|
+
context "route table is not propagating to virtual gatway" do
|
575
|
+
it "skip deletion" do
|
576
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
577
|
+
expect(@textout).to receive(:puts).with(not_delete_route_propagation_from_gateway)
|
578
|
+
begin
|
579
|
+
@command_route_table_json_vpcid.delete_propagation_from_gateway(externalid_route_table, vgw)
|
580
|
+
rescue SystemExit => e
|
581
|
+
expect(e.status).to eq(0)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
end
|
585
|
+
end
|
586
|
+
|
587
|
+
describe "#declare_propagation_from_gateway" do
|
588
|
+
context "undo flag specified and route table propagates to virtual gatway already" do
|
589
|
+
it "undo file written to" do
|
590
|
+
expect(@undofile).to receive(:prepend).with("zaws route_table delete_propagation_from_gateway my_route_table #{vgw} --region #{region} --vpcid #{vpc_id} $XTRA_OPTS", '#Delete route propagation', 'undo.sh')
|
591
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_prop_gateway.get_json)
|
592
|
+
expect(@textout).to receive(:puts).with(route_propagated_to_gateway_already)
|
593
|
+
begin
|
594
|
+
@command_route_table_json_vpcid_undo.declare_propagation_from_gateway(externalid_route_table, vgw)
|
595
|
+
rescue SystemExit => e
|
596
|
+
expect(e.status).to eq(0)
|
597
|
+
end
|
598
|
+
|
599
|
+
end
|
600
|
+
end
|
601
|
+
context "route table propagates to virtual gatway already" do
|
602
|
+
it "skip propagation" do
|
603
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_prop_gateway.get_json)
|
604
|
+
expect(@textout).to receive(:puts).with(route_propagated_to_gateway_already)
|
605
|
+
begin
|
606
|
+
@command_route_table_json_vpcid.declare_propagation_from_gateway(externalid_route_table, vgw)
|
607
|
+
rescue SystemExit => e
|
608
|
+
expect(e.status).to eq(0)
|
609
|
+
end
|
610
|
+
|
611
|
+
end
|
612
|
+
end
|
613
|
+
context "route table is not propagating to virtual gatway" do
|
614
|
+
it "setup propagation" do
|
615
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
616
|
+
expect(@shellout).to receive(:cli).with(enable_vgw_route_propagation.aws.get_command, nil).and_return('{ "return": "true" }')
|
617
|
+
expect(@textout).to receive(:puts).with(route_propagated_to_gateway)
|
618
|
+
begin
|
619
|
+
@command_route_table_json_vpcid.declare_propagation_from_gateway(externalid_route_table, vgw)
|
620
|
+
rescue SystemExit => e
|
621
|
+
expect(e.status).to eq(0)
|
622
|
+
end
|
623
|
+
end
|
624
|
+
end
|
625
|
+
context "check flag is set and route table propagates to virtual gatway already" do
|
626
|
+
it "check ok" do
|
627
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_prop_gateway.get_json)
|
628
|
+
|
629
|
+
expect(@textout).to receive(:puts).with(ok_route_propagation)
|
630
|
+
begin
|
631
|
+
@command_route_table_json_vpcid_check.declare_propagation_from_gateway(externalid_route_table, vgw)
|
632
|
+
rescue SystemExit => e
|
633
|
+
expect(e.status).to eq(0)
|
634
|
+
end
|
635
|
+
|
636
|
+
end
|
637
|
+
end
|
638
|
+
context "check flag is set and route table is not propagating to virtual gatway" do
|
639
|
+
it "check critical" do
|
640
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
641
|
+
expect(@textout).to receive(:puts).with(critical_route_propagation)
|
642
|
+
begin
|
643
|
+
@command_route_table_json_vpcid_check.declare_propagation_from_gateway(externalid_route_table, vgw)
|
644
|
+
rescue SystemExit => e
|
645
|
+
expect(e.status).to eq(2)
|
646
|
+
end
|
647
|
+
end
|
648
|
+
end
|
649
|
+
end
|
650
|
+
|
651
|
+
describe "#route_exists_by_instance" do
|
652
|
+
context "subnet is associated to a route table " do
|
653
|
+
it "returns true" do
|
654
|
+
expect(@shellout).to receive(:cli).with(describe_instances.aws.get_command, nil).and_return(instances.get_json)
|
655
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_instance.get_json)
|
656
|
+
expect(@textout).to receive(:puts).with('true')
|
657
|
+
@command_route_table_json_vpcid.route_exists_by_instance(externalid_route_table, cidr, external_id)
|
658
|
+
end
|
659
|
+
end
|
660
|
+
context "subnet is associated to a route table " do
|
661
|
+
it "returns true" do
|
662
|
+
expect(@shellout).to receive(:cli).with(describe_instances.aws.get_command, nil).and_return(instances.get_json)
|
663
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
664
|
+
expect(@textout).to receive(:puts).with('false')
|
665
|
+
@command_route_table_json_vpcid.route_exists_by_instance(externalid_route_table, cidr, external_id)
|
666
|
+
end
|
667
|
+
end
|
668
|
+
end
|
669
|
+
|
670
|
+
describe "#delete_route" do
|
671
|
+
context "route exists" do
|
672
|
+
it "delete route" do
|
673
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_instance.get_json)
|
674
|
+
expect(@shellout).to receive(:cli).with(delete_route.aws.get_command, nil).and_return('{ "return" : "true" }')
|
675
|
+
expect(@textout).to receive(:puts).with(route_deleted)
|
676
|
+
begin
|
677
|
+
@command_route_table_json_vpcid.delete_route(externalid_route_table, cidr)
|
678
|
+
rescue SystemExit => e
|
679
|
+
expect(e.status).to eq(0)
|
680
|
+
end
|
681
|
+
|
682
|
+
end
|
683
|
+
end
|
684
|
+
context "route does not exists" do
|
685
|
+
it "skip deletion" do
|
686
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
687
|
+
expect(@textout).to receive(:puts).with(route_not_deleted)
|
688
|
+
begin
|
689
|
+
@command_route_table_json_vpcid.delete_route(externalid_route_table, cidr)
|
690
|
+
rescue SystemExit => e
|
691
|
+
expect(e.status).to eq(0)
|
692
|
+
end
|
693
|
+
end
|
694
|
+
end
|
695
|
+
|
696
|
+
end
|
697
|
+
|
698
|
+
describe "#declare_route" do
|
699
|
+
context "route exists" do
|
700
|
+
it "skip route creation" do
|
701
|
+
expect(@shellout).to receive(:cli).with(describe_instances.aws.get_command, nil).and_return(instances.get_json)
|
702
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_instance.get_json)
|
703
|
+
expect(@textout).to receive(:puts).with(route_not_created)
|
704
|
+
begin
|
705
|
+
@command_route_table_json_vpcid.declare_route(externalid_route_table, cidr, external_id)
|
706
|
+
rescue SystemExit => e
|
707
|
+
expect(e.status).to eq(0)
|
708
|
+
end
|
709
|
+
|
710
|
+
end
|
711
|
+
end
|
712
|
+
context "undo file provided and route table exists" do
|
713
|
+
it "output delete statement to undo file" do
|
714
|
+
expect(@undofile).to receive(:prepend).with("zaws route_table delete_route #{externalid_route_table} #{cidr} --region #{region} --vpcid #{vpc_id} $XTRA_OPTS", '#Delete route', 'undo.sh')
|
715
|
+
expect(@shellout).to receive(:cli).with(describe_instances.aws.get_command, nil).and_return(instances.get_json)
|
716
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_instance.get_json)
|
717
|
+
expect(@textout).to receive(:puts).with(route_not_created)
|
718
|
+
begin
|
719
|
+
@command_route_table_json_vpcid_undo.declare_route(externalid_route_table, cidr, external_id)
|
720
|
+
rescue SystemExit => e
|
721
|
+
expect(e.status).to eq(0)
|
722
|
+
end
|
723
|
+
|
724
|
+
end
|
725
|
+
end
|
726
|
+
context "route does not exists" do
|
727
|
+
it "create route" do
|
728
|
+
expect(@shellout).to receive(:cli).with(describe_instances.aws.get_command, nil).and_return(instances.get_json)
|
729
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
730
|
+
expect(@shellout).to receive(:cli).with(create_route.aws.get_command, nil).and_return('{ "return": "true" }')
|
731
|
+
expect(@textout).to receive(:puts).with(route_created)
|
732
|
+
begin
|
733
|
+
@command_route_table_json_vpcid.declare_route(externalid_route_table, cidr, external_id)
|
734
|
+
rescue SystemExit => e
|
735
|
+
expect(e.status).to eq(0)
|
736
|
+
end
|
737
|
+
end
|
738
|
+
end
|
739
|
+
context "check flag is set and route exists" do
|
740
|
+
it "check ok" do
|
741
|
+
expect(@shellout).to receive(:cli).with(describe_instances.aws.get_command, nil).and_return(instances.get_json)
|
742
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_instance.get_json)
|
743
|
+
expect(@textout).to receive(:puts).with(ok_declare_route)
|
744
|
+
begin
|
745
|
+
@command_route_table_json_vpcid_check.declare_route(externalid_route_table, cidr, external_id)
|
746
|
+
rescue SystemExit => e
|
747
|
+
expect(e.status).to eq(0)
|
748
|
+
end
|
749
|
+
|
750
|
+
end
|
751
|
+
end
|
752
|
+
context "check flag is set and route does not exists" do
|
753
|
+
it "check critical" do
|
754
|
+
expect(@shellout).to receive(:cli).with(describe_instances.aws.get_command, nil).and_return(instances.get_json)
|
755
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
756
|
+
expect(@textout).to receive(:puts).with(critical_declare_route)
|
757
|
+
begin
|
758
|
+
@command_route_table_json_vpcid_check.declare_route(externalid_route_table, cidr, external_id)
|
759
|
+
rescue SystemExit => e
|
760
|
+
expect(e.status).to eq(2)
|
761
|
+
end
|
762
|
+
end
|
763
|
+
end
|
764
|
+
end
|
765
|
+
|
766
|
+
describe "#route_exists_by_gatewayid" do
|
767
|
+
context "a route does exist to a gateway" do
|
768
|
+
it "returns true" do
|
769
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_gateway.get_json)
|
770
|
+
expect(@textout).to receive(:puts).with('true')
|
771
|
+
@command_route_table_json_vpcid.route_exists_by_gatewayid(externalid_route_table, cidr, gateway_id)
|
772
|
+
end
|
773
|
+
end
|
774
|
+
context "a route does not exist to a gateway" do
|
775
|
+
it "returns true" do
|
776
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
777
|
+
expect(@textout).to receive(:puts).with('false')
|
778
|
+
@command_route_table_json_vpcid.route_exists_by_gatewayid(externalid_route_table, cidr, gateway_id)
|
779
|
+
end
|
780
|
+
end
|
781
|
+
end
|
782
|
+
|
783
|
+
describe "#declare_route_to_gateway" do
|
784
|
+
context "check flag specified and a route does exist to a gateway" do
|
785
|
+
it "returns ok" do
|
786
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_gateway.get_json)
|
787
|
+
expect(@textout).to receive(:puts).with(ok_declare_route_to_gateway)
|
788
|
+
begin
|
789
|
+
@command_route_table_json_vpcid_check.declare_route_to_gateway(externalid_route_table, cidr, gateway_id)
|
790
|
+
rescue SystemExit => e
|
791
|
+
expect(e.status).to eq(0)
|
792
|
+
end
|
793
|
+
end
|
794
|
+
end
|
795
|
+
context "check flag specified and a route does not exist to a gateway" do
|
796
|
+
it "returns critical" do
|
797
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
798
|
+
expect(@textout).to receive(:puts).with(critical_declare_route_to_gateway)
|
799
|
+
begin
|
800
|
+
@command_route_table_json_vpcid_check.declare_route_to_gateway(externalid_route_table, cidr, gateway_id)
|
801
|
+
rescue SystemExit => e
|
802
|
+
expect(e.status).to eq(2)
|
803
|
+
end
|
804
|
+
end
|
805
|
+
end
|
806
|
+
context "route does exist to a gateway" do
|
807
|
+
it "skip route creation" do
|
808
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_gateway.get_json)
|
809
|
+
expect(@textout).to receive(:puts).with(route_to_gateway_not_created)
|
810
|
+
begin
|
811
|
+
@command_route_table_json_vpcid.declare_route_to_gateway(externalid_route_table, cidr, gateway_id)
|
812
|
+
rescue SystemExit => e
|
813
|
+
expect(e.status).to eq(0)
|
814
|
+
end
|
815
|
+
end
|
816
|
+
end
|
817
|
+
context "route does not exist to a gateway" do
|
818
|
+
it "create route" do
|
819
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables.get_json)
|
820
|
+
expect(@shellout).to receive(:cli).with(create_route_to_gateway.aws.get_command, nil).and_return('{ "return" : "true" }')
|
821
|
+
expect(@textout).to receive(:puts).with(route_to_gateway_created)
|
822
|
+
begin
|
823
|
+
@command_route_table_json_vpcid.declare_route_to_gateway(externalid_route_table, cidr, gateway_id)
|
824
|
+
rescue SystemExit => e
|
825
|
+
expect(e.status).to eq(0)
|
826
|
+
end
|
827
|
+
end
|
828
|
+
end
|
829
|
+
context "undo flag provided and route does exist to a gateway" do
|
830
|
+
it "skip route creation" do
|
831
|
+
expect(@undofile).to receive(:prepend).with("zaws route_table delete_route #{externalid_route_table} #{cidr} --region #{region} --vpcid #{vpc_id} $XTRA_OPTS", '#Delete route', 'undo.sh')
|
832
|
+
expect(@shellout).to receive(:cli).with(describe_route_tables.aws.get_command, nil).and_return(single_route_tables_with_gateway.get_json)
|
833
|
+
expect(@textout).to receive(:puts).with(route_to_gateway_not_created)
|
834
|
+
begin
|
835
|
+
@command_route_table_json_vpcid_undo.declare_route_to_gateway(externalid_route_table, cidr, gateway_id)
|
836
|
+
rescue SystemExit => e
|
837
|
+
expect(e.status).to eq(0)
|
838
|
+
end
|
839
|
+
end
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
end
|
844
|
+
|