Commit bc6e7e2c authored by syasonik's avatar syasonik

Address invalid embed_json values

parent 68d82ed0
......@@ -24,6 +24,8 @@ module Metrics
override :get_raw_dashboard
def get_raw_dashboard
JSON.parse(params[:embed_json])
rescue JSON::ParserError => e
invalid_embed_json!(e.message)
end
override :sequence
......@@ -35,6 +37,10 @@ module Metrics
def identifiers
Digest::SHA256.hexdigest(params[:embed_json])
end
def invalid_embed_json!(message)
raise DashboardProcessingError.new("Parsing error for param :embed_json. #{message}")
end
end
end
end
......@@ -67,6 +67,12 @@ describe Metrics::Dashboard::TransientEmbedService, :use_clean_rails_memory_stor
expect(get_type_for_embed(alt_embed)).to eq('area-chart')
end
context 'when embed_json cannot be parsed as json' do
let(:embed_json) { '' }
it_behaves_like 'misconfigured dashboard service response', :unprocessable_entity
end
private
def get_embed_json(type = 'line-graph')
......
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