diff options
author | Robert Speicher <robert@gitlab.com> | 2016-06-17 22:27:51 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-06-17 22:27:51 +0300 |
commit | d9d149244a050f32dd00a9a1898eb5c309eb50eb (patch) | |
tree | 5dee734af88c7884dd89fccb3759c26a0d1ae5a0 /spec/controllers | |
parent | 1db4fd3ae7cd3a4fa2f356a4c252820e26783a27 (diff) | |
parent | 2786edc931f1853883e5bbd9d2b83a824288ae5c (diff) |
Merge branch 'disable-saml-account-unlink' into 'master'
Disable the unlink feature for SAML connected accounts (social login).
This disables the ability to manually unlink your SAML account, if you have one connected. In certain scenarios, the only allowed login mechanism can be SAML, and if you unlink your account you will be locked out of the system (configuration dependent).
Fixes #18613
See merge request !4662
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/profiles/accounts_controller_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/controllers/profiles/accounts_controller_spec.rb b/spec/controllers/profiles/accounts_controller_spec.rb new file mode 100644 index 00000000000..4eafc11abaa --- /dev/null +++ b/spec/controllers/profiles/accounts_controller_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Profiles::AccountsController do + + let(:user) { create(:omniauth_user, provider: 'saml') } + + before do + sign_in(user) + end + + it 'does not allow to unlink SAML connected account' do + identity = user.identities.last + delete :unlink, provider: 'saml' + updated_user = User.find(user.id) + + expect(response.status).to eq(302) + expect(updated_user.identities.size).to eq(1) + expect(updated_user.identities).to include(identity) + end + + it 'does allow to delete other linked accounts' do + user.identities.create(provider: 'twitter', extern_uid: 'twitter_123') + + expect { delete :unlink, provider: 'twitter' }.to change(Identity.all, :size).by(-1) + end +end |