diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-15 23:17:12 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-15 23:23:43 +0300 |
commit | 5f45ddc54577fb65db00636a05408b00636544f5 (patch) | |
tree | 3722ec5dc3e27d211303356430c93c24390dbfde /spec/requests | |
parent | 83b643a0145cf3f5b919cc61342ba0a824dfdcc9 (diff) |
Fix specs after merging LFS changes
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/jwt_controller_spec.rb | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/spec/requests/jwt_controller_spec.rb b/spec/requests/jwt_controller_spec.rb index 93b9cfaf33d..1ca4541dbde 100644 --- a/spec/requests/jwt_controller_spec.rb +++ b/spec/requests/jwt_controller_spec.rb @@ -45,13 +45,31 @@ describe JwtController do context 'using User login' do let(:user) { create(:user) } - let(:headers) { { authorization: credentials('user', 'password') } } - - before { expect(Gitlab::Auth).to receive(:find_with_user_password).with('user', 'password').and_return(user) } + let(:headers) { { authorization: credentials(user.username , user.password) } } subject! { get '/jwt/auth', parameters, headers } it { expect(service_class).to have_received(:new).with(nil, user, parameters) } + + context 'when user has 2FA enabled' do + let(:user) { create(:user, :two_factor) } + + context 'without personal token' do + it 'rejects the authorization attempt' do + expect(response).to have_http_status(401) + expect(response.body).to include('You have 2FA enabled, please use a personal access token for Git over HTTP') + end + end + + context 'with personal token' do + let(:access_token) { create(:personal_access_token, user: user) } + let(:headers) { { authorization: credentials(user.username, access_token.token) } } + + it 'rejects the authorization attempt' do + expect(response).to have_http_status(200) + end + end + end end context 'using invalid login' do |