diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 15:09:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 15:09:03 +0300 |
commit | 5366964a10484c2783a646b35a6da9eece01b242 (patch) | |
tree | 4a5a7a289d44e63d96a50a6a64db6e16b871f19c /spec/requests | |
parent | 733befe96ad19f5a02e442c4a9cc8059d3aabbda (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/users_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index d14baa49341..12ac601c013 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -949,6 +949,45 @@ describe API::Users do end end + describe "DELETE /users/:id/identities/:provider" do + let(:test_user) { create(:omniauth_user, provider: 'ldapmain') } + + context 'when unauthenticated' do + it 'returns authentication error' do + delete api("/users/#{test_user.id}/identities/ldapmain") + + expect(response).to have_gitlab_http_status(:unauthorized) + end + end + + context 'when authenticated' do + it 'deletes identity of given provider' do + expect do + delete api("/users/#{test_user.id}/identities/ldapmain", admin) + end.to change { test_user.identities.count }.by(-1) + expect(response).to have_gitlab_http_status(:no_content) + end + + it_behaves_like '412 response' do + let(:request) { api("/users/#{test_user.id}/identities/ldapmain", admin) } + end + + it 'returns 404 error if user not found' do + delete api("/users/0/identities/ldapmain", admin) + + expect(response).to have_gitlab_http_status(:not_found) + expect(json_response['message']).to eq('404 User Not Found') + end + + it 'returns 404 error if identity not found' do + delete api("/users/#{test_user.id}/identities/saml", admin) + + expect(response).to have_gitlab_http_status(:not_found) + expect(json_response['message']).to eq('404 Identity Not Found') + end + end + end + describe "POST /users/:id/keys" do before do admin |