Commit 16772b91 authored by rpereira2's avatar rpereira2

Remove permitting of params

- It is now being done in ProxyService class.
parent eac3e230
...@@ -5,13 +5,11 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon ...@@ -5,13 +5,11 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon
before_action :environment before_action :environment
def proxy def proxy
permitted = permit_params
result = Prometheus::ProxyService.new( result = Prometheus::ProxyService.new(
environment, environment,
request.method, request.method,
permitted[:proxy_path], params[:proxy_path],
permitted.except(:proxy_path) # rubocop: disable CodeReuse/ActiveRecord params
).execute ).execute
if result.nil? if result.nil?
...@@ -24,20 +22,15 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon ...@@ -24,20 +22,15 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon
if result[:status] == :success if result[:status] == :success
render status: result[:http_status], json: result[:body] render status: result[:http_status], json: result[:body]
else else
render status: result[:http_status] || :bad_request, render(
status: result[:http_status] || :bad_request,
json: { status: result[:status], message: result[:message] } json: { status: result[:status], message: result[:message] }
)
end end
end end
private private
def permit_params
params.permit([
:proxy_path, :query, :time, :timeout, :start, :end, :step, { match: [] },
:match_target, :metric, :limit
])
end
def environment def environment
@environment ||= project.environments.find(params[:id]) @environment ||= project.environments.find(params[:id])
end end
......
...@@ -36,15 +36,6 @@ describe Projects::Environments::PrometheusApiController do ...@@ -36,15 +36,6 @@ describe Projects::Environments::PrometheusApiController do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq(prometheus_json_body) expect(json_response).to eq(prometheus_json_body)
end end
it 'filters unknown params' do
get :proxy, params: environment_params(unknown_param: 'value')
params = ActionController::Parameters.new('query' => '1').permit!
expect(Prometheus::ProxyService)
.to have_received(:new)
.with(environment, 'GET', 'query', params)
end
end end
context 'with nil result' do context 'with nil result' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment