Skip to content

Commit

Permalink
Updates validate_request_format so it checks for existance attributes…
Browse files Browse the repository at this point in the history
… object after data object
  • Loading branch information
rockwellwindsor-va committed May 19, 2023
1 parent 6a5afe2 commit 35a58dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def validate
private

def validate_request_format
if params[:data].nil?
if params[:data].nil? || params[:data][:attributes].nil?
message = 'Request body is not in the correct format.'
raise ::Common::Exceptions::BadRequest.new(detail: message)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@

context 'when payload is invalid' do
context "when 'type' is invalid" do
context "in the :data object" do
let(:invalid_data) do
{
data: {
type: ''
}
}
end
it 'returns a 400' do
with_okta_user(scopes) do |auth_header|
post itf_submit_path, params: invalid_data, headers: auth_header
expect(response.status).to eq(400)
end
end
end
context "when 'type' is blank" do
it 'returns a 400' do
with_okta_user(scopes) do |auth_header|
Expand Down Expand Up @@ -706,7 +721,7 @@
end
end

it 'returns 422 when submitting to SUBMIT with incorrect body format' do
it 'returns 400 when submitting to SUBMIT with incorrect body format' do
with_okta_user(scopes) do |auth_header|
invalid_data_format = data[:data][:attributes]
post itf_submit_path, params: invalid_data_format, headers: auth_header
Expand Down

0 comments on commit 35a58dd

Please sign in to comment.