scimitar 1.2.0 → 1.2.1

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
  SHA256:
3
- metadata.gz: f4361be0d5f54ce11106a22215c7ec4167a877961dc775908e902f3c6abc281e
4
- data.tar.gz: b4e721e5f247b4ed1f3fa1a65f0f68b4572bc4d41ad44a68d37578c41d71e718
3
+ metadata.gz: 69cae1bb9cbd4ddcdf7914e35b4ac23ad7359c2d566d99071dfb346ae8b2f9d2
4
+ data.tar.gz: c1636e01e98e1938a1f62ffd27b8aa0c00a787860f93a95f445158cb8e7e6064
5
5
  SHA512:
6
- metadata.gz: f373036a611555190e8d15bfd021be1bda8dc3bd358d58dfc8825f656bcdd648a5b7b2c06e091c58455b7eadec6277ccbf58646dd2b26bc4f9864dd6aa2761e7
7
- data.tar.gz: e05d6fd73646929393c7edfea91076bf475fb1f997be0692130a5ba12b2d0f56ee8e106f775b1cdabdf8ed8723d56042b4941c110f66ce800b6868336d6762f7
6
+ metadata.gz: 321cf5943bf587c925c827d909cb8dda138be977a03e211b1a7496e0c608da1055a0e4fb9aaa1d8f9877d5631a34dbba5f16c00b50098ca08b5bdfa6fed2cff2
7
+ data.tar.gz: 910f2e4f85c7722f71229cdbd680af6af64aa7d1186e8464ad6050b338f97bf6849042407b241acfc409a63ce8fe48023f1f251d3712d1ec8298cb91d911ce0f
@@ -82,12 +82,17 @@ module Scimitar
82
82
  # request and subclass processing.
83
83
  #
84
84
  def require_scim
85
- if request.content_type&.downcase == Mime::Type.lookup_by_extension(:scim).to_s
85
+ scim_mime_type = Mime::Type.lookup_by_extension(:scim).to_s
86
+
87
+ if request.content_type.nil?
88
+ request.format = :scim
89
+ request.headers['CONTENT_TYPE'] = scim_mime_type
90
+ elsif request.content_type&.downcase == scim_mime_type
86
91
  request.format = :scim
87
92
  elsif request.format == :scim
88
- request.headers['CONTENT_TYPE'] = Mime::Type.lookup_by_extension(:scim).to_s
93
+ request.headers['CONTENT_TYPE'] = scim_mime_type
89
94
  else
90
- handle_scim_error(ErrorResponse.new(status: 406, detail: "Only #{Mime::Type.lookup_by_extension(:scim)} type is accepted."))
95
+ handle_scim_error(ErrorResponse.new(status: 406, detail: "Only #{scim_mime_type} type is accepted."))
91
96
  end
92
97
  end
93
98
 
@@ -138,7 +138,7 @@ module Scimitar
138
138
  end
139
139
 
140
140
  def as_json(options = {})
141
- self.meta = Meta.new unless self.meta
141
+ self.meta = Meta.new unless self.meta && self.meta.is_a?(Meta)
142
142
  meta.resourceType = self.class.resource_type_id
143
143
  original_hash = super(options).except('errors')
144
144
  original_hash.merge!('schemas' => self.class.schemas.map(&:id))
@@ -3,11 +3,11 @@ module Scimitar
3
3
  # Gem version. If this changes, be sure to re-run "bundle install" or
4
4
  # "bundle update".
5
5
  #
6
- VERSION = '1.2.0'
6
+ VERSION = '1.2.1'
7
7
 
8
8
  # Date for VERSION. If this changes, be sure to re-run "bundle install"
9
9
  # or "bundle update".
10
10
  #
11
- DATE = '2021-09-27'
11
+ DATE = '2022-06-15'
12
12
 
13
13
  end
@@ -180,6 +180,7 @@ RSpec.describe Scimitar::ActiveRecordBackedResourcesController do
180
180
  givenName: 'Given',
181
181
  familyName: 'Family'
182
182
  },
183
+ meta: { resourceType: 'User' },
183
184
  emails: [
184
185
  {
185
186
  type: 'work',
@@ -11,11 +11,14 @@ RSpec.describe Scimitar::ApplicationController do
11
11
  end
12
12
 
13
13
  context 'format handling' do
14
- it 'renders "not acceptable" if the request does not use SCIM type' do
14
+ it 'renders "OK" if the request does not provide any Content-Type value' do
15
15
  get '/CustomRequestVerifiers', params: { format: :html }
16
16
 
17
- expect(response).to have_http_status(:not_acceptable)
18
- expect(JSON.parse(response.body)['detail']).to eql('Only application/scim+json type is accepted.')
17
+ expect(response).to have_http_status(:ok)
18
+ parsed_body = JSON.parse(response.body)
19
+ expect(parsed_body['request']['is_scim' ]).to eql(true)
20
+ expect(parsed_body['request']['format' ]).to eql('application/scim+json')
21
+ expect(parsed_body['request']['content_type']).to eql('application/scim+json')
19
22
  end
20
23
 
21
24
  it 'renders 400 if given bad JSON' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scimitar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - RIPA Global
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-27 00:00:00.000000000 Z
12
+ date: 2022-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -260,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  - !ruby/object:Gem::Version
261
261
  version: '0'
262
262
  requirements: []
263
- rubygems_version: 3.2.28
263
+ rubygems_version: 3.1.6
264
264
  signing_key:
265
265
  specification_version: 4
266
266
  summary: SCIM v2 for Rails