codeconsole commented on code in PR #13863:
URL: https://github.com/apache/grails-core/pull/13863#discussion_r3553013952


##########
grails-test-examples/enable-mvc-check/README.md:
##########
@@ -0,0 +1,62 @@
+<!--
+SPDX-License-Identifier: Apache-2.0
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+# enable-mvc-check
+
+A dedicated Grails functional test application that pins down the behavior of

Review Comment:
   Removed in 5c4974389b.



##########
grails-web-common/src/test/groovy/grails/web/servlet/mvc/GrailsParameterMapTests.groovy:
##########
@@ -92,82 +97,47 @@ class GrailsParameterMapTests {
     }
 
     @Test
-    void testParseRequestBodyForPutRequest() {
-        def request = new MockHttpServletRequest()
-        request.content = 'foo=bar&one=two'.bytes
-        request.method = 'PUT'
-        request.contentType = "application/x-www-form-urlencoded"
-
-        def params = new GrailsParameterMap(request)
+    void testFormEncodedPutBodyIsExposedAsParams() {
+        def params = new GrailsParameterMap(formFilteredRequest('PUT', 
'foo=bar&one=two', 'application/x-www-form-urlencoded'))
 
         assert 'bar' == params.foo
         assert 'two' == params.one
-
-        params = new GrailsParameterMap(request)
-        assert params.foo == null // should be null, request can't be parsed 
twice
-
-        request = new MockHttpServletRequest()
-        request.method = 'PUT'
-        request.content = 'foo='.bytes
-        request.contentType = "application/x-www-form-urlencoded"
-        request.removeAttribute(GrailsParameterMap.REQUEST_BODY_PARSED)
-
-        params = new GrailsParameterMap(request)
-
-        assert '' == params.foo
     }
 
     @Test
-    void testParseRequestBodyForPutRequestWithCharset() {
-        def request = new MockHttpServletRequest()
-        request.content = 'foo=bar&one=two'.bytes
-        request.method = 'PUT'
-        request.contentType = "application/x-www-form-urlencoded; 
charset=UTF-8"
-
-        def params = new GrailsParameterMap(request)
+    void testFormEncodedPutBodyWithCharsetIsExposedAsParams() {
+        def params = new GrailsParameterMap(formFilteredRequest('PUT', 
'foo=bar&one=two', 'application/x-www-form-urlencoded; charset=UTF-8'))
 
         assert 'bar' == params.foo
         assert 'two' == params.one
-
-        params = new GrailsParameterMap(request)
-        assert params.foo == null // should be null, request can't be parsed 
twice
-
-        request = new MockHttpServletRequest()
-        request.method = 'PUT'
-        request.contentType = "application/x-www-form-urlencoded; 
charset=UTF-8"
-        request.content = 'foo='.bytes
-        request.removeAttribute(GrailsParameterMap.REQUEST_BODY_PARSED)

Review Comment:
   Added in 5c4974389b — a `FormContentFunctionalSpec` in `app1` (a default, 
non-@EnableWebMvc app) asserts that form-encoded `PUT`, `PATCH` and `DELETE` 
(and `POST`) bodies are parsed into `params` via Boot OrderedFormContentFilter, 
covering these removed unit scenarios end-to-end.



##########
grails-web-common/src/test/groovy/grails/web/servlet/mvc/GrailsParameterMapTests.groovy:
##########
@@ -92,82 +97,47 @@ class GrailsParameterMapTests {
     }
 
     @Test
-    void testParseRequestBodyForPutRequest() {
-        def request = new MockHttpServletRequest()
-        request.content = 'foo=bar&one=two'.bytes
-        request.method = 'PUT'
-        request.contentType = "application/x-www-form-urlencoded"
-
-        def params = new GrailsParameterMap(request)
+    void testFormEncodedPutBodyIsExposedAsParams() {
+        def params = new GrailsParameterMap(formFilteredRequest('PUT', 
'foo=bar&one=two', 'application/x-www-form-urlencoded'))
 
         assert 'bar' == params.foo
         assert 'two' == params.one
-
-        params = new GrailsParameterMap(request)
-        assert params.foo == null // should be null, request can't be parsed 
twice
-
-        request = new MockHttpServletRequest()
-        request.method = 'PUT'
-        request.content = 'foo='.bytes
-        request.contentType = "application/x-www-form-urlencoded"
-        request.removeAttribute(GrailsParameterMap.REQUEST_BODY_PARSED)
-
-        params = new GrailsParameterMap(request)
-
-        assert '' == params.foo
     }
 
     @Test
-    void testParseRequestBodyForPutRequestWithCharset() {
-        def request = new MockHttpServletRequest()
-        request.content = 'foo=bar&one=two'.bytes
-        request.method = 'PUT'
-        request.contentType = "application/x-www-form-urlencoded; 
charset=UTF-8"
-
-        def params = new GrailsParameterMap(request)
+    void testFormEncodedPutBodyWithCharsetIsExposedAsParams() {
+        def params = new GrailsParameterMap(formFilteredRequest('PUT', 
'foo=bar&one=two', 'application/x-www-form-urlencoded; charset=UTF-8'))
 
         assert 'bar' == params.foo
         assert 'two' == params.one
-
-        params = new GrailsParameterMap(request)
-        assert params.foo == null // should be null, request can't be parsed 
twice
-
-        request = new MockHttpServletRequest()
-        request.method = 'PUT'
-        request.contentType = "application/x-www-form-urlencoded; 
charset=UTF-8"
-        request.content = 'foo='.bytes
-        request.removeAttribute(GrailsParameterMap.REQUEST_BODY_PARSED)
-
-        params = new GrailsParameterMap(request)
-
-        assert '' == params.foo
     }
 
     @Test
-    void testParseRequestBodyForPatchRequest() {
-        def request = new MockHttpServletRequest()
-        request.content = 'foo=bar&one=two'.bytes
-        request.method = 'PATCH'
-        request.contentType = "application/x-www-form-urlencoded"
-
-        def params = new GrailsParameterMap(request)
+    void testFormEncodedPatchBodyIsExposedAsParams() {
+        def params = new GrailsParameterMap(formFilteredRequest('PATCH', 
'foo=bar&one=two', 'application/x-www-form-urlencoded'))
 
         assert 'bar' == params.foo
         assert 'two' == params.one
+    }
 
-        params = new GrailsParameterMap(request)
-        assert params.foo == null // should be null, request can't be parsed 
twice
-
-        request = new MockHttpServletRequest()

Review Comment:
   Same as above — covered by the new `FormContentFunctionalSpec` in `app1` 
(5c4974389b).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to