awspec 0.41.0 → 0.42.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: a82db0940952c2d0456c6ab91ad8da93005e0342
4
- data.tar.gz: c2ea3398cb1a479bc6037f2f42571ea8461b2b02
3
+ metadata.gz: 269db3afd477e7b97500b7fa382400c9619b565c
4
+ data.tar.gz: 3968c5248b90648e277fa1c104b097ee7a31e9bc
5
5
  SHA512:
6
- metadata.gz: a46db329c15ddc92a25d437693f4ae60302998c772876b5fe23a1bdbf844248c8006d9b0758ae3d4a04bab84385cae0823671f46d106dc1207ae27116180f44a
7
- data.tar.gz: 23d66c7d32f53236669021c14a5ea370bdd087674af69c43610c46f9fe07b1d556ac38560a21a83b5674bb68a2fb39cb38d7d9bb56189d034232700bc5eac53e
6
+ metadata.gz: 709a0207a1dfe54c95e75b7e5143207c6b1aca6eb97aa13edbed729940979617d6459974da673cf87973a231b15d34f420693a85743075b5faac2948995c788a
7
+ data.tar.gz: a914e74d80c93295e185770f22e978089819e4f051fb134ef7190fb3110ce957b835c08b966342b2e168214351283c71e34f982f8100c5a6d912edcb567b8f11
@@ -70,6 +70,14 @@ describe s3_bucket('my-bucket') do
70
70
  end
71
71
  ```
72
72
 
73
+ ### have_logging_enabled
74
+
75
+ ```ruby
76
+ describe s3_bucket('my-bucket') do
77
+ it { should have_logging_enabled(target_bukcet: 'my-log-bucket', target_prefix: 'logs/') }
78
+ end
79
+ ```
80
+
73
81
  ### advanced
74
82
 
75
83
  `s3_bucket` can use `Aws::S3::Bucket` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Bucket.html).
@@ -1293,6 +1293,15 @@ end
1293
1293
  ```
1294
1294
 
1295
1295
 
1296
+ ### have_logging_enabled
1297
+
1298
+ ```ruby
1299
+ describe s3_bucket('my-bucket') do
1300
+ it { should have_logging_enabled(target_bukcet: 'my-log-bucket', target_prefix: 'logs/') }
1301
+ end
1302
+ ```
1303
+
1304
+
1296
1305
  ### have_object
1297
1306
 
1298
1307
  ```ruby
@@ -26,6 +26,12 @@ module Awspec::Helper
26
26
  nil
27
27
  end
28
28
 
29
+ def find_bucket_logging(id)
30
+ s3_client.get_bucket_logging(bucket: id)
31
+ rescue Aws::S3::Errors::NoSuchBucket
32
+ nil
33
+ end
34
+
29
35
  def select_all_buckets
30
36
  s3_client.list_buckets.buckets
31
37
  end
@@ -54,10 +54,15 @@ Aws.config[:s3] = {
54
54
  ]
55
55
  },
56
56
  get_bucket_policy: {
57
- policy: '{"Version":"2012-10-17","Statement":' \
58
- '[{"Sid":"AllowPublicRead","Effect":"Allow",' \
59
- '"Principal":"*","Action":"s3:GetObject",' \
60
- '"Resource":"arn:aws:s3:::my-bucket/*"}]}'
57
+ policy: '{"Version":"2012-10-17","Statement":[{"Sid":"","Effect":"Allow","Principal":' \
58
+ '{"AWS":"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity XXXXX"},' \
59
+ '"Action":"s3:GetObject","Resource":"arn:aws:s3:::my-bucket/*"}]}'
60
+ },
61
+ get_bucket_logging: {
62
+ logging_enabled: {
63
+ target_bucket: 'my-log-bucket',
64
+ target_prefix: 'logs/'
65
+ }
61
66
  }
62
67
  }
63
68
  }
@@ -56,8 +56,17 @@ module Awspec::Type
56
56
 
57
57
  def has_policy?(policy)
58
58
  bp = find_bucket_policy(@id)
59
- # newlines, spaces, etc.. are removed from policy which is returned from API
60
- bp ? (bp.policy.read == policy.gsub(/(\n|\r|\r\n|\s|\t)/, '')) : false
59
+ bp ? (JSON.parse(bp.policy.read) == JSON.parse(policy)) : false
60
+ end
61
+
62
+ def has_logging_enabled?(target_bucket: nil, target_prefix: nil)
63
+ bl = find_bucket_logging(@id)
64
+ le = bl ? bl.logging_enabled : nil
65
+
66
+ return false if le.nil?
67
+ return false if target_bucket && target_bucket != le.target_bucket
68
+ return false if target_prefix && target_prefix != le.target_prefix
69
+ true
61
70
  end
62
71
 
63
72
  private
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.41.0'
2
+ VERSION = '0.42.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.41.0
4
+ version: 0.42.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-06-11 00:00:00.000000000 Z
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec