Skip to content

Commit

Permalink
Merge pull request #129 from RIPAGlobal/feature/fix-user-name-required
Browse files Browse the repository at this point in the history
Address #113 - user.givenName / user.familyName are *not* mandatory
  • Loading branch information
bagp1 authored Jun 12, 2024
2 parents 1634db5 + a449c26 commit 0c8a088
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/models/scimitar/schema/name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Name < Base

def self.scim_attributes
@scim_attributes ||= [
Attribute.new(name: 'familyName', type: 'string', required: true),
Attribute.new(name: 'givenName', type: 'string', required: true),
Attribute.new(name: 'familyName', type: 'string'),
Attribute.new(name: 'givenName', type: 'string'),
Attribute.new(name: 'middleName', type: 'string'),
Attribute.new(name: 'formatted', type: 'string'),
Attribute.new(name: 'honorificPrefix', type: 'string'),
Expand Down
20 changes: 10 additions & 10 deletions app/models/scimitar/schema/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.scim_attributes
[
Attribute.new(name: 'userName', type: 'string', uniqueness: 'server', required: true),

Attribute.new(name: 'name', complexType: Scimitar::ComplexTypes::Name),
Attribute.new(name: 'name', complexType: Scimitar::ComplexTypes::Name),

Attribute.new(name: 'displayName', type: 'string'),
Attribute.new(name: 'nickName', type: 'string'),
Expand All @@ -35,15 +35,15 @@ def self.scim_attributes

Attribute.new(name: 'password', type: 'string', mutability: 'writeOnly', returned: 'never'),

Attribute.new(name: 'emails', multiValued: true, complexType: Scimitar::ComplexTypes::Email),
Attribute.new(name: 'phoneNumbers', multiValued: true, complexType: Scimitar::ComplexTypes::PhoneNumber),
Attribute.new(name: 'ims', multiValued: true, complexType: Scimitar::ComplexTypes::Ims),
Attribute.new(name: 'photos', multiValued: true, complexType: Scimitar::ComplexTypes::Photo),
Attribute.new(name: 'addresses', multiValued: true, complexType: Scimitar::ComplexTypes::Address),
Attribute.new(name: 'groups', multiValued: true, complexType: Scimitar::ComplexTypes::ReferenceGroup, mutability: 'readOnly'),
Attribute.new(name: 'entitlements', multiValued: true, complexType: Scimitar::ComplexTypes::Entitlement),
Attribute.new(name: 'roles', multiValued: true, complexType: Scimitar::ComplexTypes::Role),
Attribute.new(name: 'x509Certificates', multiValued: true, complexType: Scimitar::ComplexTypes::X509Certificate),
Attribute.new(name: 'emails', multiValued: true, complexType: Scimitar::ComplexTypes::Email),
Attribute.new(name: 'phoneNumbers', multiValued: true, complexType: Scimitar::ComplexTypes::PhoneNumber),
Attribute.new(name: 'ims', multiValued: true, complexType: Scimitar::ComplexTypes::Ims),
Attribute.new(name: 'photos', multiValued: true, complexType: Scimitar::ComplexTypes::Photo),
Attribute.new(name: 'addresses', multiValued: true, complexType: Scimitar::ComplexTypes::Address),
Attribute.new(name: 'groups', multiValued: true, complexType: Scimitar::ComplexTypes::ReferenceGroup, mutability: 'readOnly'),
Attribute.new(name: 'entitlements', multiValued: true, complexType: Scimitar::ComplexTypes::Entitlement),
Attribute.new(name: 'roles', multiValued: true, complexType: Scimitar::ComplexTypes::Role),
Attribute.new(name: 'x509Certificates', multiValued: true, complexType: Scimitar::ComplexTypes::X509Certificate),
]
end

Expand Down
17 changes: 15 additions & 2 deletions spec/models/scimitar/resources/base_validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ def self.id
'custom-id'
end

class NameWithRequirementsSchema < Scimitar::Schema::Base
def self.scim_attributes
@scim_attributes ||= [
Scimitar::Schema::Attribute.new(name: 'familyName', type: 'string', required: true),
Scimitar::Schema::Attribute.new(name: 'givenName', type: 'string', required: true),
]
end
end

class NameWithRequirementsComplexType < Scimitar::ComplexTypes::Base
set_schema NameWithRequirementsSchema
end

def self.scim_attributes
[
Scimitar::Schema::Attribute.new(
Expand All @@ -16,10 +29,10 @@ def self.scim_attributes
name: 'enforce', type: 'boolean', required: true
),
Scimitar::Schema::Attribute.new(
name: 'complexName', complexType: Scimitar::ComplexTypes::Name, required: false
name: 'complexName', complexType: NameWithRequirementsComplexType, required: false
),
Scimitar::Schema::Attribute.new(
name: 'complexNames', complexType: Scimitar::ComplexTypes::Name, multiValued:true, required: false
name: 'complexNames', complexType: Scimitar::ComplexTypes::Name, multiValued: true, required: false
),
Scimitar::Schema::Attribute.new(
name: 'vdtpTestByEmail', complexType: Scimitar::ComplexTypes::Email, required: false
Expand Down
4 changes: 2 additions & 2 deletions spec/models/scimitar/schema/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"subAttributes": [
{
"multiValued": false,
"required": true,
"required": false,
"caseExact": false,
"mutability": "readWrite",
"uniqueness": "none",
Expand All @@ -37,7 +37,7 @@
},
{
"multiValued": false,
"required": true,
"required": false,
"caseExact": false,
"mutability": "readWrite",
"uniqueness": "none",
Expand Down

0 comments on commit 0c8a088

Please sign in to comment.