summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPeter Lauck <griest024@gmail.com>2018-02-13 02:21:42 -0500
committerPeter Lauck <griest024@gmail.com>2018-02-13 02:21:51 -0500
commiteddf4c0f6cb6125a30cbc2528a468d2c3d5a48e0 (patch)
tree77d00e2c503730aa398d888b6edd5ad30ed0d8d3 /spec
parent201f53e96d26d4babfc6a4492576f873219d4e6f (diff)
downloadgitlab-ce-eddf4c0f6cb6125a30cbc2528a468d2c3d5a48e0.tar.gz
Strip whitespace from username/login value for user lookup
As per the discussion with @psimyn, this change does not affect the frontend, so user input will not be validated on the signin screen. Instead, the value sent to the backend has leading and trailing whitespace stripped before looking up the user with find_by. Closes #42637
Diffstat (limited to 'spec')
-rw-r--r--spec/models/user_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 76a6aef39cc..1815696a8a0 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -893,6 +893,14 @@ describe User do
end
end
+ describe '.find_for_database_authentication' do
+ it 'strips whitespace from login' do
+ user = create(:user)
+
+ expect(described_class.find_for_database_authentication({ login: " #{user.username} " })).to eq user
+ end
+ end
+
describe '.find_by_any_email' do
it 'finds by primary email' do
user = create(:user, email: 'foo@example.com')