Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb')
-rw-r--r--spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb b/spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb
index ed1440f23b6..7bc5fd853bf 100644
--- a/spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb
+++ b/spec/lib/gitlab/middleware/handle_malformed_strings_spec.rb
@@ -58,6 +58,39 @@ RSpec.describe Gitlab::Middleware::HandleMalformedStrings do
end
end
+ context 'with POST request' do
+ let(:request_env) do
+ Rack::MockRequest.env_for(
+ '/',
+ method: 'POST',
+ input: input,
+ 'CONTENT_TYPE' => 'application/json'
+ )
+ end
+
+ let(:params) { { method: 'POST' } }
+
+ context 'with valid JSON' do
+ let(:input) { %({"hello": "world"}) }
+
+ it 'returns no error' do
+ env = request_env
+
+ expect(subject.call(env)).not_to eq error_400
+ end
+ end
+
+ context 'with bad JSON' do
+ let(:input) { "{ bad json }" }
+
+ it 'rejects bad JSON with 400 error' do
+ env = request_env
+
+ expect(subject.call(env)).to eq error_400
+ end
+ end
+ end
+
context 'in authorization headers' do
let(:problematic_input) { null_byte }