Commit ee7326f
Changed files (3)
lib
scim
kit
spec
scim
kit
lib/scim/kit/v2/schema.rb
@@ -17,6 +17,7 @@ module Scim
@meta = Meta.new('Schema', location)
@meta.created = @meta.last_modified = @meta.version = nil
@attributes = []
+ yield self if block_given?
end
def add_attribute(name:, type: :string)
@@ -26,7 +27,7 @@ module Scim
end
def core?
- id.include?(Schemas::CORE)
+ id.include?(Schemas::CORE) || id.include?(Messages::CORE)
end
def self.build(*args)
lib/scim/kit/v2/schemas.rb
@@ -13,6 +13,27 @@ module Scim
RESOURCE_TYPE = "#{CORE}:ResourceType"
SERVICE_PROVIDER_CONFIGURATION = "#{CORE}:ServiceProviderConfig"
USER = "#{CORE}:User"
+
+ def self.error
+ Schema.new(id: Messages::ERROR, name: 'Error', location: nil) do |schema|
+ schema.add_attribute(name: :scim_type) do |attribute|
+ attribute.canonical_values = [
+ 'invalidPath',
+ 'invalidSyntax',
+ 'invalidSyntax',
+ 'invalidValue',
+ 'invalidVers',
+ 'mutability',
+ 'noTarget',
+ 'sensitive',
+ 'tooMany',
+ 'uniqueness',
+ ]
+ end
+ schema.add_attribute(name: :detail)
+ schema.add_attribute(name: :status, type: :integer)
+ end
+ end
end
end
end
spec/scim/kit/v2/resource_spec.rb
@@ -471,4 +471,20 @@ RSpec.describe Scim::Kit::V2::Resource do
specify { expect(subject.emails[0][:primary]).to be(true) }
end
end
+
+ describe "Errors" do
+ subject { described_class.new(schemas: schemas) }
+ let(:schemas) { [Scim::Kit::V2::Schemas.error] }
+
+ before do
+ subject.scim_type = :invalidSyntax
+ subject.detail = "error"
+ subject.status = 400
+ end
+
+ specify { expect(subject.to_h[:schemas]).to match_array([Scim::Kit::V2::Messages::ERROR]) }
+ specify { expect(subject.to_h[:scimType]).to eql('invalidSyntax') }
+ specify { expect(subject.to_h[:detail]).to eql('error') }
+ specify { expect(subject.to_h[:status]).to be(400) }
+ end
end