2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-14 19:28:17 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe Profiles::AccountsController do
|
2017-03-28 06:33:51 -04:00
|
|
|
describe 'DELETE unlink' do
|
|
|
|
let(:user) { create(:omniauth_user) }
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2017-03-28 06:33:51 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2017-03-28 06:33:51 -04:00
|
|
|
it 'renders 404 if someone tries to unlink a non existent provider' do
|
2018-12-17 17:52:17 -05:00
|
|
|
delete :unlink, params: { provider: 'github' }
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2020-02-06 13:08:54 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2017-03-28 06:33:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
[:saml, :cas3].each do |provider|
|
|
|
|
describe "#{provider} provider" do
|
|
|
|
let(:user) { create(:omniauth_user, provider: provider.to_s) }
|
|
|
|
|
|
|
|
it "does not allow to unlink connected account" do
|
|
|
|
identity = user.identities.last
|
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
delete :unlink, params: { provider: provider.to_s }
|
2017-03-28 06:33:51 -04:00
|
|
|
|
2020-02-06 13:08:54 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2017-03-28 06:33:51 -04:00
|
|
|
expect(user.reload.identities).to include(identity)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-17 08:16:49 -04:00
|
|
|
[:twitter, :facebook, :google_oauth2, :gitlab, :github, :bitbucket, :crowd, :auth0, :authentiq].each do |provider|
|
2017-03-28 06:33:51 -04:00
|
|
|
describe "#{provider} provider" do
|
|
|
|
let(:user) { create(:omniauth_user, provider: provider.to_s) }
|
|
|
|
|
|
|
|
it 'allows to unlink connected account' do
|
|
|
|
identity = user.identities.last
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
delete :unlink, params: { provider: provider.to_s }
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2020-02-06 13:08:54 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2017-03-28 06:33:51 -04:00
|
|
|
expect(user.reload.identities).not_to include(identity)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-09-10 14:08:54 -04:00
|
|
|
|
|
|
|
describe 'atlassian_oauth2 provider' do
|
|
|
|
let(:user) { create(:atlassian_user) }
|
|
|
|
|
|
|
|
it 'allows a user to unlink a connected account' do
|
|
|
|
expect(user.atlassian_identity).not_to be_nil
|
|
|
|
|
|
|
|
delete :unlink, params: { provider: 'atlassian_oauth2' }
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
|
|
|
expect(user.reload.atlassian_identity).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2016-06-14 19:28:17 -04:00
|
|
|
end
|
2016-06-14 19:37:22 -04:00
|
|
|
end
|