summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJ Mountney <david@twkie.net>2017-03-31 13:06:15 -0700
committerDJ Mountney <david@twkie.net>2017-04-04 10:18:56 -0700
commita766f60a0be65a5f8af3f4328c1bcdc505948d15 (patch)
tree59cac43333d9c8ce84380b01502b8824202e98d3
parent93de37ce1bd0f5ce015287f0729d625ddf6f7390 (diff)
downloadgitlab-ce-fix-password-required-check.tar.gz
Inlude the password_automatically_check param as permitted config in the user create_servicefix-password-required-check
This param is passed to service in two places, one is in the build_user for non ldap oauth users. And the other is in the initial production admin user seed data. Without this change, when setting up GitLab in a production environment, you were not being given the option of setting the root password on initial setup in the UI.
-rw-r--r--app/services/users/create_service.rb2
-rw-r--r--spec/lib/gitlab/o_auth/user_spec.rb9
-rw-r--r--spec/services/users/create_service_spec.rb26
3 files changed, 37 insertions, 0 deletions
diff --git a/app/services/users/create_service.rb b/app/services/users/create_service.rb
index 193fcd85896..a847a71a66a 100644
--- a/app/services/users/create_service.rb
+++ b/app/services/users/create_service.rb
@@ -62,6 +62,7 @@ module Users
:email,
:external,
:force_random_password,
+ :password_automatically_set,
:hide_no_password,
:hide_no_ssh_key,
:key_id,
@@ -85,6 +86,7 @@ module Users
[
:email,
:email_confirmation,
+ :password_automatically_set,
:name,
:password,
:username
diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb
index 6c84a4c8b73..8f09266c3b3 100644
--- a/spec/lib/gitlab/o_auth/user_spec.rb
+++ b/spec/lib/gitlab/o_auth/user_spec.rb
@@ -40,6 +40,15 @@ describe Gitlab::OAuth::User, lib: true do
let(:provider) { 'twitter' }
describe 'signup' do
+ it 'marks user as having password_automatically_set' do
+ stub_omniauth_config(allow_single_sign_on: ['twitter'], external_providers: ['twitter'])
+
+ oauth_user.save
+
+ expect(gl_user).to be_persisted
+ expect(gl_user).to be_password_automatically_set
+ end
+
shared_examples 'to verify compliance with allow_single_sign_on' do
context 'provider is marked as external' do
it 'marks user as external' do
diff --git a/spec/services/users/create_service_spec.rb b/spec/services/users/create_service_spec.rb
index 66f68650f81..a111aec2f89 100644
--- a/spec/services/users/create_service_spec.rb
+++ b/spec/services/users/create_service_spec.rb
@@ -122,6 +122,32 @@ describe Users::CreateService, services: true do
end
end
+ context 'when password_automatically_set parameter is true' do
+ let(:params) do
+ {
+ name: 'John Doe',
+ username: 'jduser',
+ email: 'jd@example.com',
+ password: 'mydummypass',
+ password_automatically_set: true
+ }
+ end
+
+ it 'persists the given attributes' do
+ user = service.execute
+ user.reload
+
+ expect(user).to have_attributes(
+ name: params[:name],
+ username: params[:username],
+ email: params[:email],
+ password: params[:password],
+ created_by_id: admin_user.id,
+ password_automatically_set: params[:password_automatically_set]
+ )
+ end
+ end
+
context 'when skip_confirmation parameter is true' do
let(:params) do
{ name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass', skip_confirmation: true }