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,35 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsIamUser") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsIamUser,
|
5
|
+
'aws_iam_user')
|
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_users,
|
13
|
+
{
|
14
|
+
users: [
|
15
|
+
{
|
16
|
+
user_name: 'FakeUser',
|
17
|
+
user_id: 'ANTIPASTAAC2ZFSLA',
|
18
|
+
arn: 'arn:aws:iam::123456789012:user/FakeUser',
|
19
|
+
path: '/'
|
20
|
+
},
|
21
|
+
{
|
22
|
+
user_name: 'FakeUser',
|
23
|
+
user_id: 'ANTIPASTAAC2ZFSLA',
|
24
|
+
arn: 'arn:aws:iam::123456789012:user/FakeUser',
|
25
|
+
path: '/'
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
29
|
+
)
|
30
|
+
sns.stub_responses(:list_users, stub)
|
31
|
+
remote_resources = GeoEngineer::Resources::AwsIamUser._fetch_remote_resources
|
32
|
+
expect(remote_resources.length).to eq 2
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsInstance") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsInstance, 'aws_instance')
|
5
|
+
name_tag_geo_id_tests(GeoEngineer::Resources::AwsInstance)
|
6
|
+
|
7
|
+
describe "#_fetch_remote_resources" do
|
8
|
+
it 'should create list of hashes from returned AWS SDK' do
|
9
|
+
ec2 = AwsClients.ec2
|
10
|
+
stub = ec2.stub_data(
|
11
|
+
:describe_instances,
|
12
|
+
{
|
13
|
+
reservations: [
|
14
|
+
instances: [
|
15
|
+
{ instance_id: 'name1', tags: [{ key: 'Name', value: 'one' }] },
|
16
|
+
{ instance_id: 'name2', tags: [{ key: 'Name', value: 'two' }] }
|
17
|
+
]
|
18
|
+
]
|
19
|
+
}
|
20
|
+
)
|
21
|
+
ec2.stub_responses(:describe_instances, stub)
|
22
|
+
remote_resources = GeoEngineer::Resources::AwsInstance._fetch_remote_resources
|
23
|
+
expect(remote_resources.length).to eq 2
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsRedshiftCluster") do
|
4
|
+
let(:aws_client) { AwsClients.redshift }
|
5
|
+
|
6
|
+
before { aws_client.setup_stubbing }
|
7
|
+
|
8
|
+
common_resource_tests(GeoEngineer::Resources::AwsRedshiftCluster, 'aws_redshift_cluster')
|
9
|
+
|
10
|
+
describe "#_fetch_remote_resources" do
|
11
|
+
before do
|
12
|
+
aws_client.stub_responses(
|
13
|
+
:describe_clusters,
|
14
|
+
{
|
15
|
+
clusters: [{ cluster_identifier: "id1" }]
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should create list of hashes from returned AWS SDK' do
|
21
|
+
remote_resources = GeoEngineer::Resources::AwsRedshiftCluster._fetch_remote_resources
|
22
|
+
expect(remote_resources.length).to eq(1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsRoute53Record") do
|
4
|
+
let(:aws_client) { AwsClients.route53 }
|
5
|
+
|
6
|
+
before { aws_client.setup_stubbing }
|
7
|
+
|
8
|
+
common_resource_tests(GeoEngineer::Resources::AwsRoute53Record, 'aws_route53_record')
|
9
|
+
|
10
|
+
describe "#_fetch_remote_resources" do
|
11
|
+
before do
|
12
|
+
aws_client.stub_responses(
|
13
|
+
:list_hosted_zones,
|
14
|
+
{
|
15
|
+
hosted_zones: [
|
16
|
+
{ id: 'id1', name: "zone1", caller_reference: "foo" }
|
17
|
+
],
|
18
|
+
is_truncated: false,
|
19
|
+
max_items: 100,
|
20
|
+
marker: "foo"
|
21
|
+
}
|
22
|
+
)
|
23
|
+
aws_client.stub_responses(
|
24
|
+
:list_resource_record_sets,
|
25
|
+
{
|
26
|
+
resource_record_sets: [
|
27
|
+
{ name: 'name1', type: 'A', ttl: 3600, resource_records: [{ value: "8.8.8.8" }] },
|
28
|
+
{ name: 'name1', type: 'CNAME', ttl: 300, resource_records: [{ value: "0.0.0.0" }] }
|
29
|
+
],
|
30
|
+
is_truncated: false,
|
31
|
+
max_items: 100
|
32
|
+
}
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should create list of hashes from returned AWS SDK' do
|
37
|
+
remote_resources = GeoEngineer::Resources::AwsRoute53Record._fetch_remote_resources
|
38
|
+
expect(remote_resources.length).to eq(2)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsRoute53Zone") do
|
4
|
+
let(:aws_client) { AwsClients.route53 }
|
5
|
+
|
6
|
+
before { aws_client.setup_stubbing }
|
7
|
+
|
8
|
+
common_resource_tests(GeoEngineer::Resources::AwsRoute53Zone, 'aws_route53_zone')
|
9
|
+
|
10
|
+
describe '#_fetch_remote_resources' do
|
11
|
+
before do
|
12
|
+
aws_client.stub_responses(
|
13
|
+
:list_hosted_zones, {
|
14
|
+
hosted_zones: [
|
15
|
+
{ id: '123', name: "testzone", caller_reference: "test" },
|
16
|
+
{ id: '1234', name: "anothertestzone", caller_reference: "test" }
|
17
|
+
],
|
18
|
+
is_truncated: false,
|
19
|
+
max_items: 100,
|
20
|
+
marker: "foo"
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should create an array of hashes from the AWS response' do
|
26
|
+
resources = GeoEngineer::Resources::AwsRoute53Zone._fetch_remote_resources
|
27
|
+
expect(resources.count).to eql(2)
|
28
|
+
|
29
|
+
testzone = resources.first
|
30
|
+
expect(testzone[:_terraform_id]).to eql('123')
|
31
|
+
expect(testzone[:_geo_id]).to eql('testzone')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsS3Bucket") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsS3Bucket, 'aws_s3_bucket')
|
5
|
+
|
6
|
+
describe "validations" do
|
7
|
+
it 'should validate that policy is valid JSON' do
|
8
|
+
s3b = GeoEngineer::Resources::AwsS3Bucket.new('type', 'id') {
|
9
|
+
bucket "bucket"
|
10
|
+
policy "}}" # invalid JSON
|
11
|
+
}
|
12
|
+
expect(s3b.errors.length).to eq 1
|
13
|
+
|
14
|
+
s3g = GeoEngineer::Resources::AwsS3Bucket.new('type', 'id') {
|
15
|
+
bucket "bucket"
|
16
|
+
policy "{}" # valid JSON
|
17
|
+
}
|
18
|
+
expect(s3g.errors.length).to eq 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#_fetch_remote_resources" do
|
23
|
+
it 'should create list of hashes from returned AWS SDK' do
|
24
|
+
s3 = AwsClients.s3
|
25
|
+
stub = s3.stub_data(
|
26
|
+
:list_buckets,
|
27
|
+
{
|
28
|
+
buckets: [
|
29
|
+
{ name: 'name1' },
|
30
|
+
{ name: 'name2' }
|
31
|
+
]
|
32
|
+
}
|
33
|
+
)
|
34
|
+
s3.stub_responses(:list_buckets, stub)
|
35
|
+
remote_resources = GeoEngineer::Resources::AwsS3Bucket._fetch_remote_resources
|
36
|
+
expect(remote_resources.length).to eq 2
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsSecurityGroup") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsSecurityGroup, 'aws_security_group')
|
5
|
+
name_tag_geo_id_tests(GeoEngineer::Resources::AwsSecurityGroup)
|
6
|
+
|
7
|
+
describe "validations" do
|
8
|
+
it 'should flatten cidr blocks (allows for easier definition)' do
|
9
|
+
res = GeoEngineer::Resources::AwsSecurityGroup.new('type', 'id') {
|
10
|
+
ingress {
|
11
|
+
cidr_blocks [[1], 2, [[3]]]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
res.flatten_cidr_and_sg_blocks
|
15
|
+
expect(res.ingress.cidr_blocks).to eq [1, 2, 3]
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should validate_correct_cidr_blocks' do
|
19
|
+
good_cidrs = GeoEngineer::Resources::AwsSecurityGroup.new('type', 'id') {
|
20
|
+
ingress {
|
21
|
+
cidr_blocks ["0.0.0.0/32", '255.255.255.255/0']
|
22
|
+
}
|
23
|
+
}
|
24
|
+
expect(good_cidrs.validate_correct_cidr_blocks.length).to eq 0
|
25
|
+
|
26
|
+
bad_cidrs = GeoEngineer::Resources::AwsSecurityGroup.new('type', 'id') {
|
27
|
+
ingress {
|
28
|
+
cidr_blocks ["0.0.0.0/33", '256.255.255.255/0', 'nonsence']
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
expect(bad_cidrs.validate_correct_cidr_blocks.length).to eq 3
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "_terraform_id and _geo_id" do
|
37
|
+
it 'should get geo_id from tags Name' do
|
38
|
+
res = GeoEngineer::Resources::AwsSecurityGroup.new('type', 'id') {
|
39
|
+
tags {
|
40
|
+
Name 'geo_id'
|
41
|
+
}
|
42
|
+
}
|
43
|
+
expect(res._geo_id).to eq 'geo_id'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should get terraform_id from remote by matching geo_ids' do
|
47
|
+
GeoEngineer::Resources::AwsSecurityGroup.clear_remote_resource_cache
|
48
|
+
remote_resources = [{ _geo_id: 'geo_id', _terraform_id: 't_id' }]
|
49
|
+
allow(GeoEngineer::Resources::AwsSecurityGroup).to(
|
50
|
+
receive(:_fetch_remote_resources).and_return(remote_resources)
|
51
|
+
)
|
52
|
+
|
53
|
+
res = GeoEngineer::Resources::AwsSecurityGroup.new('type', 'id') {
|
54
|
+
tags {
|
55
|
+
Name 'geo_id'
|
56
|
+
}
|
57
|
+
}
|
58
|
+
expect(res.remote_resource).to_not be_nil
|
59
|
+
expect(res._terraform_id).to eq 't_id'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#_fetch_remote_resources" do
|
64
|
+
it 'should create list of hashes from returned AWS SDK' do
|
65
|
+
ec2 = AwsClients.ec2
|
66
|
+
stub = ec2.stub_data(
|
67
|
+
:describe_security_groups,
|
68
|
+
{
|
69
|
+
security_groups: [
|
70
|
+
{ group_name: 'name1', group_id: 'id1', tags: [{ key: 'Name', value: 'one' }] },
|
71
|
+
{ group_name: 'name2', group_id: 'id2', tags: [{ key: 'Name', value: 'two' }] }
|
72
|
+
]
|
73
|
+
}
|
74
|
+
)
|
75
|
+
ec2.stub_responses(:describe_security_groups, stub)
|
76
|
+
remote_resources = GeoEngineer::Resources::AwsSecurityGroup._fetch_remote_resources
|
77
|
+
expect(remote_resources.length).to eq 2
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsSesReceiptRule") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsSesReceiptRule,
|
5
|
+
'aws_ses_policy')
|
6
|
+
|
7
|
+
describe "#_fetch_remote_resources" do
|
8
|
+
it 'should create list of hashes from returned AWS SDK' do
|
9
|
+
ses = AwsClients.ses
|
10
|
+
# ses.list_policies.policies
|
11
|
+
stub = ses.stub_data(
|
12
|
+
:describe_active_receipt_rule_set,
|
13
|
+
{
|
14
|
+
rules: [
|
15
|
+
{
|
16
|
+
name: 'FakeRule',
|
17
|
+
enabled: true,
|
18
|
+
recipients: ["fake_emal@test123.com"]
|
19
|
+
},
|
20
|
+
{
|
21
|
+
name: 'FakeRule',
|
22
|
+
enabled: true,
|
23
|
+
recipients: ["fake_emal@test123.com"]
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
27
|
+
)
|
28
|
+
sns.stub_responses(:describe_active_receipt_rule_set, stub)
|
29
|
+
remote_resources = GeoEngineer::Resources::AwsSesReceiptRule._fetch_remote_resources
|
30
|
+
expect(remote_resources.length).to eq 2
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsSesReceiptRuleSet") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsSesReceiptRuleSet,
|
5
|
+
'aws_ses_receipt_rule_set')
|
6
|
+
|
7
|
+
describe "#_fetch_remote_resources" do
|
8
|
+
it 'should create list of hashes from returned AWS SDK' do
|
9
|
+
ses = AwsClients.ses
|
10
|
+
# ses.list_receipt_rule_sets.rule_sets
|
11
|
+
stub = ses.stub_data(
|
12
|
+
:list_receipt_rule_sets,
|
13
|
+
{
|
14
|
+
rule_sets: [
|
15
|
+
{ name: "fake-rule-set", created_timestamp: "2016-10-19 20:19:29 UTC" },
|
16
|
+
{ name: "fake-rule-set-2", created_timestamp: "2016-10-19 20:19:29 UTC" }
|
17
|
+
]
|
18
|
+
}
|
19
|
+
)
|
20
|
+
sns.stub_responses(:list_receipt_rule_sets, stub)
|
21
|
+
remote_resources = GeoEngineer::Resources::AwsSesReceiptRuleSet._fetch_remote_resources
|
22
|
+
expect(remote_resources.length).to eq 2
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsSnsTopic") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsSnsTopic, 'aws_sns_topic')
|
5
|
+
|
6
|
+
describe "#_fetch_remote_resources" do
|
7
|
+
it 'should create list of hashes from returned AWS SDK' do
|
8
|
+
sns = AwsClients.sns
|
9
|
+
stub = sns.stub_data(
|
10
|
+
:list_topics,
|
11
|
+
{
|
12
|
+
topics: [
|
13
|
+
{ topic_arn: 'arn:aws:sns:us-east-1:123456789012:fake_arn' },
|
14
|
+
{ topic_arn: 'arn:aws:sns:us-east-1:123456789012:another_fake_arn' }
|
15
|
+
]
|
16
|
+
}
|
17
|
+
)
|
18
|
+
sns.stub_responses(:list_topics, stub)
|
19
|
+
remote_resources = GeoEngineer::Resources::AwsSnsTopic._fetch_remote_resources
|
20
|
+
expect(remote_resources.length).to eq 2
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsSnsTopic") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsSnsTopicSubscription,
|
5
|
+
'aws_sns_topic_subscription')
|
6
|
+
|
7
|
+
describe "#_fetch_remote_resources" do
|
8
|
+
it 'should create list of hashes from returned AWS SDK' do
|
9
|
+
sns = AwsClients.sns
|
10
|
+
# list_subscriptions.subscriptions
|
11
|
+
stub = sns.stub_data(
|
12
|
+
:list_subscriptions,
|
13
|
+
{
|
14
|
+
subscriptions: [
|
15
|
+
{
|
16
|
+
subscription_arn: 'arn:aws:sns:us-east-1:123456789012:fake_arn:8b93e9cd-ef23-47f3',
|
17
|
+
topic_arn: 'arn:aws:sns:us-east-1:123456789012:fake_arn',
|
18
|
+
endpoint: 'arn:aws:sqs:us-east-1:123456789012:fake_arn',
|
19
|
+
protocol: 'sqs'
|
20
|
+
},
|
21
|
+
{
|
22
|
+
subscription_arn: 'arn:aws:sns:us-east-1:123456789012:fake_arn:8b93e9cd-ef23-47f3',
|
23
|
+
topic_arn: 'arn:aws:sns:us-east-1:123456789012:fake_arn',
|
24
|
+
endpoint: 'arn:aws:sqs:us-east-1:123456789012:fake_arn',
|
25
|
+
protocol: 'sqs'
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
29
|
+
)
|
30
|
+
sns.stub_responses(:list_subscriptions, stub)
|
31
|
+
remote_resources = GeoEngineer::Resources::AwsSnsTopicSubscription._fetch_remote_resources
|
32
|
+
expect(remote_resources.length).to eq 2
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsSqsQueue") do
|
4
|
+
common_resource_tests(GeoEngineer::Resources::AwsSqsQueue, 'aws_sqs_queue')
|
5
|
+
|
6
|
+
describe "#_fetch_remote_resources" do
|
7
|
+
it 'should create list of hashes from returned AWS SDK' do
|
8
|
+
sqs = AwsClients.sqs
|
9
|
+
stub = sqs.stub_data(
|
10
|
+
:list_queues,
|
11
|
+
{
|
12
|
+
queue_urls: ["https://www.qqq.com/path/name1", "https://www.qqq.com/path/name2"]
|
13
|
+
}
|
14
|
+
)
|
15
|
+
sqs.stub_responses(:list_queues, stub)
|
16
|
+
remote_resources = GeoEngineer::Resources::AwsSqsQueue._fetch_remote_resources
|
17
|
+
expect(remote_resources.length).to eq 2
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
describe 'rubocop' do
|
5
|
+
it 'should validate the code style' do
|
6
|
+
puts ""
|
7
|
+
puts "Starting Rubocop Scan"
|
8
|
+
stdout, _stderr, status = Open3.capture3('bundle exec rubocop')
|
9
|
+
expect(status.success?).to eq(true), stdout
|
10
|
+
puts "Finished Rubocop Scan"
|
11
|
+
puts ""
|
12
|
+
end
|
13
|
+
end
|