diff options
| author | mo <mo.khan@gmail.com> | 2019-01-19 15:47:21 -0700 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2019-01-19 15:47:21 -0700 |
| commit | dedb49a447ddae1c417d2d148c122a7231a46f9f (patch) | |
| tree | 4485473fc65bed01afed035879eca670da1a68bd | |
| parent | 45b65da85c0ab2114299331b492961918d8c65dd (diff) | |
add scim group
| -rw-r--r-- | lib/scim/shady.rb | 1 | ||||
| -rw-r--r-- | lib/scim/shady/group.rb | 61 | ||||
| -rw-r--r-- | spec/scim/group_spec.rb | 10 |
3 files changed, 72 insertions, 0 deletions
diff --git a/lib/scim/shady.rb b/lib/scim/shady.rb index 2f7c6ae..cb00361 100644 --- a/lib/scim/shady.rb +++ b/lib/scim/shady.rb @@ -2,6 +2,7 @@ require 'json' require 'scim-kit' require 'scim/shady/user' +require 'scim/shady/group' require 'scim/shady/version' module Scim diff --git a/lib/scim/shady/group.rb b/lib/scim/shady/group.rb new file mode 100644 index 0000000..6da7918 --- /dev/null +++ b/lib/scim/shady/group.rb @@ -0,0 +1,61 @@ +module Scim + module Shady + class Group < ::Scim::Kit::V2::Resource + def initialize(attributes = {}) + super(schemas: [self.class.schema], attributes: attributes) + end + + def template_name + 'resource.json.jbuilder' + end + + def self.schema(location: "/v2/Schemas/#{::Scim::Kit::V2::Schemas::GROUP}") + schema = ::Scim::Kit::V2::Schema.new(id: ::Scim::Kit::V2::Schemas::GROUP, name: 'Group', location: location) + schema.add_attribute(name: :display_name, type: :string) do |x| + x.multi_valued = false + x.description = "A human-readable name for the Group. REQUIRED." + x.required = false + x.case_exact = false + x.mutability = :read_write + x.returned = :default + x.uniqueness = :none + end + schema.add_attribute(name: :members, type: :complex) do |x| + x.multi_valued = true + x.description = "A list of members of the Group." + x.required = false + x.add_attribute(name: :value, type: :string) do |y| + y.multi_valued = false + y.description = "Identifier of the member of this Group." + y.required = false + y.case_exact = false + y.mutability = :immutable + y.returned = :default + y.uniqueness = :none + end + x.add_attribute(name: '$ref', type: :reference) do |y| + y.reference_types = ['User', 'Group'] + y.multi_valued = false + y.description = "The URI corresponding to a SCIM resource that is a member of this Group." + y.required = false + y.case_exact = false + y.mutability = :immutable + y.returned = :default + y.uniqueness = :none + end + x.add_attribute(name: :type, type: :string) do |y| + y.multi_valued = false + y.description = "A label indicating the type of resource, e.g., 'User' or 'Group'." + y.required = false + y.case_exact = false + y.canonical_values = ['User', 'Group'] + y.mutability = :immutable + y.returned = :default + y.uniqueness = :none + end + end + schema + end + end + end +end diff --git a/spec/scim/group_spec.rb b/spec/scim/group_spec.rb new file mode 100644 index 0000000..02f3a5a --- /dev/null +++ b/spec/scim/group_spec.rb @@ -0,0 +1,10 @@ +RSpec.describe Scim::Shady::Group do + subject { described_class.new } + + before do + subject.display_name = 'voltron' + subject.members << { value: SecureRandom.uuid, '$ref' => FFaker::Internet.uri('https'), type: 'User' } + end + + specify { expect(subject).to be_valid } +end |
