Skip to content

Commit

Permalink
Merge pull request #2974 from bgeuken/update_user_pw_stuff
Browse files Browse the repository at this point in the history
Update user fake pw creation
  • Loading branch information
ChrisBr committed Apr 13, 2017
2 parents 04848f8 + 7967fe4 commit 1b2ab67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/api/app/models/user.rb
Expand Up @@ -179,11 +179,7 @@ def self.update_notifications(params, user = nil)
end

def self.create_user_with_fake_pw!(attributes = {})
chars = ["A".."Z", "a".."z", "0".."9"].collect(&:to_a).join
fakepw = (1..24).collect { chars[rand(chars.size)] }.pack("a" * 24)

attributes[:password] = fakepw
create!(attributes)
create!(attributes.merge(password: SecureRandom.base64(48)))
end

# This static method tries to find a user with the given login and password
Expand Down
4 changes: 4 additions & 0 deletions src/api/spec/models/user_spec.rb
Expand Up @@ -273,6 +273,10 @@
let(:user) { User.create_user_with_fake_pw!({ login: 'tux', email: 'some@email.com' }) }

it 'creates a user with a fake password' do
expect(user.password).not_to eq(User.create_user_with_fake_pw!({ login: 'tux2', email: 'some@email.com' }).password)
end

it 'creates a user from given attributes' do
expect(user).to be_an(User)
expect(user.login).to eq('tux')
expect(user.email).to eq('some@email.com')
Expand Down

0 comments on commit 1b2ab67

Please sign in to comment.