-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ GIT | |
PATH | ||
remote: . | ||
specs: | ||
scimitar (2.1.2) | ||
scimitar (2.1.3) | ||
rails (~> 7.0) | ||
|
||
GEM | ||
|
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
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
5 changes: 5 additions & 0 deletions
5
spec/apps/dummy/db/migrate/20230109012729_add_timestamps_to_mock_user.rb
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddTimestampsToMockUser < ActiveRecord::Migration[7.0] | ||
def change | ||
add_timestamps :mock_users | ||
end | ||
end |
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
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
require 'spec_helper' | ||
require 'time' | ||
|
||
RSpec.describe Scimitar::ActiveRecordBackedResourcesController do | ||
before :each do | ||
allow_any_instance_of(Scimitar::ApplicationController).to receive(:authenticated?).and_return(true) | ||
|
||
@u1 = MockUser.create(username: '1', first_name: 'Foo', last_name: 'Ark', home_email_address: '[email protected]') | ||
@u2 = MockUser.create(username: '2', first_name: 'Foo', last_name: 'Bar', home_email_address: '[email protected]') | ||
@u3 = MockUser.create(username: '3', first_name: 'Foo', home_email_address: '[email protected]') | ||
lmt = Time.parse("2023-01-09 14:25:00 +1300") | ||
|
||
@u1 = MockUser.create(username: '1', first_name: 'Foo', last_name: 'Ark', home_email_address: '[email protected]', scim_uid: '001', created_at: lmt, updated_at: lmt + 1) | ||
@u2 = MockUser.create(username: '2', first_name: 'Foo', last_name: 'Bar', home_email_address: '[email protected]', scim_uid: '002', created_at: lmt, updated_at: lmt + 2) | ||
@u3 = MockUser.create(username: '3', first_name: 'Foo', home_email_address: '[email protected]', scim_uid: '003', created_at: lmt, updated_at: lmt + 3) | ||
end | ||
|
||
# =========================================================================== | ||
|
@@ -48,7 +51,7 @@ | |
it 'applies a filter, with case-insensitive value comparison' do | ||
get '/Users', params: { | ||
format: :scim, | ||
filter: 'name.givenName eq "Foo" and name.familyName pr and emails ne "home_1@TEST.COM"' | ||
filter: 'name.givenName eq "FOO" and name.familyName pr and emails ne "home_1@test.com"' | ||
} | ||
|
||
expect(response.status).to eql(200) | ||
|
@@ -83,6 +86,68 @@ | |
expect(usernames).to match_array(['2']) | ||
end | ||
|
||
# Strange attribute capitalisation in tests here builds on test coverage | ||
# for now-fixed GitHub issue #37. | ||
# | ||
context '"meta" / IDs (GitHub issue #36)' do | ||
it 'applies a filter on primary keys, using direct comparison (rather than e.g. case-insensitive operators)' do | ||
get '/Users', params: { | ||
format: :scim, | ||
filter: "id eq \"#{@u3.id}\"" | ||
} | ||
|
||
expect(response.status).to eql(200) | ||
result = JSON.parse(response.body) | ||
|
||
expect(result['totalResults']).to eql(1) | ||
expect(result['Resources'].size).to eql(1) | ||
|
||
ids = result['Resources'].map { |resource| resource['id'] } | ||
expect(ids).to match_array([@u3.id.to_s]) | ||
|
||
usernames = result['Resources'].map { |resource| resource['userName'] } | ||
expect(usernames).to match_array(['3']) | ||
end | ||
|
||
it 'applies a filter on external IDs, using direct comparison' do | ||
get '/Users', params: { | ||
format: :scim, | ||
filter: "externalID eq \"#{@u2.scim_uid}\"" | ||
} | ||
|
||
expect(response.status).to eql(200) | ||
result = JSON.parse(response.body) | ||
|
||
expect(result['totalResults']).to eql(1) | ||
expect(result['Resources'].size).to eql(1) | ||
|
||
ids = result['Resources'].map { |resource| resource['id'] } | ||
expect(ids).to match_array([@u2.id.to_s]) | ||
|
||
usernames = result['Resources'].map { |resource| resource['userName'] } | ||
expect(usernames).to match_array(['2']) | ||
end | ||
|
||
it 'applies a filter on "meta" entries, using direct comparison' do | ||
get '/Users', params: { | ||
format: :scim, | ||
filter: "Meta.LastModified eq \"#{@u3.updated_at}\"" | ||
} | ||
|
||
expect(response.status).to eql(200) | ||
result = JSON.parse(response.body) | ||
|
||
expect(result['totalResults']).to eql(1) | ||
expect(result['Resources'].size).to eql(1) | ||
|
||
ids = result['Resources'].map { |resource| resource['id'] } | ||
expect(ids).to match_array([@u3.id.to_s]) | ||
|
||
usernames = result['Resources'].map { |resource| resource['userName'] } | ||
expect(usernames).to match_array(['3']) | ||
end | ||
end # "context '"meta" / IDs (GitHub issue #36)' do" | ||
|
||
it 'obeys a page size' do | ||
get '/Users', params: { | ||
format: :scim, | ||
|