-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from RIPAGlobal/feature/request-attributes
Allow requesting specific attributes (derived from #102)
- Loading branch information
Showing
4 changed files
with
144 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,6 +255,47 @@ def self.scim_queryable_attributes | |
# ========================================================================= | ||
|
||
context '#to_scim' do | ||
context 'with list of requested attributes' do | ||
it 'compiles instance attribute values into a SCIM representation, including only the requested attributes' do | ||
uuid = SecureRandom.uuid | ||
|
||
instance = MockUser.new | ||
instance.primary_key = uuid | ||
instance.scim_uid = 'AA02984' | ||
instance.username = 'foo' | ||
instance.password = 'correcthorsebatterystaple' | ||
instance.first_name = 'Foo' | ||
instance.last_name = 'Bar' | ||
instance.work_email_address = '[email protected]' | ||
instance.home_email_address = nil | ||
instance.work_phone_number = '+642201234567' | ||
instance.organization = 'SOMEORG' | ||
|
||
g1 = MockGroup.create!(display_name: 'Group 1') | ||
g2 = MockGroup.create!(display_name: 'Group 2') | ||
g3 = MockGroup.create!(display_name: 'Group 3') | ||
|
||
g1.mock_users << instance | ||
g3.mock_users << instance | ||
|
||
scim = instance.to_scim(location: "https://test.com/mock_users/#{uuid}", include_attributes: %w[id userName name groups.display groups.value organization]) | ||
json = scim.to_json() | ||
hash = JSON.parse(json) | ||
|
||
expect(hash).to eql({ | ||
'id' => uuid, | ||
'userName' => 'foo', | ||
'name' => {'givenName'=>'Foo', 'familyName'=>'Bar'}, | ||
'groups' => [{'display'=>g1.display_name, 'value'=>g1.id.to_s}, {'display'=>g3.display_name, 'value'=>g3.id.to_s}], | ||
'meta' => {'location'=>"https://test.com/mock_users/#{uuid}", 'resourceType'=>'User'}, | ||
'schemas' => ['urn:ietf:params:scim:schemas:core:2.0:User', 'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User'], | ||
'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User' => { | ||
'organization' => 'SOMEORG', | ||
}, | ||
}) | ||
end | ||
end # "context 'with list of requested attributes' do" | ||
|
||
context 'with a UUID, renamed primary key column' do | ||
it 'compiles instance attribute values into a SCIM representation, but omits do-not-return fields' do | ||
uuid = SecureRandom.uuid | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters