diff --git a/db/fixtures/development/18_abuse_reports.rb b/db/fixtures/development/18_abuse_reports.rb index 88d2f784852f1e878ce5af837ecf5fa0f71c47de..7dd930691220e2cef0781a12e8cfafa4fcc1741b 100644 --- a/db/fixtures/development/18_abuse_reports.rb +++ b/db/fixtures/development/18_abuse_reports.rb @@ -11,7 +11,7 @@ def self.seed name: FFaker::Name.name, email: FFaker::Internet.email, confirmed_at: DateTime.now, - password: '12345678' + password: ::User.random_password ) ::AbuseReport.create(reporter: ::User.take, user: reported_user, message: 'User sends spam') diff --git a/spec/channels/application_cable/connection_spec.rb b/spec/channels/application_cable/connection_spec.rb index f5b2cdd2fca13084c3caa19a4b713432b7cd7b6b..4943669bde034c17758c930b995addb10338cba1 100644 --- a/spec/channels/application_cable/connection_spec.rb +++ b/spec/channels/application_cable/connection_spec.rb @@ -21,7 +21,7 @@ end context 'with a stale password' do - let(:partial_password_hash) { build(:user, password: 'some_old_password').authenticatable_salt } + let(:partial_password_hash) { build(:user, password: User.random_password).authenticatable_salt } let(:session_hash) { { 'warden.user.user.key' => [[user.id], partial_password_hash] } } it 'sets current_user to nil' do diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb index 09ed27eb90fe9e85d08cd37b155506f209139815..fce552569223d42bd4628de052bc44c22129dc9c 100644 --- a/spec/mailers/emails/profile_spec.rb +++ b/spec/mailers/emails/profile_spec.rb @@ -49,7 +49,7 @@ describe 'for users that signed up, the email' do let(:example_site_path) { root_path } - let(:new_user) { create(:user, email: new_user_address, password: "securePassword") } + let(:new_user) { create(:user, email: new_user_address) } subject { Notify.new_user_email(new_user.id) } @@ -59,6 +59,7 @@ it_behaves_like 'a user cannot unsubscribe through footer link' it 'does not contain the new user\'s password' do + is_expected.not_to have_body_text(new_user.password) is_expected.not_to have_body_text /password/ end end diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb index 9f5f81dd6c0d70579c07831ce87d12949df49b3e..f4786083b75d00bf7104a29a3a23a920065e2b12 100644 --- a/spec/models/hooks/system_hook_spec.rb +++ b/spec/models/hooks/system_hook_spec.rb @@ -37,7 +37,7 @@ let(:project) { create(:project, namespace: user.namespace) } let(:group) { create(:group) } let(:params) do - { name: 'John Doe', username: 'jduser', email: 'jg@example.com', password: 'mydummypass' } + { name: 'John Doe', username: 'jduser', email: 'jg@example.com', password: User.random_password } end before do diff --git a/spec/tasks/gitlab/password_rake_spec.rb b/spec/tasks/gitlab/password_rake_spec.rb index 65bba836024dcf92c6989a387fc8e990c1f72c2d..5d5e5af25369b8ff1ea4b98c312decceea515434 100644 --- a/spec/tasks/gitlab/password_rake_spec.rb +++ b/spec/tasks/gitlab/password_rake_spec.rb @@ -3,7 +3,8 @@ require 'rake_helper' RSpec.describe 'gitlab:password rake tasks', :silence_stdout do - let_it_be(:user_1) { create(:user, username: 'foobar', password: 'initial_password') } + let_it_be(:user_1) { create(:user, username: 'foobar', password: User.random_password) } + let_it_be(:password) { User.random_password } def stub_username(username) allow(Gitlab::TaskHelpers).to receive(:prompt).with('Enter username: ').and_return(username) @@ -19,14 +20,14 @@ def stub_password(password, confirmation = nil) Rake.application.rake_require 'tasks/gitlab/password' stub_username('foobar') - stub_password('secretpassword') + stub_password(password) end describe ':reset' do context 'when all inputs are correct' do it 'updates the password properly' do run_rake_task('gitlab:password:reset', user_1.username) - expect(user_1.reload.valid_password?('secretpassword')).to eq(true) + expect(user_1.reload.valid_password?(password)).to eq(true) end end @@ -55,7 +56,7 @@ def stub_password(password, confirmation = nil) context 'when passwords do not match' do before do - stub_password('randompassword', 'differentpassword') + stub_password(password, User.random_password) end it 'aborts with an error' do