Commit 26b35c3
Changed files (3)
app/controllers/scim/v2/users_controller.rb
@@ -1,6 +1,15 @@
module Scim
module V2
class UsersController < ::Scim::Controller
+ def index
+ response.headers['Content-Type'] = 'application/scim+json'
+ render json: {
+ schemas: [Scim::Shady::Messages::LIST],
+ totalResults: 0,
+ Resources: [],
+ }.to_json, status: :ok
+ end
+
def show
user = User.find_by(uuid: params[:id])
response.headers['Content-Type'] = 'application/scim+json'
config/routes.rb
@@ -9,7 +9,7 @@ Rails.application.routes.draw do
namespace :scim do
namespace :v2, defaults: { format: 'json' } do
- resources :users, only: [:show, :create, :update, :destroy]
+ resources :users, only: [:index, :show, :create, :update, :destroy]
get :ServiceProviderConfig, to: "service_providers#index"
#resources :groups
resources :resource_types, only: [:index]
spec/requests/scim/v2/users_spec.rb
@@ -35,7 +35,7 @@ describe '/scim/v2/users' do
end
end
- describe "GET /scim/v2/users" do
+ describe "GET /scim/v2/users/:id" do
let(:user) { create(:user) }
it 'returns the requested resource' do
@@ -57,4 +57,19 @@ describe '/scim/v2/users' do
expect(json[:meta][:location]).to eql(scim_v2_users_url(user))
end
end
+
+ describe "GET /scim/v2/users" do
+ it 'returns an empty set of results' do
+ get "/scim/v2/users?attributes=userName"
+
+ expect(response).to have_http_status(:ok)
+ expect(response.headers['Content-Type']).to eql('application/scim+json')
+ expect(response.body).to be_present
+
+ json = JSON.parse(response.body, symbolize_names: true)
+ expect(json[:schemas]).to match_array([Scim::Shady::Messages::LIST])
+ expect(json[:totalResults]).to be_zero
+ expect(json[:Resources]).to be_empty
+ end
+ end
end