drillbit 2.9.1 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -3
  4. data/lib/drillbit/authorizable_resource.rb +9 -3
  5. data/lib/drillbit/authorizers/parameters/resource.rb +1 -1
  6. data/lib/drillbit/requests/rack.rb +0 -2
  7. data/lib/drillbit/responses/invalid_api_request.rb +3 -3
  8. data/lib/drillbit/responses/invalid_request_body.rb +3 -3
  9. data/lib/drillbit/responses/invalid_subdomain.rb +3 -3
  10. data/lib/drillbit/responses/invalid_token.rb +3 -3
  11. data/lib/drillbit/tokens/json_web_tokens/password_reset.rb +1 -1
  12. data/lib/drillbit/version.rb +1 -1
  13. data/spec/drillbit/accept_header_spec.rb +1 -1
  14. data/spec/drillbit/errors/invalid_api_request_spec.rb +1 -1
  15. data/spec/drillbit/errors/invalid_request_body_spec.rb +1 -1
  16. data/spec/drillbit/errors/invalid_subdomain_spec.rb +1 -1
  17. data/spec/drillbit/errors/invalid_token_spec.rb +1 -1
  18. data/spec/drillbit/invalid_subdomain_spec.rb +1 -1
  19. data/spec/drillbit/invalid_token_spec.rb +1 -1
  20. data/spec/drillbit/matchers/accept_header_spec.rb +1 -1
  21. data/spec/drillbit/matchers/subdomain_spec.rb +1 -1
  22. data/spec/drillbit/matchers/version_spec.rb +1 -1
  23. data/spec/drillbit/middleware/api_request_validator_spec.rb +1 -1
  24. data/spec/drillbit/middleware/token_processor_spec.rb +1 -1
  25. data/spec/drillbit/requests/base_spec.rb +1 -1
  26. data/spec/drillbit/requests/rack_spec.rb +1 -2
  27. data/spec/drillbit/requests/rails_spec.rb +1 -1
  28. data/spec/drillbit/resource/model_spec.rb +1 -1
  29. data/spec/drillbit/resource/processors/filtering_spec.rb +1 -1
  30. data/spec/drillbit/resource/processors/indexing_spec.rb +2 -3
  31. data/spec/drillbit/resource/processors/paging_spec.rb +1 -1
  32. data/spec/drillbit/resource/processors/sorting_spec.rb +1 -1
  33. data/spec/drillbit/tokens/base64_spec.rb +1 -1
  34. data/spec/drillbit/tokens/json_web_token_spec.rb +1 -1
  35. data/spec/drillbit/tokens/json_web_tokens/password_reset_spec.rb +1 -1
  36. data/spec/support/private_keys.rb +0 -2
  37. metadata +5 -5
  38. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35653ddb12a3ac73697b766d3729913aabeabbf0
4
- data.tar.gz: d91cf79e75b637a9801d2b2c22d96d408d4ccc46
3
+ metadata.gz: 661d2f0c465f93327b9baa2a3e2feabf6c066cd1
4
+ data.tar.gz: 0742f6aa1d4b375be2cff08ab70eff87ce908faf
5
5
  SHA512:
6
- metadata.gz: e3ee79969053c7c2248eda17f8705e2a4c7ec6f4b507e657ed33181b6cf91d54cf9fe0c3f5f13a4c10b348a582ca4890531c5413a6cdf999076c55e18c336d65
7
- data.tar.gz: c9bfd0d14eb6d2c46bc5d2e539131f861608c877cf40281d223c3ebec0d7d5d450d11f01b253df6e6404308610d1b972d13cfd5334da68b4456a4e15f9284346
6
+ metadata.gz: 00d8164c6424c877f31797741adc5371d7895969958ca81ce24eb9ae937c96e34b3367eb541c4d9b39b90d21145600f322d6d0a82b4b42769e4ad6f5363f6b34
7
+ data.tar.gz: 17eaf922c23f0e3da08edac204ad321e0e8e64e5e6a2e27c4f0ec5b674c8eaf2361833fd70203eb7268068c0dff2dd4815bebc89b29d020d46aaff874b7454c6
Binary file
data.tar.gz.sig CHANGED
@@ -1,3 +1 @@
1
- �\I��O,.���Z��%)^��ϡ���a�z���Ђ��py8%�f�d3u�׭5�;���
2
- ���[���~�>�����}�#;A��>uV]��� �
3
- ���XH�w� @cV��c:A+\��tLб�B�Q�s^IY+r`�����È�M��}����Nݞ��t�����YZ>b�aE��7e����(�<
1
+ BiCb��ݽ�z�}Pq������Es_�YAJ�޾�x~Ɂj��󑊑�.�y^m��r�0 ���ې��6�%�}��x'c`�3q�A���"�B�����^G7����Ю\hO�F���_Z�Uه��&��)����}?����f8���1m%���+$�rb\�ZE(�ԛ@��%?TY��bl����@]���6�;�B�+�!}Y���9j���#�u6d�_W>��5s<�L��m����i�N��e鿬� ��@�q�B�j
@@ -71,12 +71,14 @@ module AuthorizableResource
71
71
  private
