Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4f92594a
Commit
4f92594a
authored
May 05, 2021
by
Małgorzata Ksionek
Committed by
Douglas Barbosa Alexandre
May 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide different method for checking feature flag
parent
b7a620b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+2
-2
ee/spec/models/ee/user_spec.rb
ee/spec/models/ee/user_spec.rb
+21
-1
No files found.
ee/app/models/ee/user.rb
View file @
4f92594a
...
...
@@ -328,11 +328,11 @@ module EE
end
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
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
def
gitlab_employee?
...
...
ee/spec/models/ee/user_spec.rb
View file @
4f92594a
...
...
@@ -816,8 +816,10 @@ RSpec.describe User do
describe
'#user_authorized_by_provisioning_group?'
do
context
'when user is provisioned by group'
do
let
(
:group
)
{
build
(
:group
)
}
before
do
user
.
user_detail
.
provisioned_by_group
=
build
(
:group
)
user
.
user_detail
.
provisioned_by_group
=
group
end
it
'is true'
do
...
...
@@ -833,6 +835,24 @@ RSpec.describe User do
expect
(
user
.
user_authorized_by_provisioning_group?
).
to
eq
false
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
context
'when user is not provisioned by group'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment