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
6e657a34
Commit
6e657a34
authored
Apr 16, 2020
by
Ryan Cobb
Committed by
Jose Vargas
Apr 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs and cleanup method
Add specs and clean method around metrics dashboard auth.
parent
a5d176ac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
8 deletions
+149
-8
app/assets/javascripts/pages/projects/shared/permissions/components/settings_panel.vue
...projects/shared/permissions/components/settings_panel.vue
+3
-2
app/models/project.rb
app/models/project.rb
+6
-5
app/policies/project_policy.rb
app/policies/project_policy.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+139
-0
No files found.
app/assets/javascripts/pages/projects/shared/permissions/components/settings_panel.vue
View file @
6e657a34
...
...
@@ -212,6 +212,7 @@ export default {
this
.
buildsAccessLevel
=
Math
.
min
(
10
,
this
.
buildsAccessLevel
);
this
.
wikiAccessLevel
=
Math
.
min
(
10
,
this
.
wikiAccessLevel
);
this
.
snippetsAccessLevel
=
Math
.
min
(
10
,
this
.
snippetsAccessLevel
);
this
.
metricsAccessLevel
=
Math
.
min
(
10
,
this
.
metricsAccessLevel
);
if
(
this
.
pagesAccessLevel
===
20
)
{
// When from Internal->Private narrow access for only members
this
.
pagesAccessLevel
=
10
;
...
...
@@ -491,12 +492,12 @@ export default {
class=
"form-control select-control"
>
<option
:value=
"
visibilityOptions.INTERNAL
"
:value=
"
featureAccessLevelMembers[0]
"
:disabled=
"!visibilityAllowed(visibilityOptions.INTERNAL)"
>
{{ featureAccessLevelMembers[1] }}
</option
>
<option
:value=
"
visibilityOptions.PUBLIC
"
:value=
"
featureAccessLevelEveryone[0]
"
:disabled=
"!visibilityAllowed(visibilityOptions.PUBLIC)"
>
{{ featureAccessLevelEveryone[1] }}
</option
>
...
...
app/models/project.rb
View file @
6e657a34
...
...
@@ -2400,11 +2400,12 @@ class Project < ApplicationRecord
end
def
metrics_dashboard_allowed?
(
user
)
if
(
public
?
&&
metrics_dashboard_access_level
>=
20
)
||
feature_available?
(:
metrics_dashboard
,
user
)
true
else
false
end
project_feature
.
metrics_dashboard_access_level
=
10
if
private
?
# private projects should never have an access level above private
return
true
if
public
?
&&
metrics_dashboard_access_level
>=
20
return
false
unless
user
feature_available?
(
:metrics_dashboard
,
user
)
?
true
:
false
end
private
...
...
app/policies/project_policy.rb
View file @
6e657a34
...
...
@@ -255,7 +255,7 @@ class ProjectPolicy < BasePolicy
enable
:fork_project
end
rule
{
metrics_dashboard_allowed
}.
policy
do
rule
{
metrics_dashboard_allowed
}.
enable
do
enable
:metrics_dashboard
enable
:read_prometheus
enable
:read_environment
...
...
spec/models/project_spec.rb
View file @
6e657a34
...
...
@@ -5944,6 +5944,145 @@ describe Project do
end
end
describe
'#metrics_dashboard_allowed?'
do
context
'project is public'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
context
'metrics_dashboard_access_level is set to private'
do
before
do
project
.
metrics_dashboard_access_level
=
'private'
end
it
'does not allow anonymous access'
do
user
=
nil
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
false
end
it
'allows logged in users'
do
user
=
create
(
:user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
false
end
it
'allows project members'
do
user
=
create
(
:user
)
project
.
add_developer
(
user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
true
end
end
context
'metrics_dashboard_access_level is set to enabled'
do
before
do
project
.
metrics_dashboard_access_level
=
'enabled'
end
it
'allows annoymous access'
do
user
=
nil
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
true
end
it
'allows logged in users'
do
user
=
create
(
:user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
true
end
it
'allows project members'
do
user
=
create
(
:user
)
project
.
add_developer
(
user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
true
end
end
end
context
'project is internal'
do
let
(
:project
)
{
create
(
:project
,
:internal
)
}
context
'metrics_dashboard_access_level is set to private'
do
before
do
project
.
metrics_dashboard_access_level
=
'private'
end
it
'does not allow anonymous access'
do
user
=
nil
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
false
end
it
'allows logged in users'
do
user
=
create
(
:user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
false
end
it
'allows project members'
do
user
=
create
(
:user
)
project
.
add_developer
(
user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
true
end
end
context
'metrics_dashboard_access_level is set to enabled'
do
before
do
project
.
metrics_dashboard_access_level
=
'enabled'
end
it
'does not allow anonymous access'
do
user
=
nil
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
false
end
it
'allows logged in users'
do
user
=
create
(
:user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
true
end
it
'allows project members'
do
user
=
create
(
:user
)
project
.
add_developer
(
user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
true
end
end
end
context
'project is private'
do
let
(
:project
)
{
create
(
:project
,
:private
)
}
context
'metrics_dashboard_access_level is set to private'
do
before
do
project
.
metrics_dashboard_access_level
=
'private'
end
it
'does not allow anonymous access'
do
user
=
nil
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
false
end
it
'does not allow logged in users'
do
user
=
create
(
:user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
false
end
it
'allows project members'
do
user
=
create
(
:user
)
project
.
add_developer
(
user
)
expect
(
project
.
metrics_dashboard_allowed?
(
user
)).
to
be
true
end
end
end
end
def
finish_job
(
export_job
)
export_job
.
start
export_job
.
finish
...
...
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