awspec 0.37.1 → 0.37.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awspec/command/generate.rb +1 -1
- data/lib/awspec/generator.rb +1 -0
- data/lib/awspec/generator/spec/iam_group.rb +39 -0
- data/lib/awspec/helper/finder/iam.rb +13 -0
- data/lib/awspec/stub/iam_group.rb +10 -3
- data/lib/awspec/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0a5dad9214e4aa1801d62b7cc829348ed01fa57
|
4
|
+
data.tar.gz: fd8add8f33ba56d825cbb3d2117e1d10c6351e48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baaabfb1dee8c745f949826d55c5ab68002f9ec5301a387c29d79523cb86dccdda29410f68b74b59f40812ee6fa13f9272779400f9e552c234517b7ac3a46c12
|
7
|
+
data.tar.gz: 5a0272e85c7d25b93523780cc30434ff392ae607cdc5fa09d22ad6a722838b68f1490b47f854343bc30787dec1a3e2412373424a05dd3d769dbdae461a308c41
|
data/lib/awspec/generator.rb
CHANGED
@@ -17,6 +17,7 @@ require 'awspec/generator/spec/nat_gateway'
|
|
17
17
|
require 'awspec/generator/spec/lambda'
|
18
18
|
require 'awspec/generator/spec/network_interface'
|
19
19
|
require 'awspec/generator/spec/iam_user'
|
20
|
+
require 'awspec/generator/spec/iam_group'
|
20
21
|
|
21
22
|
# Doc
|
22
23
|
require 'awspec/generator/doc/type'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Spec
|
3
|
+
class IamGroup
|
4
|
+
include Awspec::Helper::Finder
|
5
|
+
def generate_all
|
6
|
+
groups = select_all_iam_groups
|
7
|
+
raise 'Not Found IAM Group' if groups.empty?
|
8
|
+
specs = groups.map do |group|
|
9
|
+
inline_policies = select_inine_policy_by_group_name(group.group_name).map do |policy_name|
|
10
|
+
res = iam_client.get_group_policy({
|
11
|
+
group_name: group.group_name,
|
12
|
+
policy_name: policy_name
|
13
|
+
})
|
14
|
+
document = JSON.generate(JSON.parse(URI.decode(res.policy_document)))
|
15
|
+
"it { should have_inline_policy('#{policy_name}').document('#{document}') }"
|
16
|
+
end
|
17
|
+
content = ERB.new(iam_group_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
|
18
|
+
end
|
19
|
+
specs.join("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
def iam_group_spec_template
|
23
|
+
template = <<-'EOF'
|
24
|
+
describe iam_group('<%= group.group_name %>') do
|
25
|
+
it { should exist }
|
26
|
+
its(:arn) { should eq '<%= group.arn %>' }
|
27
|
+
its(:create_date) { should eq Time.parse('<%= group.create_date %>') }
|
28
|
+
<% select_iam_policy_by_group_name(group.group_name).each do |policy| %> it { should have_iam_policy('<%= policy.policy_name %>') }
|
29
|
+
<% end %>
|
30
|
+
<%- inline_policies.each do |line| -%>
|
31
|
+
<%= line %>
|
32
|
+
<%- end -%>
|
33
|
+
end
|
34
|
+
EOF
|
35
|
+
template
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -64,6 +64,13 @@ module Awspec::Helper
|
|
64
64
|
res.policy_names
|
65
65
|
end
|
66
66
|
|
67
|
+
def select_inine_policy_by_group_name(group_name)
|
68
|
+
res = iam_client.list_group_policies({
|
69
|
+
group_name: group_name
|
70
|
+
})
|
71
|
+
res.policy_names
|
72
|
+
end
|
73
|
+
|
67
74
|
def select_all_attached_policies
|
68
75
|
selected = []
|
69
76
|
res = iam_client.list_policies
|
@@ -101,6 +108,12 @@ module Awspec::Helper
|
|
101
108
|
responce.users
|
102
109
|
end.flatten
|
103
110
|
end
|
111
|
+
|
112
|
+
def select_all_iam_groups
|
113
|
+
iam_client.list_groups.map do |responce|
|
114
|
+
responce.groups
|
115
|
+
end.flatten
|
116
|
+
end
|
104
117
|
end
|
105
118
|
end
|
106
119
|
end
|
@@ -6,7 +6,7 @@ Aws.config[:iam] = {
|
|
6
6
|
user_name: 'my-iam-user',
|
7
7
|
user_id: 'ABCDEFGHI1234556890',
|
8
8
|
arn: 'arn:aws:iam::123456789012:user/my-iam-user',
|
9
|
-
create_date: Time.
|
9
|
+
create_date: Time.new(2015, 1, 2, 10, 00, 00, '+00:00')
|
10
10
|
]
|
11
11
|
},
|
12
12
|
list_groups: {
|
@@ -15,7 +15,7 @@ Aws.config[:iam] = {
|
|
15
15
|
group_name: 'my-iam-group',
|
16
16
|
group_id: 'GABCDEFGHI123455689',
|
17
17
|
arn: 'arn:aws:iam::123456789012:group/my-iam-group',
|
18
|
-
create_date: Time.
|
18
|
+
create_date: Time.new(2015, 1, 2, 11, 00, 00, '+00:00')
|
19
19
|
]
|
20
20
|
},
|
21
21
|
list_groups_for_user: {
|
@@ -25,7 +25,7 @@ Aws.config[:iam] = {
|
|
25
25
|
group_name: 'my-iam-group',
|
26
26
|
group_id: 'GABCDEFGHI123455689',
|
27
27
|
arn: 'arn:aws:iam::123456789012:group/my-iam-group',
|
28
|
-
create_date: Time.
|
28
|
+
create_date: Time.new(2015, 1, 2, 12, 00, 00, '+00:00')
|
29
29
|
}
|
30
30
|
]
|
31
31
|
},
|
@@ -39,6 +39,13 @@ Aws.config[:iam] = {
|
|
39
39
|
is_truncated: false,
|
40
40
|
marker: nil
|
41
41
|
},
|
42
|
+
list_group_policies: {
|
43
|
+
policy_names: [
|
44
|
+
'InlineEC2FullAccess'
|
45
|
+
],
|
46
|
+
is_truncated: false,
|
47
|
+
marker: nil
|
48
|
+
},
|
42
49
|
get_group_policy: {
|
43
50
|
group_name: 'my-iam-group',
|
44
51
|
policy_name: 'InlineEC2FullAccess',
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.37.
|
4
|
+
version: 0.37.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- lib/awspec/generator/spec/ebs.rb
|
273
273
|
- lib/awspec/generator/spec/ec2.rb
|
274
274
|
- lib/awspec/generator/spec/elb.rb
|
275
|
+
- lib/awspec/generator/spec/iam_group.rb
|
275
276
|
- lib/awspec/generator/spec/iam_policy.rb
|
276
277
|
- lib/awspec/generator/spec/iam_user.rb
|
277
278
|
- lib/awspec/generator/spec/lambda.rb
|