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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
5ee7c419
Commit
5ee7c419
authored
Apr 03, 2019
by
rpereira2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call permit! on params
parent
16772b91
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
app/controllers/projects/environments/prometheus_api_controller.rb
...ollers/projects/environments/prometheus_api_controller.rb
+1
-1
spec/controllers/projects/environments/prometheus_api_controller_spec.rb
...s/projects/environments/prometheus_api_controller_spec.rb
+14
-1
No files found.
app/controllers/projects/environments/prometheus_api_controller.rb
View file @
5ee7c419
...
...
@@ -9,7 +9,7 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon
environment
,
request
.
method
,
params
[
:proxy_path
],
params
params
.
permit!
).
execute
if
result
.
nil?
...
...
spec/controllers/projects/environments/prometheus_api_controller_spec.rb
View file @
5ee7c419
...
...
@@ -14,11 +14,22 @@ describe Projects::Environments::PrometheusApiController do
describe
'GET #proxy'
do
let
(
:prometheus_proxy_service
)
{
instance_double
(
Prometheus
::
ProxyService
)
}
let
(
:expected_params
)
do
ActionController
::
Parameters
.
new
(
"query"
=>
"1"
,
"id"
=>
"1"
,
"namespace_id"
=>
"namespace1"
,
"project_id"
=>
"project1"
,
"proxy_path"
=>
"query"
,
"controller"
=>
"projects/environments/prometheus_api"
,
"action"
=>
"proxy"
).
permit!
end
context
'with valid requests'
do
before
do
allow
(
Prometheus
::
ProxyService
).
to
receive
(
:new
)
.
with
(
environment
,
'GET'
,
'query'
,
anything
)
.
with
(
environment
,
'GET'
,
'query'
,
expected_params
)
.
and_return
(
prometheus_proxy_service
)
allow
(
prometheus_proxy_service
).
to
receive
(
:execute
)
...
...
@@ -33,6 +44,8 @@ describe Projects::Environments::PrometheusApiController do
it
'returns prometheus response'
do
get
:proxy
,
params:
environment_params
expect
(
Prometheus
::
ProxyService
).
to
have_received
(
:new
)
.
with
(
environment
,
'GET'
,
'query'
,
expected_params
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
eq
(
prometheus_json_body
)
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