Commit 92dc05c4 authored by James Lopez's avatar James Lopez

Add users entity

parent 1cec65d0
# frozen_string_literal: true
module EE
module Gitlab
module Scim
class Users < Grape::Entity
expose :schemas
expose :total_results, as: :totalResults
expose :items_per_page, as: :itemsPerPage
expose :start_index, as: :startIndex
present_collection true, :Resources
expose :resources, as: :Resources, using: ::EE::Gitlab::Scim::User
private
DEFAULT_SCHEMA = 'urn:ietf:params:scim:api:messages:2.0:ListResponse'
ITEMS_PER_PAGE = 20
START_INDEX = 1
def schemas
[DEFAULT_SCHEMA]
end
def total_results
1
end
def items_per_page
ITEMS_PER_PAGE
end
def start_index
START_INDEX
end
# We only support a single resource at the moment
# Please update `total_results` to `resources.count` once this changes
def resources
[object]
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe ::EE::Gitlab::Scim::Users do
let(:user) { build(:user) }
let(:identity) { build(:group_saml_identity, user: user) }
let(:entity) do
described_class.new(identity)
end
subject { entity.as_json }
it 'contains the schemas' do
expect(subject[:schemas]).to eq(['urn:ietf:params:scim:api:messages:2.0:ListResponse'])
end
it 'contains the totalResults' do
expect(subject[:totalResults]).to eq(1)
end
it 'contains the itemsPerPage' do
expect(subject[:itemsPerPage]).to eq(20)
end
it 'contains the startIndex' do
expect(subject[:startIndex]).to eq(1)
end
it 'contains the user' do
expect(subject[:Resources]).not_to be_empty
end
it 'contains the user ID' do
expect(subject[:Resources].first[:id]).to eq(identity.extern_uid)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment