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 +4 -4
- data/doc/_resource_types/iam_group.md +36 -0
- data/doc/_resource_types/iam_policy.md +2 -2
- data/doc/_resource_types/iam_role.md +28 -0
- data/doc/_resource_types/iam_user.md +28 -0
- data/doc/resource_types.md +63 -2
- data/lib/awspec/matcher.rb +1 -0
- data/lib/awspec/matcher/have_inline_policy.rb +9 -0
- data/lib/awspec/stub/iam_group.rb +9 -0
- data/lib/awspec/stub/iam_role.rb +8 -0
- data/lib/awspec/stub/iam_user.rb +8 -0
- data/lib/awspec/type/iam_group.rb +9 -0
- data/lib/awspec/type/iam_role.rb +9 -0
- data/lib/awspec/type/iam_user.rb +9 -0
- data/lib/awspec/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 943408f055cbbe94af820dc9a73e46fd9865cd0d
|
4
|
+
data.tar.gz: 24a1f2214ca5d14790ed98ff429a14392e39c236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
```
|
@@ -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
|
data/doc/resource_types.md
CHANGED
@@ -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-
|
575
|
-
it { should
|
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
|
data/lib/awspec/matcher.rb
CHANGED
@@ -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
|
{
|
data/lib/awspec/stub/iam_role.rb
CHANGED
@@ -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
|
{
|
data/lib/awspec/stub/iam_user.rb
CHANGED
@@ -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
|
data/lib/awspec/type/iam_role.rb
CHANGED
@@ -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
|
data/lib/awspec/type/iam_user.rb
CHANGED
@@ -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
|
data/lib/awspec/version.rb
CHANGED
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.
|
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-
|
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
|