summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-05-30 22:17:26 -0400
committerRobert Speicher <rspeicher@gmail.com>2016-05-30 22:25:35 -0400
commita602df303175aaaf1d5b60a2c009f5e259d187db (patch)
tree68eb6241dfbd4ccc8ae8474b73ead87018e92386 /spec/controllers
parentde20bd5b31715f096db3fb0155c82b0eea992b6c (diff)
downloadgitlab-ce-a602df303175aaaf1d5b60a2c009f5e259d187db.tar.gz
Pass the "Remember me" value to the 2FA token formrs-remember-me-2fa
Prior, if a user had 2FA enabled and checked the "Remember me" field, the setting was ignored because the OTP input was on a new form and the value was never passed. Closes #18000
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/sessions_controller_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index ab57c52c7cd..b39d8c8cd5b 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -35,6 +35,27 @@ describe SessionsController do
post(:create, { user: user_params }, { otp_user_id: user.id })
end
+ context 'remember_me field' do
+ it 'sets a remember_user_token cookie when enabled' do
+ allow(controller).to receive(:find_user).and_return(user)
+ expect(controller).
+ to receive(:remember_me).with(user).and_call_original
+
+ authenticate_2fa(remember_me: '1', otp_attempt: user.current_otp)
+
+ expect(response.cookies['remember_user_token']).to be_present
+ end
+
+ it 'does nothing when disabled' do
+ allow(controller).to receive(:find_user).and_return(user)
+ expect(controller).not_to receive(:remember_me)
+
+ authenticate_2fa(remember_me: '0', otp_attempt: user.current_otp)
+
+ expect(response.cookies['remember_user_token']).to be_nil
+ end
+ end
+
##
# See #14900 issue
#