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
cc18c332
Commit
cc18c332
authored
Aug 22, 2019
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test, reduce complexity
parent
30f302d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
app/services/application_settings/update_service.rb
app/services/application_settings/update_service.rb
+5
-2
spec/services/application_settings/update_service_spec.rb
spec/services/application_settings/update_service_spec.rb
+6
-0
No files found.
app/services/application_settings/update_service.rb
View file @
cc18c332
...
@@ -7,8 +7,7 @@ module ApplicationSettings
...
@@ -7,8 +7,7 @@ module ApplicationSettings
attr_reader
:params
,
:application_setting
attr_reader
:params
,
:application_setting
def
execute
def
execute
disable_ext_auth
=
params
[
:external_authorization_service_enabled
].
present?
&&
!
Gitlab
::
Utils
.
to_boolean
(
params
[
:external_authorization_service_enabled
])
validate_classification_label
(
application_setting
,
:external_authorization_service_default_label
)
unless
bypass_external_auth?
validate_classification_label
(
application_setting
,
:external_authorization_service_default_label
)
unless
disable_ext_auth
if
application_setting
.
errors
.
any?
if
application_setting
.
errors
.
any?
return
false
return
false
...
@@ -60,5 +59,9 @@ module ApplicationSettings
...
@@ -60,5 +59,9 @@ module ApplicationSettings
Group
.
find_by_full_path
(
group_full_path
)
&
.
id
if
group_full_path
.
present?
Group
.
find_by_full_path
(
group_full_path
)
&
.
id
if
group_full_path
.
present?
end
end
def
bypass_external_auth?
params
.
key?
(
:external_authorization_service_enabled
)
&&
!
Gitlab
::
Utils
.
to_boolean
(
params
[
:external_authorization_service_enabled
])
end
end
end
end
end
spec/services/application_settings/update_service_spec.rb
View file @
cc18c332
...
@@ -201,6 +201,12 @@ describe ApplicationSettings::UpdateService do
...
@@ -201,6 +201,12 @@ describe ApplicationSettings::UpdateService do
enable_external_authorization_service_check
enable_external_authorization_service_check
end
end
it
'does not validate labels if external authorization gets disabled'
do
expect_any_instance_of
(
described_class
).
not_to
receive
(
:validate_classification_label
)
described_class
.
new
(
application_settings
,
admin
,
{
external_authorization_service_enabled:
false
}).
execute
end
it
'does not save the settings with an error if the service denies access'
do
it
'does not save the settings with an error if the service denies access'
do
expect
(
::
Gitlab
::
ExternalAuthorization
)
expect
(
::
Gitlab
::
ExternalAuthorization
)
.
to
receive
(
:access_allowed?
).
with
(
admin
,
'new-label'
)
{
false
}
.
to
receive
(
:access_allowed?
).
with
(
admin
,
'new-label'
)
{
false
}
...
...
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