Commit 589d96a3 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'dblessing-scim-api-context' into 'master'

Fix SCIM API Application Context

Closes #199587

See merge request gitlab-org/gitlab!26514
parents 2dc80baf e530327a
---
title: Fix SCIM API not creating new users
merge_request: 26514
author:
type: fixed
......@@ -51,14 +51,16 @@ module API
unauthorized! unless token && ScimOauthAccessToken.token_matches_for_group?(token, group)
end
# Instance variable `@group` is necessary for the
# Gitlab::ApplicationContext in API::API
def find_and_authenticate_group!(group_path)
group = find_group(group_path)
@group = find_group(group_path)
scim_not_found!(message: "Group #{group_path} not found") unless group
scim_not_found!(message: "Group #{group_path} not found") unless @group
check_access_to_group!(group)
check_access_to_group!(@group)
group
@group
end
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -136,6 +136,12 @@ describe API::Scim do
end
end
it_behaves_like 'storing arguments in the application context' do
let(:expected_params) { { root_namespace: group.full_path_components.first } }
subject { post scim_api("scim/v2/groups/#{group.full_path}/Users?params=#{post_params}") }
end
context 'with allowed domain setting switched on' do
let(:new_user) { User.find_by_email('work@example.com') }
let(:member) { GroupMember.find_by(user: new_user, group: group) }
......
......@@ -45,7 +45,7 @@ module API
before do
Gitlab::ApplicationContext.push(
user: -> { current_user },
user: -> { @current_user },
project: -> { @project },
namespace: -> { @group },
caller_id: route.origin
......
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