main
 1# frozen_string_literal: true
 2
 3require 'rails_helper'
 4
 5describe "/ServiceProviderConfig" do
 6  let(:user) { create(:user) }
 7  let(:token) { create(:access_token, subject: user).to_jwt }
 8  let(:headers) do
 9    {
10      'Authorization' => "Bearer #{token}",
11      'Accept' => 'application/scim+json',
12      'Content-Type' => 'application/scim+json',
13    }
14  end
15
16  context "when loading the service provider configuration" do
17    let(:json) { JSON.parse(response.body, symbolize_names: true) }
18
19    before { get '/scim/v2/ServiceProviderConfig', headers: headers }
20
21    specify { expect(response).to have_http_status(:ok) }
22    specify { expect(response.body).to be_present }
23    specify { expect(json[:schemas]).to match_array([Scim::Kit::V2::Schemas::SERVICE_PROVIDER_CONFIGURATION]) }
24    specify { expect(json[:documentationUri]).to eql(root_url + "doc") }
25    specify { expect(json[:patch][:supported]).to be(false) }
26    specify { expect(json[:bulk][:supported]).to be(false) }
27    specify { expect(json[:filter][:supported]).to be(false) }
28    specify { expect(json[:changePassword][:supported]).to be(false) }
29    specify { expect(json[:sort][:supported]).to be(false) }
30    specify { expect(json[:etag][:supported]).to be(false) }
31    specify { expect(json[:authenticationSchemes][0][:name]).to eql('OAuth Bearer Token') }
32    specify { expect(json[:authenticationSchemes][0][:description]).to eql('Authentication scheme using the OAuth Bearer Token Standard') }
33    specify { expect(json[:authenticationSchemes][0][:specUri]).to eql('http://www.rfc-editor.org/info/rfc6750') }
34    specify { expect(json[:authenticationSchemes][0][:documentationUri]).to eql('http://example.com/help/oauth.html') }
35    specify { expect(json[:authenticationSchemes][0][:type]).to eql('oauthbearertoken') }
36    specify { expect(json[:authenticationSchemes][0][:primary]).to be(true) }
37    specify { expect(json[:meta][:location]).to eql(scim_v2_ServiceProviderConfig_url) }
38    specify { expect(json[:meta][:resourceType]).to eql('ServiceProviderConfig') }
39    specify { expect(json[:meta][:created]).to be_present }
40    specify { expect(json[:meta][:lastModified]).to be_present }
41    specify { expect(json[:meta][:version]).to be_present }
42  end
43end