awspec 0.36.1 → 0.37.0

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: d3fddd77e3ed0bec352d8a53cfaa7f239b1fb896
4
- data.tar.gz: f259c5bb2c4b5b90ab582c808d718d9f362a990d
3
+ metadata.gz: 943408f055cbbe94af820dc9a73e46fd9865cd0d
4
+ data.tar.gz: 24a1f2214ca5d14790ed98ff429a14392e39c236
5
5
  SHA512:
6
- metadata.gz: 45c6af40e0ccbc9fd2d766dcd6df9dbf66168079e12893156ec5b7ece8190fe554b849f88c5eac54e80759ebe5c9bd47460790099356288da483123ba614cfbf
7
- data.tar.gz: 32e845dd34c5dc984cf5959bef2bb9b9d2e59f86d65cda1d45b6b6de16d51bb61c24afb12d8aa2514e9ddbea530a8c181e166e78f192ccf90682b97e34e859ac
6
+ metadata.gz: 4c6731a2c4b4700a53ce01370f5f30866d3e166e7b407ae79c9ea8e407a8c054f36868d49e40e112f5062470c2c700dbf6ffc1f1f056fe943c7945a89ffae67a
7
+ data.tar.gz: 4de99f88703f60ef5d0016aa4ff5c6b76d07f0a7f0d42358ddf2163a94d1e473521930e85b44c86cb31f090c87a2f87222748119a775625c30d839d2a587e349
@@ -30,3 +30,39 @@ describe iam_group('my-iam-group') do
30
30
  it { should have_iam_user('my-iam-user') }
31
31
  end
32
32
  ```
33
+
34
+ ### have_inline_group
35
+
36
+ ```ruby
37
+ describe iam_group('my-iam-group') do
38
+ it { should have_inline_policy('InlineEC2FullAccess') }
39
+ it do
40
+ should have_inline_policy('InlineEC2FullAccess').policy_document(<<-'DOC')
41
+ {
42
+ "Statement": [
43
+ {
44
+ "Action": "ec2:*",
45
+ "Effect": "Allow",
46
+ "Resource": "*"
47
+ },
48
+ {
49
+ "Effect": "Allow",
50
+ "Action": "elasticloadbalancing:*",
51
+ "Resource": "*"
52
+ },
53
+ {
54
+ "Effect": "Allow",
55
+ "Action": "cloudwatch:*",
56
+ "Resource": "*"
57
+ },
58
+ {
59
+ "Effect": "Allow",
60
+ "Action": "autoscaling:*",
61
+ "Resource": "*"
62
+ }
63
+ ]
64
+ }
65
+ DOC
66
+ end
67
+ end
68
+ ```
@@ -33,7 +33,7 @@ end
33
33
  ### be_attached_to_user
34
34
 
35
35
  ```ruby
36
- describe iam_policy('my-iam-policy') do
37
- it { should be_attached_to_policy('my-iam-policy') }
36
+ describe iam_policy('my-iam-user') do
37
+ it { should be_attached_to_user('my-iam-user') }
38
38
  end
39
39
  ```
@@ -22,3 +22,31 @@ describe iam_role('my-iam-role') do
22
22
  it { should have_iam_policy('ReadOnlyAccess') }
23
23
  end
24
24
  ```
25
+
26
+ ### have_inline_policy
27
+
28
+ ```ruby
29
+ describe iam_role('my-iam-role') do
30
+ it { should have_inline_policy('AllowS3BucketAccess') }
31
+ it do
32
+ should have_inline_policy('AllowS3BucketAccess').policy_document(<<-'DOC')
33
+ {
34
+ "Statement": [
35
+ {
36
+ "Action": [
37
+ "s3:ListAllMyBuckets"
38
+ ],
39
+ "Effect": "Allow",
40
+ "Resource": "arn:aws:s3:::*"
41
+ },
42
+ {
43
+ "Action": "s3:*",
44
+ "Effect": "Allow",
45
+ "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"]
46
+ }
47
+ ]
48
+ }
49
+ DOC
50
+ end
51
+ end
52
+ ```
@@ -23,6 +23,34 @@ describe iam_user('my-iam-user') do
23
23
  end
24
24
  ```
25
25
 
26
+ ### have_inline_policy
27
+
28
+ ```ruby
29
+ describe iam_user('my-iam-user') do
30
+ it { should have_inline_policy('AllowS3BucketAccess') }
31
+ it do
32
+ should have_inline_policy('AllowS3BucketAccess').policy_document(<<-'DOC')
33
+ {
34
+ "Statement": [
35
+ {
36
+ "Action": [
37
+ "s3:ListAllMyBuckets"
38
+ ],
39
+ "Effect": "Allow",
40
+ "Resource": "arn:aws:s3:::*"
41
+ },
42
+ {
43
+ "Action": "s3:*",
44
+ "Effect": "Allow",
45
+ "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"]
46
+ }
47
+ ]
48
+ }
49
+ DOC
50
+ end
51
+ end
52
+ ```
53
+
26
54
  ### belong_to_iam_group
27
55
 
28
56
  ```ruby
@@ -527,6 +527,9 @@ describe iam_group('my-iam-group') do
527
527
  end
528
528
  ```
529
529
 
530
+
531
+ ### have_inline_policy
532
+
530
533
  ### its(:path), its(:group_name), its(:group_id), its(:arn), its(:create_date)
531
534
  ## <a name="iam_policy">iam_policy</a>
532
535
 
@@ -571,8 +574,8 @@ end
571
574
  ### be_attached_to_user
572
575
 
573
576
  ```ruby
574
- describe iam_policy('my-iam-policy') do
575
- it { should be_attached_to_policy('my-iam-policy') }
577
+ describe iam_policy('my-iam-user') do
578
+ it { should be_attached_to_user('my-iam-user') }
576
579
  end
577
580
  ```
578
581
 
@@ -608,6 +611,35 @@ describe iam_role('my-iam-role') do
608
611
  end
609
612
  ```
610
613
 
614
+
615
+ ### have_inline_policy
616
+
617
+ ```ruby
618
+ describe iam_role('my-iam-role') do
619
+ it { should have_inline_policy('AllowS3BucketAccess') }
620
+ it do
621
+ should have_inline_policy('AllowS3BucketAccess').policy_document(<<-'DOC')
622
+ {
623
+ "Statement": [
624
+ {
625
+ "Action": [
626
+ "s3:ListAllMyBuckets"
627
+ ],
628
+ "Effect": "Allow",
629
+ "Resource": "arn:aws:s3:::*"
630
+ },
631
+ {
632
+ "Action": "s3:*",
633
+ "Effect": "Allow",
634
+ "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"]
635
+ }
636
+ ]
637
+ }
638
+ DOC
639
+ end
640
+ end
641
+ ```
642
+
611
643
  ### its(:path), its(:role_name), its(:role_id), its(:arn), its(:create_date), its(:assume_role_policy_document)
612
644
  ## <a name="iam_user">iam_user</a>
613
645
 
@@ -641,6 +673,35 @@ end
641
673
  ```
642
674
 
643
675
 
676
+ ### have_inline_policy
677
+
678
+ ```ruby
679
+ describe iam_user('my-iam-user') do
680
+ it { should have_inline_policy('AllowS3BucketAccess') }
681
+ it do
682
+ should have_inline_policy('AllowS3BucketAccess').policy_document(<<-'DOC')
683
+ {
684
+ "Statement": [
685
+ {
686
+ "Action": [
687
+ "s3:ListAllMyBuckets"
688
+ ],
689
+ "Effect": "Allow",
690
+ "Resource": "arn:aws:s3:::*"
691
+ },
692
+ {
693
+ "Action": "s3:*",
694
+ "Effect": "Allow",
695
+ "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"]
696
+ }
697
+ ]
698
+ }
699
+ DOC
700
+ end
701
+ end
702
+ ```
703
+
704
+
644
705
  ### belong_to_iam_group
645
706
 
646
707
  ```ruby
@@ -18,6 +18,7 @@ require 'awspec/matcher/have_route'
18
18
 
19
19
  # IAM User
20
20
  require 'awspec/matcher/belong_to_iam_group'
21
+ require 'awspec/matcher/have_inline_policy'
21
22
 
22
23
  # IAM User/Group/Role
23
24
  require 'awspec/matcher/be_allowed_action'
@@ -0,0 +1,9 @@
1
+ RSpec::Matchers.define :have_inline_policy do |policy_name|
2
+ match do |iam_type|
3
+ iam_type.has_inline_policy?(policy_name, @document)
4
+ end
5
+
6
+ chain :policy_document do |document|
7
+ @document = document
8
+ end
9
+ end
@@ -39,6 +39,15 @@ Aws.config[:iam] = {
39
39
  is_truncated: false,
40
40
  marker: nil
41
41
  },
42
+ get_group_policy: {
43
+ group_name: 'my-iam-group',
44
+ policy_name: 'InlineEC2FullAccess',
45
+ policy_document: '{"Statement": [{"Action": "ec2:*","Effect": "Allow",' \
46
+ '"Resource": "*"},{"Effect": "Allow","Action": "elasticloadbalancing:*",' \
47
+ '"Resource": "*"},{"Effect": "Allow","Action": "cloudwatch:*",' \
48
+ '"Resource": "*"},{"Effect": "Allow","Action": "autoscaling:*",' \
49
+ '"Resource": "*"}]}'
50
+ },
42
51
  simulate_principal_policy: {
43
52
  evaluation_results: [
44
53
  {
@@ -19,6 +19,14 @@ Aws.config[:iam] = {
19
19
  is_truncated: false,
20
20
  marker: nil
21
21
  },
22
+ get_role_policy: {
23
+ role_name: 'my-iam-role',
24
+ policy_name: 'AllowS3BucketAccess',
25
+ policy_document: '{"Statement": [{"Action": ["s3:ListAllMyBuckets"],' \
26
+ '"Effect": "Allow","Resource": "arn:aws:s3:::*"},' \
27
+ '{"Action": "s3:*","Effect": "Allow","Resource":' \
28
+ '["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"]}]}'
29
+ },
22
30
  simulate_principal_policy: {
23
31
  evaluation_results: [
24
32
  {
@@ -30,6 +30,14 @@ Aws.config[:iam] = {
30
30
  is_truncated: false,
31
31
  marker: nil
32
32
  },
33
+ get_user_policy: {
34
+ user_name: 'my-iam-user',
35
+ policy_name: 'AllowS3BucketAccess',
36
+ policy_document: '{"Statement": [{"Action": ["s3:ListAllMyBuckets"],' \
37
+ '"Effect": "Allow","Resource": "arn:aws:s3:::*"},' \
38
+ '{"Action": "s3:*","Effect": "Allow","Resource":' \
39
+ '["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"]}]}'
40
+ },
33
41
  simulate_principal_policy: {
34
42
  evaluation_results: [
35
43
  {
@@ -22,5 +22,14 @@ module Awspec::Type
22
22
  policy.policy_arn == policy_id || policy.policy_name == policy_id
23
23
  end
24
24
  end
25
+
26
+ def has_inline_policy?(policy_name, document = nil)
27
+ res = iam_client.get_group_policy({
28
+ group_name: @resource_via_client.group_name,
29
+ policy_name: policy_name
30
+ })
31
+ return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
32
+ res
33
+ end
25
34
  end
26
35
  end
@@ -12,5 +12,14 @@ module Awspec::Type
12
12
  policy.policy_arn == policy_id || policy.policy_name == policy_id
13
13
  end
14
14
  end
15
+
16
+ def has_inline_policy?(policy_name, document = nil)
17
+ res = iam_client.get_role_policy({
18
+ role_name: @resource_via_client.role_name,
19
+ policy_name: policy_name
20
+ })
21
+ return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
22
+ res
23
+ end
15
24
  end
16
25
  end
@@ -12,5 +12,14 @@ module Awspec::Type
12
12
  policy.policy_arn == policy_id || policy.policy_name == policy_id
13
13
  end
14
14
  end
15
+
16
+ def has_inline_policy?(policy_name, document = nil)
17
+ res = iam_client.get_user_policy({
18
+ user_name: @resource_via_client.user_name,
19
+ policy_name: policy_name
20
+ })
21
+ return JSON.parse(URI.decode(res.policy_document)) == JSON.parse(document) if document
22
+ res
23
+ end
15
24
  end
16
25
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.36.1'
2
+ VERSION = '0.37.0'
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: 0.36.1
4
+ version: 0.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2016-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -320,6 +320,7 @@ files:
320
320
  - lib/awspec/matcher/belong_to_replication_group.rb
321
321
  - lib/awspec/matcher/belong_to_subnet.rb
322
322
  - lib/awspec/matcher/belong_to_vpc.rb
323
+ - lib/awspec/matcher/have_inline_policy.rb
323
324
  - lib/awspec/matcher/have_private_ip_address.rb
324
325
  - lib/awspec/matcher/have_record_set.rb
325
326
  - lib/awspec/matcher/have_route.rb