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
118e1791
Commit
118e1791
authored
Nov 18, 2021
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix VulnerabilitiesController authorization for new action spec
parent
d800938c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
ee/spec/controllers/projects/security/vulnerabilities_controller_spec.rb
...lers/projects/security/vulnerabilities_controller_spec.rb
+16
-10
No files found.
ee/spec/controllers/projects/security/vulnerabilities_controller_spec.rb
View file @
118e1791
...
@@ -18,27 +18,33 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
...
@@ -18,27 +18,33 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
describe
'GET #new'
do
describe
'GET #new'
do
let
(
:request_new_vulnerability_page
)
{
get
:new
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
let
(
:request_new_vulnerability_page
)
{
get
:new
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
}
before
do
allow
(
controller
).
to
receive
(
:can?
).
and_call_original
allow
(
controller
).
to
receive
(
:can?
).
with
(
controller
.
current_user
,
:create_vulnerability
,
an_instance_of
(
Project
)).
and_return
(
can_create_vulnerability
)
end
include_context
'"Security & Compliance" permissions'
do
include_context
'"Security & Compliance" permissions'
do
let
(
:valid_request
)
{
request_new_vulnerability_page
}
let
(
:valid_request
)
{
request_new_vulnerability_page
}
let
(
:can_create_vulnerability
)
{
true
}
end
end
it
'renders the add new finding page
'
do
context
'when user can create vulnerability
'
do
request_new_vulnerability_page
let
(
:can_create_vulnerability
)
{
true
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
it
'renders the add new finding page'
do
request_new_vulnerability_page
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
context
'when user can not create vulnerability'
do
context
'when user can not create vulnerability'
do
before
do
let
(
:can_create_vulnerability
)
{
false
}
guest
=
create
(
:user
)
project
.
add_guest
(
guest
)
sign_in
(
guest
)
end
it
'renders
a 403
'
do
it
'renders
404 page not found
'
do
request_new_vulnerability_page
request_new_vulnerability_page
expect
(
response
).
to
have_gitlab_http_status
(
:
forbidden
)
expect
(
response
).
to
have_gitlab_http_status
(
:
not_found
)
end
end
end
end
end
end
...
...
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