72
72
 
73
73
  def authorize
74
+ return if authorizer.public_send(authorization_query)
75
+
74
76
  Erratum.raise(
75
77
  'ForbiddenError',
76
78
  resource_name: self.class.singular_resource_name,
77
79
  resource_id: [params[:id]],
78
80
  action: action_name,
79
- ) unless authorizer.public_send(authorization_query)
81
+ )
80
82
  end
81
83
 
82
84
  def authorizer
@@ -123,7 +125,8 @@ module AuthorizableResource
123
125
  end
124
126
 
125
127
  # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
126
- # rubocop:disable Metrics/CyclomaticComplexity
128
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
129
+ # rubocop:disable Metrics/BlockNesting
127
130
  def authorized_attributes
128
131
  @authorized_attributes ||= begin
129
132
  attributes = authorized_params.
@@ -158,12 +161,15 @@ module AuthorizableResource
158
161
  end
159
162
  end
160
163
 
164
+ relationships.permit! if relationships.respond_to?(:permit!)
165
+
161
166
  ActiveSupport::Deprecation.silence do
162
167
  attributes.merge(relationships)
163
168
  end
164
169
  end
165
170
  end
166
- # rubocop:enable Metrics/CyclomaticComplexity
171
+ # rubocop:enable Metrics/BlockNesting
172
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
167
173
  # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
168
174
 
169
175
  def authorized_resource
@@ -53,7 +53,7 @@ class Resource < Authorizers::Parameters
53
53
  end
54
54
 
55
55
  # rubocop:disable Metrics/AbcSize
56
- def add_authorized_relationship(name, embedded_attributes: {})
56
+ def add_authorized_relationship(name, embedded_attributes: [])
57
57
  param = params.
58
58
  fetch(:data, {}).
59
59
  fetch(:relationships, {}).
@@ -5,7 +5,6 @@ require 'drillbit/accept_header'
5
5
  require 'drillbit/tokens/json_web_token'
6
6
  require 'drillbit/tokens/base64'
7
7
 
8
- # rubocop:disable Style/VariableNumber
9
8
  module Drillbit
10
9
  module Requests
11
10
  class Rack < Base
@@ -50,4 +49,3 @@ class Rack < Base
50
49
  end
51
50
  end
52
51
  end
53
- # rubocop:enable Style/VariableNumber
@@ -8,9 +8,9 @@ class InvalidApiRequest
8
8
  error = Drillbit::Errors::InvalidApiRequest.new(accept_header: env['HTTP_ACCEPT'])
9
9
 
10
10
  [
11
- error.http_status, # HTTP Status Code
12
- {}, # Response Headers
13
- [error.to_json], # Message
11
+ error.http_status, # HTTP Status Code
12
+ {}, # Response Headers
13
+ ["{\"errors\": [#{error.to_json}]}"], # Message
14
14
  ]
15
15
  end
16
16
  end
@@ -8,9 +8,9 @@ class InvalidRequestBody
8
8
  error = Drillbit::Errors::InvalidRequestBody.new(request_body: env['RACK_INPUT'])
9
9
 
10
10
  [
11
- error.http_status, # HTTP Status Code
12
- {}, # Response Headers
13
- [error.to_json], # Message
11
+ error.http_status, # HTTP Status Code
12
+ {}, # Response Headers
13
+ ["{\"errors\": [#{error.to_json}]}"], # Message
14
14
  ]
15
15
  end
16
16
  end
@@ -8,9 +8,9 @@ class InvalidSubdomain
8
8
  error = Drillbit::Errors::InvalidSubdomain.new(http_host: env['HTTP_HOST'])
9
9
 
10
10
  [
11
- error.http_status, # HTTP Status Code
12
- {}, # Response Headers
13
- [error.to_json], # Message
11
+ error.http_status, # HTTP Status Code
12
+ {}, # Response Headers
13
+ ["{\"errors\": [#{error.to_json}]}"], # Message
14
14
  ]
15
15
  end
16
16
  end
@@ -8,11 +8,11 @@ class InvalidToken
8
8
  error = Drillbit::Errors::InvalidToken.new
9
9
 
