Commit 2fc11e3
Changed files (3)
lib
scim
kit
spec
scim
kit
lib/scim/kit/v2/mutability.rb
@@ -11,10 +11,13 @@ module Scim
WRITE_ONLY = 'writeOnly'
VALID = {
immutable: IMMUTABLE,
+ readOnly: READ_ONLY,
+ readWrite: READ_WRITE,
read_only: READ_ONLY,
read_write: READ_WRITE,
readonly: READ_ONLY,
readwrite: READ_WRITE,
+ writeOnly: WRITE_ONLY,
write_only: WRITE_ONLY,
writeonly: WRITE_ONLY
}.freeze
lib/scim/kit/v2/schema.rb
@@ -40,6 +40,19 @@ module Scim
hash = JSON.parse(json, symbolize_names: true)
Schema.new(id: hash[:id], name: hash[:name], location: hash[:location]) do |x|
x.meta = Meta.from(hash[:meta])
+ hash[:attributes].each do |attribute|
+ x.add_attribute(name: attribute[:name], type: attribute[:type]) do |y|
+ y.description = attribute[:description]
+ y.multi_valued = attribute[:multiValued]
+ y.required = attribute[:required]
+ y.case_exact = attribute[:caseExact]
+ y.mutability = attribute[:mutability]
+ y.returned = attribute[:returned]
+ y.uniqueness = attribute[:uniqueness]
+ y.canonical_values = attribute[:canonicalValues]
+ y.reference_types = attribute[:referenceTypes]
+ end
+ end
end
end
end
spec/scim/kit/v2/schema_spec.rb
@@ -123,10 +123,20 @@ RSpec.describe Scim::Kit::V2::Schema do
specify { expect(result[:meta][:location]).to eql(location) }
end
- describe ".parse" do
+ describe '.parse' do
let(:result) { described_class.parse(subject.to_json) }
+
before do
- subject.add_attribute(name: :display_name)
+ subject.add_attribute(name: :display_name) do |x|
+ x.multi_valued = true
+ x.required = true
+ x.case_exact = true
+ x.mutability = :read_only
+ x.returned = :never
+ x.uniqueness = :server
+ x.canonical_values = ['honerva']
+ x.reference_types = %w[User Group]
+ end
end
specify { expect(result.id).to eql(subject.id) }
@@ -137,6 +147,7 @@ RSpec.describe Scim::Kit::V2::Schema do
specify { expect(result.meta.version).to eql(subject.meta.version) }
specify { expect(result.meta.location).to eql(subject.meta.location) }
specify { expect(result.meta.resource_type).to eql(subject.meta.resource_type) }
- pending { expect(result.to_json).to eql(subject.to_json) }
+ specify { expect(result.to_json).to eql(subject.to_json) }
+ specify { expect(result.to_h).to eql(subject.to_h) }
end
end