Commit 4f92594a authored by Małgorzata Ksionek's avatar Małgorzata Ksionek Committed by Douglas Barbosa Alexandre

Provide different method for checking feature flag

parent b7a620b3
...@@ -328,11 +328,11 @@ module EE ...@@ -328,11 +328,11 @@ module EE
end end
def user_authorized_by_provisioning_group? def user_authorized_by_provisioning_group?
::Feature.enabled?(:block_password_auth_for_saml_users, type: :ops) && user_detail.provisioned_by_group? user_detail.provisioned_by_group? && ::Feature.enabled?(:block_password_auth_for_saml_users, user_detail.provisioned_by_group, type: :ops)
end end
def authorized_by_provisioning_group?(group) def authorized_by_provisioning_group?(group)
::Feature.enabled?(:block_password_auth_for_saml_users, type: :ops) && provisioned_by_group == group user_authorized_by_provisioning_group? && provisioned_by_group == group
end end
def gitlab_employee? def gitlab_employee?
......
...@@ -816,8 +816,10 @@ RSpec.describe User do ...@@ -816,8 +816,10 @@ RSpec.describe User do
describe '#user_authorized_by_provisioning_group?' do describe '#user_authorized_by_provisioning_group?' do
context 'when user is provisioned by group' do context 'when user is provisioned by group' do
let(:group) { build(:group) }
before do before do
user.user_detail.provisioned_by_group = build(:group) user.user_detail.provisioned_by_group = group
end end
it 'is true' do it 'is true' do
...@@ -833,6 +835,24 @@ RSpec.describe User do ...@@ -833,6 +835,24 @@ RSpec.describe User do
expect(user.user_authorized_by_provisioning_group?).to eq false expect(user.user_authorized_by_provisioning_group?).to eq false
end end
end end
context 'with feature flag switched on for particular groups' do
before do
stub_feature_flags(block_password_auth_for_saml_users: false)
end
it 'is false when provisioned by group without feature flag' do
stub_feature_flags(block_password_auth_for_saml_users: create(:group))
expect(user.user_authorized_by_provisioning_group?).to eq false
end
it 'is true when provisioned by group with feature flag' do
stub_feature_flags(block_password_auth_for_saml_users: group)
expect(user.user_authorized_by_provisioning_group?).to eq true
end
end
end end
context 'when user is not provisioned by group' do context 'when user is not provisioned by group' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment