Commit 596df3c
Changed files (2)
lib
scim
kit
spec
scim
kit
lib/scim/kit/v2/configuration.rb
@@ -5,17 +5,28 @@ module Scim
module V2
class Configuration
class Builder
+ def initialize
+ @resource_types = {}
+ end
+
def service_provider_configuration(location:)
@sp_config = ServiceProviderConfiguration.new(location: location)
yield @sp_config
end
+ def resource_type(id:, location:)
+ @resource_types[id] ||= ResourceType.new(location: location)
+ yield @resource_types[id]
+ end
+
def apply_to(configuration)
configuration.service_provider_configuration = @sp_config
+ configuration.resource_types = @resource_types
end
end
attr_accessor :service_provider_configuration
+ attr_accessor :resource_types
def initialize
builder = Builder.new
spec/scim/kit/v2/configuration_spec.rb
@@ -7,12 +7,23 @@ RSpec.describe Scim::Kit::V2::Configuration do
y.add_authentication(:oauthbearertoken)
y.change_password.supported = true
end
+ x.resource_type(id: 'User', location: user_type_location) do |y|
+ y.schema = Scim::Kit::V2::Schemas::USER
+ end
+ x.resource_type(id: 'Group', location: group_type_location) do |y|
+ y.schema = Scim::Kit::V2::Schemas::GROUP
+ end
end
end
let(:sp_location) { FFaker::Internet.uri('https') }
+ let(:user_type_location) { FFaker::Internet.uri('https') }
+ let(:group_type_location) { FFaker::Internet.uri('https') }
specify { expect(subject.service_provider_configuration.meta.location).to eql(sp_location) }
specify { expect(subject.service_provider_configuration.authentication_schemes[0].type).to be(:oauthbearertoken) }
specify { expect(subject.service_provider_configuration.change_password.supported).to be(true) }
+
+ specify { expect(subject.resource_types['User'].schema).to eql(Scim::Kit::V2::Schemas::USER) }
+ specify { expect(subject.resource_types['Group'].schema).to eql(Scim::Kit::V2::Schemas::GROUP) }
end