Commit f979a08
Changed files (3)
lib
scim
shady
spec
lib/scim/shady/enterprise_user.rb
@@ -0,0 +1,63 @@
+module Scim
+ module Shady
+ class EnterpriseUser < ::Scim::Kit::V2::Resource
+ def initialize(attributes = {})
+ super(schemas: [User.schema, self.class.schema], attributes: attributes)
+ end
+
+ def template_name
+ 'resource.json.jbuilder'
+ end
+
+ def self.schema(location: "/v2/Schemas/urn:ietf:params:scim:schemas:extension:enterprise:2.0:User")
+ schema = ::Scim::Kit::V2::Schema.new(id: "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User", name: 'EnterpriseUser', location: location)
+ schema.add_attribute(name: :employee_number, type: :string) do |x|
+ x.multi_valued = false
+ x.description = "Numeric or alphanumeric identifier assigned to a person, typically based on order of hire or association with an organization."
+ x.required = false
+ x.case_exact = false
+ x.mutability = :read_write
+ x.returned = :default
+ x.uniqueness = :none
+ end
+ schema.add_attribute(name: :cost_center, type: :string) do |x|
+ x.multi_valued = false
+ x.description = "Identifies the name of a cost center."
+ x.required = false
+ x.case_exact = false
+ x.mutability = :read_write
+ x.returned = :default
+ x.uniqueness = :none
+ end
+ schema.add_attribute(name: :organization, type: :string) do |x|
+ x.multi_valued = false
+ x.description = "Identifies the name of an organization."
+ x.required = false
+ x.case_exact = false
+ x.mutability = :read_write
+ x.returned = :default
+ x.uniqueness = :none
+ end
+ schema.add_attribute(name: :division, type: :string) do |x|
+ x.multi_valued = false
+ x.description = "Identifies the name of a division."
+ x.required = false
+ x.case_exact = false
+ x.mutability = :read_write
+ x.returned = :default
+ x.uniqueness = :none
+ end
+ schema.add_attribute(name: :department, type: :string) do |x|
+ x.multi_valued = false
+ x.description = "Identifies the name of a department."
+ x.required = false
+ x.case_exact = false
+ x.mutability = :read_write
+ x.returned = :default
+ x.uniqueness = :none
+ end
+ schema
+ end
+ end
+ end
+end
lib/scim/shady.rb
@@ -1,6 +1,7 @@
require 'json'
require 'scim-kit'
+require 'scim/shady/enterprise_user'
require 'scim/shady/user'
require 'scim/shady/group'
require 'scim/shady/version'
spec/scim/enterprise_user_spec.rb
@@ -0,0 +1,25 @@
+RSpec.describe Scim::Shady::EnterpriseUser do
+ subject { described_class.new }
+
+ before do
+ subject.user_name = 'bjensen'
+ subject.name.formatted = "Ms. Barbara J Jensen, III"
+ subject.name.family_name = "Jensen"
+ subject.name.given_name = "Barbara"
+ subject.name.middle_name = "Jane"
+ subject.name.honorific_prefix = "Ms."
+ subject.name.honorific_suffix = "III"
+ subject.display_name = "Barbara Jensen"
+ subject.nick_name = "Barb"
+ subject.preferred_language = "en_US"
+ subject.locale = "en"
+ subject.timezone = "America/Los_Angeles"
+ subject.active = true
+ subject.employee_number = '1'
+ subject.cost_center = SecureRandom.uuid
+ subject.organization = SecureRandom.uuid
+ subject.department = SecureRandom.uuid
+ end
+
+ specify { expect(subject).to be_valid }
+end