Skip to content
代码片段 群组 项目
未验证 提交 8c420c1b 编辑于 作者: Heinrich Lee Yu's avatar Heinrich Lee Yu
浏览文件

Merge branch 'smriti-417282/scim_provisioning_service_email_skip_confirmation' into 'master'

Email confirmation setting to be considered

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/130447



Merged-by: default avatarHeinrich Lee Yu <heinrich@gitlab.com>
Approved-by: default avatarHeinrich Lee Yu <heinrich@gitlab.com>
Reviewed-by: default avatarDrew Blessing <drew@gitlab.com>
Co-authored-by: default avatarsmriti <sgarg@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -41,6 +41,14 @@ def valid_username ...@@ -41,6 +41,14 @@ def valid_username
def missing_params def missing_params
@missing_params ||= ([:extern_uid, :email, :username] - @parsed_hash.keys) @missing_params ||= ([:extern_uid, :email, :username] - @parsed_hash.keys)
end end
def user_params
@parsed_hash.tap do |hash|
hash[:username] = valid_username
hash[:password] = hash[:password_confirmation] = random_password
hash[:password_automatically_set] = PASSWORD_AUTOMATICALLY_SET
end
end
end end
end end
end end
......
...@@ -40,7 +40,7 @@ def user ...@@ -40,7 +40,7 @@ def user
strong_memoize_attr :user strong_memoize_attr :user
def build_user def build_user
::Users::AuthorizedBuildService.new(nil, user_params).execute ::Users::AuthorizedBuildService.new(nil, group_user_params).execute
end end
def build_scim_identity def build_scim_identity
...@@ -63,15 +63,11 @@ def default_membership_role ...@@ -63,15 +63,11 @@ def default_membership_role
@group.saml_provider.default_membership_role @group.saml_provider.default_membership_role
end end
def user_params def group_user_params
@parsed_hash.tap do |hash| user_params.tap do |hash|
hash[:skip_confirmation] = SKIP_EMAIL_CONFIRMATION
hash[:saml_provider_id] = @group.saml_provider.id hash[:saml_provider_id] = @group.saml_provider.id
hash[:group_id] = @group&.id hash[:group_id] = @group&.id
hash[:provider] = ::Users::BuildService::GROUP_SCIM_PROVIDER hash[:provider] = ::Users::BuildService::GROUP_SCIM_PROVIDER
hash[:username] = valid_username
hash[:password] = hash[:password_confirmation] = random_password
hash[:password_automatically_set] = PASSWORD_AUTOMATICALLY_SET
end end
end end
......
...@@ -44,15 +44,6 @@ def build_scim_identity ...@@ -44,15 +44,6 @@ def build_scim_identity
) )
end end
def user_params
@parsed_hash.tap do |hash|
hash[:skip_confirmation] = SKIP_EMAIL_CONFIRMATION
hash[:username] = valid_username
hash[:password] = hash[:password_confirmation] = random_password
hash[:password_automatically_set] = PASSWORD_AUTOMATICALLY_SET
end
end
def existing_identity? def existing_identity?
identity&.persisted? identity&.persisted?
end end
......
...@@ -54,6 +54,12 @@ ...@@ -54,6 +54,12 @@
end end
context 'when valid params' do context 'when valid params' do
before do
# By default SAAS version setting is hard as per docs
# https://docs.gitlab.com/ee/user/gitlab_com/#email-confirmation
stub_application_setting_enum('email_confirmation_setting', 'hard')
end
def user def user
User.find_by(email: service_params[:email]) User.find_by(email: service_params[:email])
end end
......
...@@ -60,11 +60,27 @@ def user ...@@ -60,11 +60,27 @@ def user
expect(user).to be_a(User) expect(user).to be_a(User)
end end
it 'user record requires confirmation' do context 'when email confirmation setting is set' do
service.execute using RSpec::Parameterized::TableSyntax
where(:email_confirmation_setting, :confirmed) do
'soft' | false
'hard' | false
'off' | true
end
expect(user).to be_present with_them do
expect(user).not_to be_confirmed before do
stub_application_setting_enum('email_confirmation_setting', email_confirmation_setting)
end
it "sets user confirmation according to setting" do
service.execute
expect(user).to be_present
expect(user.reload.confirmed?).to be(confirmed)
end
end
end end
context 'when the current minimum password length is different from the default minimum password length' do context 'when the current minimum password length is different from the default minimum password length' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册