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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b6ec4bb7c04663d22ecbacb2d64453099d3e63e
4
- data.tar.gz: 7a709c7c170f53acd3644917ef86222441cb049f
3
+ metadata.gz: a0a5dad9214e4aa1801d62b7cc829348ed01fa57
4
+ data.tar.gz: fd8add8f33ba56d825cbb3d2117e1d10c6351e48
5
5
  SHA512:
6
- metadata.gz: 009a2b28309366cf3234bd13b730de2a64fb33cf12bda4fbe62f7de037c7d3e4a41e4ce05a91d236a9e43e287b66e82694c87267aac2b1fb473d442dff5c22b0
7
- data.tar.gz: 0c64aca38e323892ff6b43d73a44b95f1963694a263a6a77d07355677930b7f2b5290cf1da20f1656a1c56bf20795288e82a7e06eae29ceb7cfa33ac3eab2ddb
6
+ metadata.gz: baaabfb1dee8c745f949826d55c5ab68002f9ec5301a387c29d79523cb86dccdda29410f68b74b59f40812ee6fa13f9272779400f9e552c234517b7ac3a46c12
7
+ data.tar.gz: 5a0272e85c7d25b93523780cc30434ff392ae607cdc5fa09d22ad6a722838b68f1490b47f854343bc30787dec1a3e2412373424a05dd3d769dbdae461a308c41
@@ -36,7 +36,7 @@ module Awspec
36
36
  end
37
37
 
38
38
  types_for_generate_all = %w(
39
- iam_policy cloudwatch_alarm directconnect ebs lambda iam_user
39
+ iam_policy cloudwatch_alarm directconnect ebs lambda iam_user iam_group
40
40
  )
41
41
 
42
42
  types_for_generate_all.each do |type|
@@ -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.local(2015)
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.local(2015)
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.local(2015)
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',
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.37.1'
2
+ VERSION = '0.37.2'
3
3
  end
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.1
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