geoengineer 0.1.0
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/LICENSE +13 -0
- data/README.md +476 -0
- data/bin/geo +7 -0
- data/lib/geoengineer.rb +29 -0
- data/lib/geoengineer/cli/geo_cli.rb +208 -0
- data/lib/geoengineer/cli/status_command.rb +101 -0
- data/lib/geoengineer/cli/terraform_commands.rb +59 -0
- data/lib/geoengineer/environment.rb +186 -0
- data/lib/geoengineer/output.rb +27 -0
- data/lib/geoengineer/project.rb +79 -0
- data/lib/geoengineer/resource.rb +200 -0
- data/lib/geoengineer/resources/aws_db_instance.rb +46 -0
- data/lib/geoengineer/resources/aws_db_parameter_group.rb +25 -0
- data/lib/geoengineer/resources/aws_elasticache_cluster.rb +50 -0
- data/lib/geoengineer/resources/aws_elasticache_parameter_group.rb +30 -0
- data/lib/geoengineer/resources/aws_elasticache_replication_group.rb +44 -0
- data/lib/geoengineer/resources/aws_elasticache_subnet_group.rb +25 -0
- data/lib/geoengineer/resources/aws_elasticsearch_domain.rb +35 -0
- data/lib/geoengineer/resources/aws_elb.rb +57 -0
- data/lib/geoengineer/resources/aws_iam_policy.rb +53 -0
- data/lib/geoengineer/resources/aws_iam_user.rb +42 -0
- data/lib/geoengineer/resources/aws_instance.rb +24 -0
- data/lib/geoengineer/resources/aws_proxy_protocol_policy.rb +39 -0
- data/lib/geoengineer/resources/aws_redshift_cluster.rb +23 -0
- data/lib/geoengineer/resources/aws_route53_record.rb +32 -0
- data/lib/geoengineer/resources/aws_route53_zone.rb +21 -0
- data/lib/geoengineer/resources/aws_s3_bucket.rb +54 -0
- data/lib/geoengineer/resources/aws_security_group.rb +53 -0
- data/lib/geoengineer/resources/aws_ses_receipt_rule.rb +38 -0
- data/lib/geoengineer/resources/aws_ses_receipt_rule_set.rb +28 -0
- data/lib/geoengineer/resources/aws_sns_topic.rb +28 -0
- data/lib/geoengineer/resources/aws_sns_topic_subscription.rb +42 -0
- data/lib/geoengineer/resources/aws_sqs_queue.rb +37 -0
- data/lib/geoengineer/resources/iam/statement.rb +43 -0
- data/lib/geoengineer/sub_resource.rb +35 -0
- data/lib/geoengineer/template.rb +28 -0
- data/lib/geoengineer/utils/aws_clients.rb +63 -0
- data/lib/geoengineer/utils/has_attributes.rb +97 -0
- data/lib/geoengineer/utils/has_lifecycle.rb +54 -0
- data/lib/geoengineer/utils/has_resources.rb +63 -0
- data/lib/geoengineer/utils/has_sub_resources.rb +43 -0
- data/lib/geoengineer/utils/has_validations.rb +57 -0
- data/lib/geoengineer/utils/null_object.rb +17 -0
- data/lib/geoengineer/version.rb +3 -0
- data/spec/environment_spec.rb +140 -0
- data/spec/output_spec.rb +3 -0
- data/spec/project_spec.rb +79 -0
- data/spec/resource_spec.rb +169 -0
- data/spec/resources/aws_db_instance_spec.rb +23 -0
- data/spec/resources/aws_db_parameter_group_spec.rb +23 -0
- data/spec/resources/aws_elasticache_replication_group_spec.rb +29 -0
- data/spec/resources/aws_elasticache_subnet_group_spec.rb +31 -0
- data/spec/resources/aws_elasticcache_cluster_spec.rb +23 -0
- data/spec/resources/aws_elasticcache_parameter_group_spec.rb +26 -0
- data/spec/resources/aws_elasticsearch_domain_spec.rb +22 -0
- data/spec/resources/aws_elb_spec.rb +65 -0
- data/spec/resources/aws_iam_policy.rb +35 -0
- data/spec/resources/aws_iam_user.rb +35 -0
- data/spec/resources/aws_instance_spec.rb +26 -0
- data/spec/resources/aws_proxy_protocol_policy_spec.rb +5 -0
- data/spec/resources/aws_redshift_cluster_spec.rb +25 -0
- data/spec/resources/aws_route53_record_spec.rb +41 -0
- data/spec/resources/aws_route53_zone_spec.rb +34 -0
- data/spec/resources/aws_s3_bucket_spec.rb +39 -0
- data/spec/resources/aws_security_group_spec.rb +80 -0
- data/spec/resources/aws_ses_receipt_rule.rb +33 -0
- data/spec/resources/aws_ses_receipt_rule_set.rb +25 -0
- data/spec/resources/aws_sns_topic_spec.rb +23 -0
- data/spec/resources/aws_sns_topic_subscription.rb +35 -0
- data/spec/resources/aws_sqs_queue_spec.rb +20 -0
- data/spec/rubocop_spec.rb +13 -0
- data/spec/spec_helper.rb +71 -0
- data/spec/sub_resource_spec.rb +20 -0
- data/spec/template_spec.rb +39 -0
- data/spec/utils/has_attributes_spec.rb +118 -0
- data/spec/utils/has_lifecycle_spec.rb +24 -0
- data/spec/utils/has_resources_spec.rb +68 -0
- data/spec/utils/has_subresources_spec.rb +29 -0
- data/spec/utils/has_validations_spec.rb +35 -0
- data/spec/utils/null_object_spec.rb +18 -0
- metadata +303 -0
@@ -0,0 +1,169 @@
|
|
1
|
+
require_relative './spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resource") do
|
4
|
+
describe '#remote_resource' do
|
5
|
+
class GeoEngineer::RemoteResources < GeoEngineer::Resource
|
6
|
+
def self._fetch_remote_resources
|
7
|
+
[{ _geo_id: "geo_id1" }, { _geo_id: "geo_id2" }, { _geo_id: "geo_id2" }]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return a list of resources' do
|
12
|
+
rem_res = GeoEngineer::RemoteResources.new('rem', 'id') {
|
13
|
+
_geo_id "geo_id1"
|
14
|
+
}
|
15
|
+
|
16
|
+
norem_res = GeoEngineer::RemoteResources.new('rem', 'id') {
|
17
|
+
_geo_id "geo_id3"
|
18
|
+
}
|
19
|
+
|
20
|
+
expect(rem_res.remote_resource.nil?).to eq false
|
21
|
+
expect(norem_res.remote_resource.nil?).to eq true
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should error if you match more than one' do
|
25
|
+
rem = GeoEngineer::RemoteResources.new('rem', 'id') {
|
26
|
+
_geo_id "geo_id2"
|
27
|
+
}
|
28
|
+
expect { rem.remote_resource }.to raise_error(StandardError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#to_terraform_json' do
|
33
|
+
it 'should return _terraform_id as primary' do
|
34
|
+
class GeoEngineer::TFJSON < GeoEngineer::Resource
|
35
|
+
after :initialize, -> { _terraform_id "tid" }
|
36
|
+
end
|
37
|
+
|
38
|
+
res = GeoEngineer::TFJSON.new('tf_json', 'ididid') {
|
39
|
+
blue "TRUE"
|
40
|
+
tags {
|
41
|
+
not_blue "FALSE"
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
tfjson = res.to_terraform_json
|
46
|
+
|
47
|
+
expect(tfjson['blue']).to eq 'TRUE'
|
48
|
+
expect(tfjson['tags'][0]['not_blue']).to eq 'FALSE'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#to_terraform_state' do
|
53
|
+
it 'should return _terraform_id as primary' do
|
54
|
+
class GeoEngineer::TFState < GeoEngineer::Resource
|
55
|
+
after :initialize, -> { _terraform_id "tid" }
|
56
|
+
end
|
57
|
+
|
58
|
+
tfs = GeoEngineer::TFState.new('tf_state', 'asd').to_terraform_state
|
59
|
+
expect(tfs[:type]).to eq 'tf_state'
|
60
|
+
expect(tfs[:primary][:id]).to eq 'tid'
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should return _terraform_id as primary' do
|
64
|
+
class GeoEngineer::TFState < GeoEngineer::Resource
|
65
|
+
after :initialize, -> { _terraform_id "tid" }
|
66
|
+
end
|
67
|
+
|
68
|
+
tfs = GeoEngineer::TFState.new('tf_state', 'asd').to_terraform_state
|
69
|
+
expect(tfs[:type]).to eq 'tf_state'
|
70
|
+
expect(tfs[:primary][:id]).to eq 'tid'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#fetch_remote_resources' do
|
75
|
+
it 'should return a list of resources' do
|
76
|
+
class GeoEngineer::FetchableResources < GeoEngineer::Resource
|
77
|
+
def self._fetch_remote_resources
|
78
|
+
[{ _geo_id: "geoid" }]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
resources = GeoEngineer::FetchableResources.fetch_remote_resources()
|
83
|
+
expect(resources.length).to eq 1
|
84
|
+
expect(resources[0]._geo_id).to eq "geoid"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#validate_required_subresource' do
|
89
|
+
it 'should return errors if it does not have a tag' do
|
90
|
+
class GeoEngineer::HasSRAttrResource < GeoEngineer::Resource
|
91
|
+
validate -> { validate_required_subresource :tags }
|
92
|
+
after :initialize, -> { _terraform_id "tid'" }
|
93
|
+
end
|
94
|
+
not_blue = GeoEngineer::HasSRAttrResource.new('has_attr', 'id') {}
|
95
|
+
with_blue = GeoEngineer::HasSRAttrResource.new('has_attr', 'id') {
|
96
|
+
tags {
|
97
|
+
blue "True"
|
98
|
+
}
|
99
|
+
}
|
100
|
+
expect(not_blue.errors.length).to eq 1
|
101
|
+
expect(with_blue.errors.length).to eq 0
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#validate_subresource_required_attributes' do
|
106
|
+
it 'should return errors if it does not have a tag' do
|
107
|
+
class GeoEngineer::HasSRAttrResource < GeoEngineer::Resource
|
108
|
+
validate -> { validate_subresource_required_attributes :tags, [:blue] }
|
109
|
+
after :initialize, -> { _terraform_id "tid'" }
|
110
|
+
end
|
111
|
+
not_blue = GeoEngineer::HasSRAttrResource.new('has_attr', 'id') {
|
112
|
+
tags {}
|
113
|
+
}
|
114
|
+
with_blue = GeoEngineer::HasSRAttrResource.new('has_attr', 'id') {
|
115
|
+
tags {
|
116
|
+
blue "True"
|
117
|
+
}
|
118
|
+
}
|
119
|
+
expect(not_blue.errors.length).to eq 1
|
120
|
+
expect(with_blue.errors.length).to eq 0
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#validate_required_attributes' do
|
125
|
+
it 'should return errors if it does not have a tag' do
|
126
|
+
class GeoEngineer::HasAttrResource < GeoEngineer::Resource
|
127
|
+
validate -> { validate_required_attributes [:blue] }
|
128
|
+
after :initialize, -> { _terraform_id "tid'" }
|
129
|
+
end
|
130
|
+
not_blue = GeoEngineer::HasAttrResource.new('has_attr', 'id')
|
131
|
+
with_blue = GeoEngineer::HasAttrResource.new('has_attr', 'id') {
|
132
|
+
blue "True"
|
133
|
+
}
|
134
|
+
expect(not_blue.errors.length).to eq 1
|
135
|
+
expect(with_blue.errors.length).to eq 0
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#validate_has_tag' do
|
140
|
+
it 'should return errors if it does not have a tag' do
|
141
|
+
class GeoEngineer::HasTagResource < GeoEngineer::Resource
|
142
|
+
validate -> { validate_has_tag :blue }
|
143
|
+
after :initialize, -> { _terraform_id "tid'" }
|
144
|
+
end
|
145
|
+
not_blue = GeoEngineer::HasTagResource.new('has_tag', 'id')
|
146
|
+
with_blue = GeoEngineer::HasTagResource.new('has_tag', 'id') {
|
147
|
+
tags {
|
148
|
+
blue "True"
|
149
|
+
}
|
150
|
+
}
|
151
|
+
expect(not_blue.errors.length).to eq 1
|
152
|
+
expect(with_blue.errors.length).to eq 0
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe 'class method' do
|
157
|
+
describe('#type_from_class_name') do
|
158
|
+
it 'should return resource' do
|
159
|
+
expect(GeoEngineer::Resource.type_from_class_name).to eq 'resource'
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should remove module' do
|
163
|
+
class GeoEngineer::ResourceType < GeoEngineer::Resource
|
164
|
+
end
|
165
|
+
expect(GeoEngineer::ResourceType.type_from_class_name).to eq 'resource_type'
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsDbInstance") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsDbInstance, 'aws_db_instance')
|
5
|
+
|
6
|
+
describe "#_fetch_remote_resources" do
|
7
|
+
it 'should create list of hashes from returned AWS SDK' do
|
8
|
+
rds = AwsClients.rds
|
9
|
+
stub = rds.stub_data(
|
10
|
+
:describe_db_instances,
|
11
|
+
{
|
12
|
+
db_instances: [
|
13
|
+
{ db_instance_identifier: 'name1' },
|
14
|
+
{ db_instance_identifier: 'name2' }
|
15
|
+
]
|
16
|
+
}
|
17
|
+
)
|
18
|
+
rds.stub_responses(:describe_db_instances, stub)
|
19
|
+
remote_resources = GeoEngineer::Resources::AwsDbInstance._fetch_remote_resources
|
20
|
+
expect(remote_resources.length).to eq 2
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsDbParameterGroup") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsDbParameterGroup, 'aws_db_parameter_group')
|
5
|
+
|
6
|
+
describe "#_fetch_remote_resources" do
|
7
|
+
it 'should create list of hashes from returned AWS SDK' do
|
8
|
+
rds = AwsClients.rds
|
9
|
+
stub = rds.stub_data(
|
10
|
+
:describe_db_parameter_groups,
|
11
|
+
{
|
12
|
+
db_parameter_groups: [
|
13
|
+
{ db_parameter_group_name: 'name1' },
|
14
|
+
{ db_parameter_group_name: 'name2' }
|
15
|
+
]
|
16
|
+
}
|
17
|
+
)
|
18
|
+
rds.stub_responses(:describe_db_parameter_groups, stub)
|
19
|
+
remote_resources = GeoEngineer::Resources::AwsDbParameterGroup._fetch_remote_resources
|
20
|
+
expect(remote_resources.length).to eq 2
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsElasticacheReplicationGroup") do
|
4
|
+
common_resource_tests(
|
5
|
+
GeoEngineer::Resources::AwsElasticacheReplicationGroup,
|
6
|
+
'aws_elasticache_replication_group'
|
7
|
+
)
|
8
|
+
|
9
|
+
describe "#_fetch_remote_resources" do
|
10
|
+
it 'should create list of hashes from returned AWS SDK' do
|
11
|
+
elasticache = AwsClients.elasticache
|
12
|
+
stub = elasticache.stub_data(
|
13
|
+
:describe_replication_groups,
|
14
|
+
{
|
15
|
+
replication_groups: [
|
16
|
+
{ replication_group_id: 'rg1' },
|
17
|
+
{ replication_group_id: 'rg2' }
|
18
|
+
]
|
19
|
+
}
|
20
|
+
)
|
21
|
+
elasticache.stub_responses(:describe_replication_groups, stub)
|
22
|
+
|
23
|
+
replication_group_class = GeoEngineer::Resources::AwsElasticacheReplicationGroup
|
24
|
+
remote_resources = replication_group_class._fetch_remote_resources
|
25
|
+
|
26
|
+
expect(remote_resources.length).to eq 2
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe "GeoEngineer::Resources::AwsElasticacheSubnetGroup" do
|
4
|
+
let(:aws_client) { AwsClients.elasticache }
|
5
|
+
|
6
|
+
before { aws_client.setup_stubbing }
|
7
|
+
|
8
|
+
common_resource_tests(
|
9
|
+
GeoEngineer::Resources::AwsElasticacheSubnetGroup,
|
10
|
+
'aws_elasticache_subnet_group'
|
11
|
+
)
|
12
|
+
|
13
|
+
describe "#_fetch_remote_resources" do
|
14
|
+
before do
|
15
|
+
aws_client.stub_responses(
|
16
|
+
:describe_cache_subnet_groups,
|
17
|
+
{
|
18
|
+
cache_subnet_groups: [
|
19
|
+
{ cache_subnet_group_name: 'cache-subnet-group-1' },
|
20
|
+
{ cache_subnet_group_name: 'cache-subnet-group-2' }
|
21
|
+
]
|
22
|
+
}
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should create list of hashes from returned AWS SDK' do
|
27
|
+
remote_resources = GeoEngineer::Resources::AwsElasticacheSubnetGroup._fetch_remote_resources
|
28
|
+
expect(remote_resources.length).to eq 2
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsElasticacheCluster") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsElasticacheCluster, 'aws_elasticache_cluster')
|
5
|
+
|
6
|
+
describe "#_fetch_remote_resources" do
|
7
|
+
it 'should create list of hashes from returned AWS SDK' do
|
8
|
+
elasticache = AwsClients.elasticache
|
9
|
+
stub = elasticache.stub_data(
|
10
|
+
:describe_cache_clusters,
|
11
|
+
{
|
12
|
+
cache_clusters: [
|
13
|
+
{ cache_cluster_id: 'name1' },
|
14
|
+
{ cache_cluster_id: 'name2' }
|
15
|
+
]
|
16
|
+
}
|
17
|
+
)
|
18
|
+
elasticache.stub_responses(:describe_cache_clusters, stub)
|
19
|
+
remote_resources = GeoEngineer::Resources::AwsElasticacheCluster._fetch_remote_resources
|
20
|
+
expect(remote_resources.length).to eq 2
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsElasticacheParameterGroup") do
|
4
|
+
common_resource_tests(
|
5
|
+
GeoEngineer::Resources::AwsElasticacheParameterGroup,
|
6
|
+
'aws_elasticache_parameter_group'
|
7
|
+
)
|
8
|
+
|
9
|
+
describe "#_fetch_remote_resources" do
|
10
|
+
it 'should create list of hashes from returned AWS SDK' do
|
11
|
+
elasticache = AwsClients.elasticache
|
12
|
+
stub = elasticache.stub_data(
|
13
|
+
:describe_cache_parameter_groups,
|
14
|
+
{
|
15
|
+
cache_parameter_groups: [
|
16
|
+
{ cache_parameter_group_name: 'name1' },
|
17
|
+
{ cache_parameter_group_name: 'name2' }
|
18
|
+
]
|
19
|
+
}
|
20
|
+
)
|
21
|
+
elasticache.stub_responses(:describe_cache_parameter_groups, stub)
|
22
|
+
rr = GeoEngineer::Resources::AwsElasticacheParameterGroup._fetch_remote_resources
|
23
|
+
expect(rr.length).to eq 2
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsElasticsearchDomain") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsElasticsearchDomain, 'aws_elasticsearch_domain')
|
5
|
+
|
6
|
+
describe "#_fetch_remote_resources" do
|
7
|
+
it 'should create list of hashes from returned AWS SDK' do
|
8
|
+
stub = AwsClients.elasticsearch.stub_data(
|
9
|
+
:list_domain_names,
|
10
|
+
{
|
11
|
+
domain_names: [
|
12
|
+
{ domain_name: 'name1' },
|
13
|
+
{ domain_name: 'name2' }
|
14
|
+
]
|
15
|
+
}
|
16
|
+
)
|
17
|
+
AwsClients.elasticsearch.stub_responses(:list_domain_names, stub)
|
18
|
+
remote_resources = GeoEngineer::Resources::AwsElasticsearchDomain._fetch_remote_resources
|
19
|
+
expect(remote_resources.length).to eq 2
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsElb") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsElb, 'aws_elb')
|
5
|
+
|
6
|
+
describe "validations" do
|
7
|
+
it 'should validate unique lb ports for listeners' do
|
8
|
+
good_elb = GeoEngineer::Resources::AwsElb.new('type', 'id') {
|
9
|
+
name "name"
|
10
|
+
listener {
|
11
|
+
instance_port 100
|
12
|
+
instance_protocol 'tcp'
|
13
|
+
lb_port 100
|
14
|
+
lb_protocol 'tcp'
|
15
|
+
}
|
16
|
+
|
17
|
+
listener {
|
18
|
+
instance_port 100
|
19
|
+
instance_protocol 'tcp'
|
20
|
+
lb_port 101
|
21
|
+
lb_protocol 'tcp'
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
expect(good_elb.errors.length).to eq 0
|
26
|
+
|
27
|
+
bad_elb = GeoEngineer::Resources::AwsElb.new('type', 'id') {
|
28
|
+
name "name"
|
29
|
+
listener {
|
30
|
+
instance_port 100
|
31
|
+
instance_protocol 'tcp'
|
32
|
+
lb_port 100
|
33
|
+
lb_protocol 'tcp'
|
34
|
+
}
|
35
|
+
|
36
|
+
listener {
|
37
|
+
instance_port 100
|
38
|
+
instance_protocol 'tcp'
|
39
|
+
lb_port 100
|
40
|
+
lb_protocol 'tcp'
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
expect(bad_elb.errors.length).to eq 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#_fetch_remote_resources" do
|
49
|
+
it 'should create list of hashes from returned AWS SDK' do
|
50
|
+
elb = AwsClients.elb
|
51
|
+
stub = elb.stub_data(
|
52
|
+
:describe_load_balancers,
|
53
|
+
{
|
54
|
+
load_balancer_descriptions: [
|
55
|
+
{ load_balancer_name: 'name1' },
|
56
|
+
{ load_balancer_name: 'name2' }
|
57
|
+
]
|
58
|
+
}
|
59
|
+
)
|
60
|
+
elb.stub_responses(:describe_load_balancers, stub)
|
61
|
+
remote_resources = GeoEngineer::Resources::AwsElb._fetch_remote_resources
|
62
|
+
expect(remote_resources.length).to eq 2
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsIamPolicy") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsIamPolicy,
|
5
|
+
'aws_iam_policy')
|
6
|
+
|
7
|
+
describe "#_fetch_remote_resources" do
|
8
|
+
it 'should create list of hashes from returned AWS SDK' do
|
9
|
+
iam = AwsClients.iam
|
10
|
+
# iam.list_policies.policies
|
11
|
+
stub = iam.stub_data(
|
12
|
+
:list_policies,
|
13
|
+
{
|
14
|
+
policies: [
|
15
|
+
{
|
16
|
+
policy_name: 'FakePolicy',
|
17
|
+
policy_id: 'ANTIPASTAAC2ZFSLA',
|
18
|
+
arn: 'arn:aws:iam::123456789012:policy/FakePolicy',
|
19
|
+
path: '/'
|
20
|
+
},
|
21
|
+
{
|
22
|
+
policy_name: 'FakePolicy',
|
23
|
+
policy_id: 'ANTIPASTAAC2ZFSLA',
|
24
|
+
arn: 'arn:aws:iam::123456789012:policy/FakePolicy',
|
25
|
+
path: '/'
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
29
|
+
)
|
30
|
+
sns.stub_responses(:list_policies, stub)
|
31
|
+
remote_resources = GeoEngineer::Resources::AwsIamPolicy._fetch_remote_resources
|
32
|
+
expect(remote_resources.length).to eq 2
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|