10
10
  [
11
- error.http_status, # HTTP Status Code
12
- { # Response Headers
11
+ error.http_status, # HTTP Status Code
12
+ { # Response Headers
13
13
  'WWW-Authenticate' => %Q{Token realm="#{application_name}"},
14
14
  },
15
- [error.to_json], # Message
15
+ ["{\"errors\": [#{error.to_json}]}"], # Message
16
16
  ]
17
17
  end
18
18
  end
@@ -9,7 +9,7 @@ class PasswordReset < JsonWebToken
9
9
  roles: ['password_reset'],
10
10
  **attrs)
11
11
 
12
- super(:expiration => expiration, :roles => roles, **attrs)
12
+ super(expiration: expiration, roles: roles, **attrs)
13
13
  end
14
14
  end
15
15
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Drillbit
3
- VERSION = '2.9.1'
3
+ VERSION = '2.10.0'
4
4
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/accept_header'
4
4
 
5
5
  # rubocop:disable Metrics/LineLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/errors/invalid_api_request'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/errors/invalid_request_body'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/errors/invalid_subdomain'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/errors/invalid_token'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/responses/invalid_subdomain'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/responses/invalid_token'
4
4
 
5
5
  # rubocop:disable Metrics/LineLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/requests/base'
4
4
  require 'drillbit/matchers/accept_header'
5
5
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/requests/base'
4
4
  require 'drillbit/matchers/subdomain'
5
5
  require 'drillbit/configuration'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/requests/base'
4
4
  require 'drillbit/matchers/version'
5
5
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/middleware/api_request_validator'
4
4
 
5
5
  # rubocop:disable Metrics/LineLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/middleware/token_processor'
4
4
 
5
5
  module Drillbit
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require 'ostruct'
3
- require 'spec_helper'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
4
  require 'drillbit/requests/base'
5
5
 
6
6
  module Drillbit
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/requests/rack'
4
4
 
5
- # rubocop:disable Metrics/LineLength
6
5
  module Drillbit
7
6
  module Requests
8
7
  describe Rack do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require 'ostruct'
3
- require 'spec_helper'
3
+ require 'rspeckled/spec_helpers/rspeckled'
4
4
  require 'drillbit/requests/rails'
5
5
 
6
6
  # rubocop:disable Metrics/LineLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/resource/model'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/resource/processors/filtering'
4
4
 
5
5
  module Drillbit
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/resource/processors/indexing'
4
4
 
5
5
  module Drillbit
6
6
  class TestIndexClass
7
- def for_query(_param)
8
- end
7
+ def for_query(_param); end
9
8
  end
10
9
  end
11
10
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/resource/processors/paging'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/resource/processors/sorting'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/tokens/base64'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/tokens/json_web_token'
4
4
 
5
5
  module Drillbit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+ require 'rspeckled/spec_helpers/rspeckled'
3
3
  require 'drillbit/tokens/json_web_tokens/password_reset'
4
4
 
5
5
  module Drillbit
@@ -33,7 +33,6 @@ def invalid_jwe_token
33
33
  @invalid_jwe_token ||= valid_jwe_token.tr('a', 'f')
34
34
  end
35
35
 
36
- # rubocop:disable Style/VariableNumber
37
36
  def valid_b64_token(payload = 'hereisacoollittlestring')
38
37
  @valid_b64_token ||= Base64.encode64(payload).chomp
39
38
  end
@@ -41,4 +40,3 @@ end
41
40
  def invalid_b64_token
42
41
  @invalid_b64_token ||= valid_b64_token.tr('abcdefghijklmnop', '$o#m$k#i$g#e$c#a')
43
42
  end
44
- # rubocop:enable Style/VariableNumber
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drillbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.1
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
@@ -31,7 +31,7 @@ cert_chain:
31
31
  zRIv8lqQM8QFT76rzP5SBCERwN+ltKAFbQ5/FwmZNGWYnmCP3RZMQiRnbh+9H9lh
32
32
  mlbwaYZTjgsXq6cy8N38EecewgBbZYS1IYJraE/M
33
33
  -----END CERTIFICATE-----
34
- date: 2016-10-28 00:00:00.000000000 Z
34
+ date: 2017-02-17 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: erratum
@@ -109,14 +109,14 @@ dependencies:
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: 0.7.0
112
+ version: 0.8.0
113
113
  type: :development
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: 0.7.0
119
+ version: 0.8.0
120
120
  description: ''
121
121
  email: rubygems@livinghighontheblog.com
122
122
  executables: []
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  version: '0'
234
234
  requirements: []
235
235
  rubyforge_project:
236
- rubygems_version: 2.5.1
236
+ rubygems_version: 2.6.8
237
237
  signing_key:
238
238
  specification_version: 4
239
239
  summary: APIs Need Love Too
metadata.gz.sig CHANGED
Binary file