diff options
author | DJ Mountney <david@twkie.net> | 2016-08-19 18:51:56 -0700 |
---|---|---|
committer | DJ Mountney <david@twkie.net> | 2016-09-01 17:11:42 -0700 |
commit | 9224f031cfcb8283566f9d1dcc336ae644faf062 (patch) | |
tree | 4c2012f873b24bd30b6fdea0807cae6d3fe43f4e /spec/controllers | |
parent | 33a367e828c95ba7321d33361be67c68b1603bdd (diff) | |
download | gitlab-ce-9224f031cfcb8283566f9d1dcc336ae644faf062.tar.gz |
Pass the remember_me option into the u2f form and support it while authenticatingadd-remember-option-u2f
Matches the changes done for non-u2f two-factor auth
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/sessions_controller_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 4e9bfb0c69b..8f27e616c3e 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -136,6 +136,29 @@ 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(U2fRegistration).to receive(:authenticate).and_return(true) + allow(controller).to receive(:find_user).and_return(user) + expect(controller). + to receive(:remember_me).with(user).and_call_original + + authenticate_2fa_u2f(remember_me: '1', login: user.username, device_response: "{}") + + expect(response.cookies['remember_user_token']).to be_present + end + + it 'does nothing when disabled' do + allow(U2fRegistration).to receive(:authenticate).and_return(true) + allow(controller).to receive(:find_user).and_return(user) + expect(controller).not_to receive(:remember_me) + + authenticate_2fa_u2f(remember_me: '0', login: user.username, device_response: "{}") + + expect(response.cookies['remember_user_token']).to be_nil + end + end + it "creates an audit log record" do allow(U2fRegistration).to receive(:authenticate).and_return(true) expect { authenticate_2fa_u2f(login: user.username, device_response: "{}") }.to change { SecurityEvent.count }.by(1) |