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,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZAWS::Services::IAM::Policy do
|
4
|
+
# var_ - Version A. awscli 1.2.13 Return
|
5
|
+
# vap_ - Version A. awscli 1.2.13 Parameter
|
6
|
+
# vac_ - Version A. awscli 1.2.13 Command
|
7
|
+
|
8
|
+
let(:vap_region) { "us-west-1" }
|
9
|
+
let(:vap_role) { "my_role" }
|
10
|
+
let(:vap_policy) { "my_policy1" }
|
11
|
+
|
12
|
+
let(:vap_policy_arn) { "arn:aws:iam::123456789abc:policy/#{vap_policy}" }
|
13
|
+
let(:vap_policy_version) { "v2" }
|
14
|
+
|
15
|
+
let(:var_policy_doc) { <<-eos
|
16
|
+
{
|
17
|
+
"Version": "2012-10-17",
|
18
|
+
"Statement": [
|
19
|
+
{
|
20
|
+
"Action": [
|
21
|
+
"ec2:StartInstances",
|
22
|
+
"ec2:StopInstances",
|
23
|
+
"ec2:CreateTags"
|
24
|
+
],
|
25
|
+
"Resource": [
|
26
|
+
"arn:aws:ec2:us-east-1:123456789012:instance/i-88b83d72",
|
27
|
+
"arn:aws:ec2:us-east-1:123456789012:instance/i-e1f62836"
|
28
|
+
],
|
29
|
+
"Effect": "Allow"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"Action": [
|
33
|
+
"iam:GetPolicy",
|
34
|
+
"iam:GetPolicyVersion"
|
35
|
+
],
|
36
|
+
"Resource": [
|
37
|
+
"*"
|
38
|
+
],
|
39
|
+
"Effect": "Allow"
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
43
|
+
eos
|
44
|
+
}
|
45
|
+
|
46
|
+
let(:var_policy_version_doc) { <<-eos
|
47
|
+
{
|
48
|
+
"PolicyVersion": {
|
49
|
+
"CreateDate": "2015-09-08T06:14:59Z",
|
50
|
+
"VersionId": "v2",
|
51
|
+
"Document": #{var_policy_doc},
|
52
|
+
"IsDefaultVersion": true
|
53
|
+
}
|
54
|
+
}
|
55
|
+
eos
|
56
|
+
}
|
57
|
+
|
58
|
+
let(:var_policy_meta_data) { <<-eos
|
59
|
+
{
|
60
|
+
"Policy": {
|
61
|
+
"PolicyName": "#{vap_policy}",
|
62
|
+
"CreateDate": "2015-09-08T05:21:54Z",
|
63
|
+
"AttachmentCount": 1,
|
64
|
+
"IsAttachable": true,
|
65
|
+
"PolicyId": "123456789012345678901",
|
66
|
+
"DefaultVersionId": "#{vap_policy_version}",
|
67
|
+
"Path": "/",
|
68
|
+
"Arn": "#{vap_policy_arn}",
|
69
|
+
"UpdateDate": "2015-09-08T06:14:59Z"
|
70
|
+
}
|
71
|
+
}
|
72
|
+
eos
|
73
|
+
}
|
74
|
+
|
75
|
+
let(:options) { {:region => vap_region, :viewtype => 'json'} }
|
76
|
+
|
77
|
+
|
78
|
+
before(:each) {
|
79
|
+
@textout=double('outout')
|
80
|
+
@shellout=double('ZAWS::Helper::Shell')
|
81
|
+
@command_iam = ZAWS::Command::IAM.new([], options, {});
|
82
|
+
@aws=ZAWS::AWS.new(@shellout, ZAWS::AWSCLI.new(@shellout, true))
|
83
|
+
@command_iam.aws=@aws
|
84
|
+
@command_iam.out=@textout
|
85
|
+
@command_iam.print_exit_code = true
|
86
|
+
}
|
87
|
+
|
88
|
+
describe "#view_default_policy_version" do
|
89
|
+
it "view default policy version" do
|
90
|
+
expect(@shellout).to receive(:cli).with("aws --output json iam get-policy --policy-arn #{vap_policy_arn}", nil).ordered.and_return(var_policy_meta_data)
|
91
|
+
expect(@shellout).to receive(:cli).with("aws --output json iam get-policy-version --policy-arn #{vap_policy_arn} --version-id #{vap_policy_version}", nil).ordered.and_return(var_policy_version_doc)
|
92
|
+
expect(@textout).to receive(:puts).with(var_policy_version_doc).ordered
|
93
|
+
@command_iam.view_default_policy_version(vap_policy_arn)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZAWS::Services::IAM::Role do
|
4
|
+
# var_ - Version A. awscli 1.2.13 Return
|
5
|
+
# vap_ - Version A. awscli 1.2.13 Parameter
|
6
|
+
# vac_ - Version A. awscli 1.2.13 Command
|
7
|
+
|
8
|
+
let(:vap_region) { "us-west-1" }
|
9
|
+
let(:vap_role) { "my_role" }
|
10
|
+
let(:vap_policy) { "my_policy" }
|
11
|
+
|
12
|
+
let(:options) { {:region => vap_region, :viewtype => 'json'} }
|
13
|
+
|
14
|
+
|
15
|
+
before(:each) {
|
16
|
+
@textout=double('outout')
|
17
|
+
@shellout=double('ZAWS::Helper::Shell')
|
18
|
+
@command_iam = ZAWS::Command::IAM.new([], options, {});
|
19
|
+
@aws=ZAWS::AWS.new(@shellout, ZAWS::AWSCLI.new(@shellout, true))
|
20
|
+
@command_iam.aws=@aws
|
21
|
+
@command_iam.out=@textout
|
22
|
+
@command_iam.print_exit_code = true
|
23
|
+
}
|
24
|
+
|
25
|
+
describe "#view_role_policy" do
|
26
|
+
it "view role policy" do
|
27
|
+
expect(@shellout).to receive(:cli).with("aws --output json iam get-role-policy --role-name #{vap_role} --policy-name #{vap_policy}", nil).ordered.and_return('test output')
|
28
|
+
expect(@textout).to receive(:puts).with('test output').ordered
|
29
|
+
@command_iam.view_role_policy(vap_role, vap_policy)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZAWS::Services::Route53::HostedZone do
|
4
|
+
before(:each) {
|
5
|
+
|
6
|
+
@var_security_group_id="sg-abcd1234"
|
7
|
+
@var_output_json="json"
|
8
|
+
@var_output_table="table"
|
9
|
+
@var_region="us-west-1"
|
10
|
+
@var_vpc_id="my_vpc_id"
|
11
|
+
@var_sec_group_name="my_security_group_name"
|
12
|
+
|
13
|
+
options_json = {:region => @var_region,
|
14
|
+
:verbose => false,
|
15
|
+
:check => false,
|
16
|
+
:undofile => false,
|
17
|
+
:viewtype => 'json'
|
18
|
+
}
|
19
|
+
|
20
|
+
options_table = {:region => @var_region,
|
21
|
+
:verbose => false,
|
22
|
+
:check => false,
|
23
|
+
:undofile => false,
|
24
|
+
:viewtype => 'table'
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
@textout=double('outout')
|
29
|
+
@shellout=double('ZAWS::Helper::Shell')
|
30
|
+
@undofile=double('ZAWS::Helper::ZFile')
|
31
|
+
@aws=ZAWS::AWS.new(@shellout, ZAWS::AWSCLI.new(@shellout, true), @undofile)
|
32
|
+
@command_hosted_zone = ZAWS::Command::Hosted_Zone.new([], options_table, {})
|
33
|
+
@command_hosted_zone.aws=@aws
|
34
|
+
@command_hosted_zone.out=@textout
|
35
|
+
@command_hosted_zone.print_exit_code = true
|
36
|
+
@command_hosted_zone_json = ZAWS::Command::Hosted_Zone.new([], options_json, {})
|
37
|
+
@command_hosted_zone_json.aws=@aws
|
38
|
+
@command_hosted_zone_json.out=@textout
|
39
|
+
@command_hosted_zone_json.print_exit_code = true
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
describe "#view" do
|
44
|
+
it "Get hosted zone in a human readable table. " do
|
45
|
+
list_hosted_zones= ZAWS::External::AWSCLI::Commands::Route53::ListHostedZones.new
|
46
|
+
list_hosted_zones.aws.output(@var_output_table)
|
47
|
+
expect(@shellout).to receive(:cli).with(list_hosted_zones.aws.get_command, nil).ordered.and_return('test output')
|
48
|
+
expect(@textout).to receive(:puts).with('test output').ordered
|
49
|
+
@command_hosted_zone.view()
|
50
|
+
end
|
51
|
+
|
52
|
+
it "Get hosted zone in JSON form " do
|
53
|
+
list_hosted_zones= ZAWS::External::AWSCLI::Commands::Route53::ListHostedZones.new
|
54
|
+
list_hosted_zones.aws.output(@var_output_json)
|
55
|
+
expect(@shellout).to receive(:cli).with(list_hosted_zones.aws.get_command, nil).ordered.and_return('test output')
|
56
|
+
expect(@textout).to receive(:puts).with('test output').ordered
|
57
|
+
@command_hosted_zone_json.view()
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
describe "#view_records" do
|
63
|
+
it "Get records for hosted zone in a human readable table. " do
|
64
|
+
hosted_zones=ZAWS::External::AWSCLI::Generators::Result::Route53::HostedZones.new
|
65
|
+
hosted_zones.name(0,"abc.com.").id(0,"id-???")
|
66
|
+
|
67
|
+
list_hosted_zones= ZAWS::External::AWSCLI::Commands::Route53::ListHostedZones.new
|
68
|
+
list_hosted_zones.aws.output(@var_output_json)
|
69
|
+
expect(@shellout).to receive(:cli).with(list_hosted_zones.aws.get_command, nil).ordered.and_return(hosted_zones.get_json)
|
70
|
+
|
71
|
+
list_resource_record_sets= ZAWS::External::AWSCLI::Commands::Route53::ListResourceRecordSets.new
|
72
|
+
list_resource_record_sets.hosted_zone_id("id-???")
|
73
|
+
list_resource_record_sets.aws.output(@var_output_table)
|
74
|
+
expect(@shellout).to receive(:cli).with(list_resource_record_sets.aws.get_command, nil).ordered.and_return('test output')
|
75
|
+
|
76
|
+
expect(@textout).to receive(:puts).with('test output').ordered
|
77
|
+
@command_hosted_zone.view_records("abc.com.")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "Get records for hosted zone in a JSON form. " do
|
81
|
+
hosted_zones=ZAWS::External::AWSCLI::Generators::Result::Route53::HostedZones.new
|
82
|
+
hosted_zones.name(0,"abc.com.").id(0,"id-???")
|
83
|
+
|
84
|
+
list_hosted_zones= ZAWS::External::AWSCLI::Commands::Route53::ListHostedZones.new
|
85
|
+
list_hosted_zones.aws.output(@var_output_json)
|
86
|
+
expect(@shellout).to receive(:cli).with(list_hosted_zones.aws.get_command, nil).ordered.and_return(hosted_zones.get_json)
|
87
|
+
|
88
|
+
list_resource_record_sets= ZAWS::External::AWSCLI::Commands::Route53::ListResourceRecordSets.new
|
89
|
+
list_resource_record_sets.hosted_zone_id("id-???")
|
90
|
+
list_resource_record_sets.aws.output(@var_output_json)
|
91
|
+
expect(@shellout).to receive(:cli).with(list_resource_record_sets.aws.get_command, nil).ordered.and_return('test output')
|
92
|
+
|
93
|
+
expect(@textout).to receive(:puts).with('test output').ordered
|
94
|
+
@command_hosted_zone_json.view_records("abc.com.")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZAWS::Services::S3::Bucket do
|
4
|
+
before(:each) {
|
5
|
+
|
6
|
+
@var_security_group_id="sg-abcd1234"
|
7
|
+
@var_output_json="json"
|
8
|
+
@var_output_table="table"
|
9
|
+
@var_region="us-west-1"
|
10
|
+
@var_vpc_id="my_vpc_id"
|
11
|
+
@var_sec_group_name="my_security_group_name"
|
12
|
+
|
13
|
+
|
14
|
+
options_table = {:region => @var_region,
|
15
|
+
:verbose => false,
|
16
|
+
:check => false,
|
17
|
+
:undofile => false,
|
18
|
+
:viewtype => 'table',
|
19
|
+
:dest => '/tmp/dir'
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
@textout=double('outout')
|
24
|
+
@shellout=double('ZAWS::Helper::Shell')
|
25
|
+
@undofile=double('ZAWS::Helper::ZFile')
|
26
|
+
@aws=ZAWS::AWS.new(@shellout, ZAWS::AWSCLI.new(@shellout, true), @undofile)
|
27
|
+
@command_bucket = ZAWS::Command::Bucket.new([], options_table, {})
|
28
|
+
@command_bucket.aws=@aws
|
29
|
+
@command_bucket.out=@textout
|
30
|
+
@command_bucket.print_exit_code = true
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
describe "#declare" do
|
35
|
+
it "Declare an S3 bucket by name but skip its creation because it already exists." do
|
36
|
+
ls= ZAWS::External::AWSCLI::Commands::S3::Ls.new
|
37
|
+
ls.aws.region(@var_region)
|
38
|
+
expect(@shellout).to receive(:cli).with(ls.aws.get_command).ordered.and_return("2014-08-25 15:49:19 test-bucket")
|
39
|
+
@command_bucket.declare("test-bucket")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "Declare an S3 bucket so that it's created when it doesn't exist" do
|
43
|
+
ls= ZAWS::External::AWSCLI::Commands::S3::Ls.new
|
44
|
+
ls.aws.region(@var_region)
|
45
|
+
expect(@shellout).to receive(:cli).with(ls.aws.get_command).ordered.and_return("2014-08-25 15:49:19 some-other-bucket")
|
46
|
+
|
47
|
+
mb= ZAWS::External::AWSCLI::Commands::S3::Mb.new
|
48
|
+
mb.bucket_name("test-bucket")
|
49
|
+
mb.aws.region(@var_region)
|
50
|
+
expect(@shellout).to receive(:cli).with(mb.aws.get_command,@textout).ordered.and_return("make_bucket: s3://test-bucket")
|
51
|
+
|
52
|
+
@command_bucket.declare("test-bucket")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
describe "#sync" do
|
58
|
+
it "Sync the entire contents of an s3 bucket to the specified directory" do
|
59
|
+
sync= ZAWS::External::AWSCLI::Commands::S3::Sync.new
|
60
|
+
sync.source_name("s3://test-bucket").target_name("/tmp/dir")
|
61
|
+
sync.aws.region(@var_region)
|
62
|
+
expect(@shellout).to receive(:cli).with(sync.aws.get_command,nil).ordered.and_return("S3Output")
|
63
|
+
@command_bucket.sync("s3://test-bucket")
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZAWS::AWSCLI::Data::EC2::Instance do
|
4
|
+
# var_ - Version A. awscli 1.2.13 Return
|
5
|
+
# vap_ - Version A. awscli 1.2.13 Parameter
|
6
|
+
# vac_ - Version A. awscli 1.2.13 Command
|
7
|
+
|
8
|
+
let(:vap_describe_instance) { <<-eos
|
9
|
+
{
|
10
|
+
"Reservations": [
|
11
|
+
{
|
12
|
+
"OwnerId": "123456789abc",
|
13
|
+
"ReservationId": "r-88ef5d66",
|
14
|
+
"Groups": [],
|
15
|
+
"Instances": [
|
16
|
+
{
|
17
|
+
"State": {
|
18
|
+
"Code": 80,
|
19
|
+
"Name": "stopped"
|
20
|
+
},
|
21
|
+
"InstanceId": "i-abcdefg1",
|
22
|
+
"Tags": [
|
23
|
+
{
|
24
|
+
"Value": "my-name1",
|
25
|
+
"Key": "Name"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"AmiLaunchIndex": 0
|
29
|
+
}
|
30
|
+
]
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"OwnerId": "123456789abc",
|
34
|
+
"ReservationId": "r-88ef5d66",
|
35
|
+
"Groups": [],
|
36
|
+
"Instances": [
|
37
|
+
{
|
38
|
+
"State": {
|
39
|
+
"Code": 80,
|
40
|
+
"Name": "stopped"
|
41
|
+
},
|
42
|
+
"InstanceId": "i-abcdefg2",
|
43
|
+
"Tags": [
|
44
|
+
{
|
45
|
+
"Value": "my-name2",
|
46
|
+
"Key": "Name"
|
47
|
+
}
|
48
|
+
],
|
49
|
+
"AmiLaunchIndex": 0
|
50
|
+
}
|
51
|
+
]
|
52
|
+
}
|
53
|
+
|
54
|
+
]
|
55
|
+
}
|
56
|
+
eos
|
57
|
+
}
|
58
|
+
let(:vap_list_instance_ids) { "i-abcdefg1\ni-abcdefg2" }
|
59
|
+
let(:var_list_instance_names) { "my-name1\nmy-name2" }
|
60
|
+
|
61
|
+
before(:each) {
|
62
|
+
@textout=double('outout')
|
63
|
+
@shellout=double('ZAWS::Helper::Shell')
|
64
|
+
@filestore=double('ZAWS::Repository::Filestore')
|
65
|
+
@data_instance = ZAWS::AWSCLI::Data::EC2::Instance.new(@shellout, @filestore)
|
66
|
+
}
|
67
|
+
|
68
|
+
describe '#names_by_ids' do
|
69
|
+
|
70
|
+
context 'the name/id data is loaded' do
|
71
|
+
it 'returns instance ids as list of strings' do
|
72
|
+
expect(@filestore).to receive(:timeout).with(any_args).and_return(0)
|
73
|
+
expect(@filestore).to receive(:store).with(any_args)
|
74
|
+
@data_instance.load(nil, vap_describe_instance, nil)
|
75
|
+
expect(@data_instance.names_by_ids(vap_list_instance_ids)).to eq(var_list_instance_names)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'in which the role policy has resources has no instance ids' do
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZAWS::AWSCLI::Data::IAM::PolicyDocument do
|
4
|
+
|
5
|
+
let(:vap_policy_document_instance_ids_exist) { <<-eos
|
6
|
+
{
|
7
|
+
"Version": "2012-10-17",
|
8
|
+
"Statement": [
|
9
|
+
{
|
10
|
+
"Action": [
|
11
|
+
"ec2:StartInstances",
|
12
|
+
"ec2:StopInstances",
|
13
|
+
"ec2:CreateTags"
|
14
|
+
],
|
15
|
+
"Resource": [
|
16
|
+
"arn:aws:ec2:us-east-1:123456789abc:instance/i-abcdefg1",
|
17
|
+
"arn:aws:ec2:us-east-1:123456789abc:instance/i-abcdefg2"
|
18
|
+
],
|
19
|
+
"Effect": "Allow"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"Action": [
|
23
|
+
"iam:GetPolicy",
|
24
|
+
"iam:GetPolicyVersion"
|
25
|
+
],
|
26
|
+
"Resource": [
|
27
|
+
"*"
|
28
|
+
],
|
29
|
+
"Effect": "Allow"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
eos
|
34
|
+
}
|
35
|
+
|
36
|
+
let(:var_list_instance_ids) { "i-abcdefg1\ni-abcdefg2" }
|
37
|
+
|
38
|
+
before(:each) {
|
39
|
+
@textout=double('outout')
|
40
|
+
@shellout=double('ZAWS::Helper::Shell')
|
41
|
+
@data_iam = ZAWS::AWSCLI::Data::IAM::PolicyDocument.new(@shellout, nil)
|
42
|
+
}
|
43
|
+
|
44
|
+
describe "#resource_instance_ids" do
|
45
|
+
context "in which the policy document has resources with instance ids" do
|
46
|
+
it "returns instance ids as list of strings" do
|
47
|
+
@data_iam.load(nil, vap_policy_document_instance_ids_exist, nil)
|
48
|
+
expect(@data_iam.resource_instance_ids()).to eq(var_list_instance_ids)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|