Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ def require_loa3!
raise Common::Exceptions::Unauthorized unless current_user&.loa&.fetch(:current, nil) == 3
end

INQUIRY_ID_FORMAT = /\AA-[0-9]{8}-[0-9]{6,7}\z/
INQUIRY_ID_FORMAT = /\AA-[0-9]{8}-[0-9]{5,}\z/

Comment thread
jerekshoe marked this conversation as resolved.
Outdated
# Validates that params[:id] follows the known inquiry ID format "A-YYYYMMDD-NNNNNN".
# Validates that params[:id] follows the known inquiry ID format "A-YYYYMMDD-NNNNN+ (5 or more digits)".
def validate_inquiry_id_format
unless params[:id].match?(INQUIRY_ID_FORMAT)
render json: { error: 'Invalid inquiry ID format. Expected format: A-YYYYMMDD-NNNNNN.' }, status: :bad_request
render json: { error: 'Invalid inquiry ID format. Expected format: A-YYYYMMDD-NNNNN+ (5 or more digits).' },
status: :bad_request
Comment thread
jerekshoe marked this conversation as resolved.
Outdated
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
end

context 'when the id format is invalid' do
%w[invalid 12345 A-1234567-123456 A-12345678-12345 A-12345678-12345678 A12345678123456].each do |bad_id|
%w[invalid 12345 A-1234567-123456 A-12345678-1234 A-12345678-12L4567 A12345678123456].each do |bad_id|
it "returns bad_request for '#{bad_id}'" do
get "/ask_va_api/v0/inquiries/#{bad_id}/status"
expect(response).to have_http_status(:bad_request)
Expand Down
Loading