awspec 1.15.2 → 1.15.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 286caeeb79c08042ba020a6266bbbf879dda76df25c59673502bb6e7b274c7d9
4
- data.tar.gz: 45c43c72c18b243bb504d94e524510b2bb29a9595dcc2120356b48633ed3d0fd
2
+ SHA1:
3
+ metadata.gz: ca755a39c613bc48b0ccc9e5dba01cc0c727f7df
4
+ data.tar.gz: 894571bf21f40ba2c635f0667cfee61f39792a40
5
5
  SHA512:
6
- metadata.gz: 328f23daea68ba72d74de30518fb246fe355f275e299860863010850ac2847b7b270317de971cd230c7e74665f999e4863ba4abafd736e2618c55e16fc56c6f7
7
- data.tar.gz: 38a223660281278ebfae75e77f377e5a6ef3884da5e04364de711a4271a4f5a27159877f48cdbf518a5ee0d59ab3247308d0d49d0cad36be8870822df6368967
6
+ metadata.gz: 2731087c9c0b93a7f12f19dce2c06a86beb38cef1f685541c5f0f6f69201916823796199f8baa24175716c6ad772bc0698bde18f502cc201c9f416c195f59396
7
+ data.tar.gz: 26a1b770cfa85ddf827cfbbe9f0cf1e63c37dcbec3e14ac7f573ef1e3a7ae7e4734cd0e0b548f529229be168d85f966b4d56a2a799ece93cad7ea1db7615bf6d
@@ -31,7 +31,7 @@ describe iam_group('my-iam-group') do
31
31
  end
32
32
  ```
33
33
 
34
- ### have_inline_group
34
+ ### have_inline_policy
35
35
 
36
36
  ```ruby
37
37
  describe iam_group('my-iam-group') do
@@ -67,6 +67,14 @@ DOC
67
67
  end
68
68
  ```
69
69
 
70
+ You can test absence of inline policies.
71
+
72
+ ```ruby
73
+ describe iam_group('my-iam-group') do
74
+ it { should_not have_inline_policy }
75
+ end
76
+ ```
77
+
70
78
  ### advanced
71
79
 
72
80
  `iam_group` can use `Aws::IAM::Group` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/IAM/Group.html).
@@ -51,6 +51,14 @@ DOC
51
51
  end
52
52
  ```
53
53
 
54
+ You can test absence of inline policies.
55
+
56
+ ```ruby
57
+ describe iam_role('my-iam-role') do
58
+ it { should_not have_inline_policy }
59
+ end
60
+ ```
61
+
54
62
  ### advanced
55
63
 
56
64
  `iam_role` can use `Aws::IAM::Role` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/IAM/Role.html).
@@ -51,6 +51,14 @@ DOC
51
51
  end
52
52
  ```
53
53
 
54
+ You can test absence of inline policies.
55
+
56
+ ```ruby
57
+ describe iam_user('my-iam-user') do
58
+ it { should_not have_inline_policy }
59
+ end
60
+ ```
61
+
54
62
  ### belong_to_iam_group
55
63
 
56
64
  ```ruby
@@ -1670,6 +1670,49 @@ end
1670
1670
 
1671
1671
  ### have_inline_policy
1672
1672
 
1673
+ ```ruby
1674
+ describe iam_group('my-iam-group') do
1675
+ it { should have_inline_policy('InlineEC2FullAccess') }
1676
+ it do
1677
+ should have_inline_policy('InlineEC2FullAccess').policy_document(<<-'DOC')
1678
+ {
1679
+ "Statement": [
1680
+ {
1681
+ "Action": "ec2:*",
1682
+ "Effect": "Allow",
1683
+ "Resource": "*"
1684
+ },
1685
+ {
1686
+ "Effect": "Allow",
1687
+ "Action": "elasticloadbalancing:*",
1688
+ "Resource": "*"
1689
+ },
1690
+ {
1691
+ "Effect": "Allow",
1692
+ "Action": "cloudwatch:*",
1693
+ "Resource": "*"
1694
+ },
1695
+ {
1696
+ "Effect": "Allow",
1697
+ "Action": "autoscaling:*",
1698
+ "Resource": "*"
1699
+ }
1700
+ ]
1701
+ }
1702
+ DOC
1703
+ end
1704
+ end
1705
+ ```
1706
+
1707
+ You can test absence of inline policies.
1708
+
1709
+ ```ruby
1710
+ describe iam_group('my-iam-group') do
1711
+ it { should_not have_inline_policy }
1712
+ end
1713
+ ```
1714
+
1715
+
1673
1716
  ### its(:path), its(:group_name), its(:group_id), its(:arn), its(:create_date)
1674
1717
  ### :unlock: Advanced use
1675
1718
 
@@ -1798,6 +1841,14 @@ DOC
1798
1841
  end
1799
1842
  ```
1800
1843
 
1844
+ You can test absence of inline policies.
1845
+
1846
+ ```ruby
1847
+ describe iam_role('my-iam-role') do
1848
+ it { should_not have_inline_policy }
1849
+ end
1850
+ ```
1851
+
1801
1852
 
1802
1853
  ### its(:path), its(:role_name), its(:role_id), its(:arn), its(:create_date), its(:assume_role_policy_document), its(:description), its(:max_session_duration), its(:permissions_boundary), its(:tags)
1803
1854
  ### :unlock: Advanced use
@@ -1878,6 +1929,14 @@ DOC
1878
1929
  end
1879
1930
  ```
1880
1931
 
1932
+ You can test absence of inline policies.
1933
+
1934
+ ```ruby
1935
+ describe iam_user('my-iam-user') do
1936
+ it { should_not have_inline_policy }
1937
+ end
1938
+ ```
1939
+
1881
1940
 
1882
1941
  ### belong_to_iam_group
1883
1942
 
@@ -2,8 +2,7 @@ module Awspec::Helper
2
2
  module Finder
3
3
  module S3
4
4
  def find_bucket(id)
5
- res = s3_client.list_buckets
6
- ret = s3_client.list_buckets[:buckets].find do |bucket|
5
+ s3_client.list_buckets[:buckets].find do |bucket|
7
6
  bucket.name == id
8
7
  end
9
8
  end
@@ -28,6 +28,8 @@ module Awspec::Type
28
28
  end
29
29
 
30
30
  def has_inline_policy?(policy_name, document = nil)
31
+ return has_any_inline_policies? unless policy_name
32
+
31
33
  res = iam_client.get_group_policy({
32
34
  group_name: id,
33
35
  policy_name: policy_name
@@ -35,5 +37,12 @@ module Awspec::Type
35
37
  return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
36
38
  res
37
39
  end
40
+
41
+ private
42
+
43
+ def has_any_inline_policies?
44
+ res = iam_client.list_group_policies(group_name: id)
45
+ !res.policy_names.empty?
46
+ end
38
47
  end
39
48
  end
@@ -18,6 +18,8 @@ module Awspec::Type
18
18
  end
19
19
 
20
20
  def has_inline_policy?(policy_name, document = nil)
21
+ return has_any_inline_policies? unless policy_name
22
+
21
23
  res = iam_client.get_role_policy({
22
24
  role_name: resource_via_client.role_name,
23
25
  policy_name: policy_name
@@ -25,5 +27,12 @@ module Awspec::Type
25
27
  return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
26
28
  res
27
29
  end
30
+
31
+ private
32
+
33
+ def has_any_inline_policies?
34
+ res = iam_client.list_role_policies(role_name: resource_via_client.role_name)
35
+ !res.policy_names.empty?
36
+ end
28
37
  end
29
38
  end
@@ -18,6 +18,8 @@ module Awspec::Type
18
18
  end
19
19
 
20
20
  def has_inline_policy?(policy_name, document = nil)
21
+ return has_any_inline_policies? unless policy_name
22
+
21
23
  res = iam_client.get_user_policy({
22
24
  user_name: resource_via_client.user_name,
23
25
  policy_name: policy_name
@@ -25,5 +27,12 @@ module Awspec::Type
25
27
  return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
26
28
  res
27
29
  end
30
+
31
+ private
32
+
33
+ def has_any_inline_policies?
34
+ res = iam_client.list_user_policies(user_name: resource_via_client.user_name)
35
+ !res.policy_names.empty?
36
+ end
28
37
  end
29
38
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '1.15.2'
2
+ VERSION = '1.15.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.2
4
+ version: 1.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-14 00:00:00.000000000 Z
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -706,7 +706,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
706
706
  version: '0'
707
707
  requirements: []
708
708
  rubyforge_project:
709
- rubygems_version: 2.7.6
709
+ rubygems_version: 2.6.14
710
710
  signing_key:
711
711
  specification_version: 4
712
712
  summary: RSpec tests for your AWS resources.