Skip to content

Commit 3be21d9

Browse files
committed
Tests
1 parent faf842b commit 3be21d9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/main/java/io/fusionauth/http/server/HTTPServerConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ public int getMaxPendingSocketConnections() {
206206
* The map that specifies the maximum size in bytes of the HTTP request body by Content-Type. This configuration excludes the size of the
207207
* HTTP request header.
208208
* <p>
209-
* The returned map is keyed by Content-Type, and willy contain a default value identified by '*', and may optionally return content type
210-
* values with a wild card '*' as the subtype.
209+
* The returned map is keyed by Content-Type, and will contain a default value identified by '*', and may optionally contain a content
210+
* type value with a wild card '*' as the subtype. For example, 'application/*' will match all subtypes of an application/ content type.
211211
*
212212
* @return the map keyed by Content-Type indicating the maximum size in bytes of the HTTP request body. Defaults to 128 Megabytes as a
213213
* default, and 10 Megabytes for application/x-www-form-urlencoded.

src/test/java/io/fusionauth/http/util/HTTPToolsTest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ public void getMaxRequestBodySize() {
6363
assertMaxConfiguredSize("multipart/form-data", 5, configuration);
6464
assertMaxConfiguredSize("text/css", 6, configuration);
6565
assertMaxConfiguredSize("text/html", 7, configuration);
66+
67+
// We don't expect this at runtime, but ideally we won't explode. These would be invalid values.
68+
// - Some of these are legit Content-Type headers, but at runtime we will have already parsed the header so we do
69+
// not expect any attributes;
70+
assertMaxConfiguredSize("", 1, configuration);
71+
assertMaxConfiguredSize("null", 1, configuration);
72+
assertMaxConfiguredSize("application/json; foo=bar", 2, configuration);
73+
assertMaxConfiguredSize("multipart/form-data; boundary=------", 1, configuration);
74+
assertMaxConfiguredSize("text/css; charset=ISO-8859-1", 6, configuration);
75+
assertMaxConfiguredSize("text/unexpected", 6, configuration);
76+
assertMaxConfiguredSize("text/unexpected/value", 6, configuration);
6677
}
6778

6879
@Test
@@ -264,7 +275,7 @@ private void assertHexValue(String s, String expected, Charset charset) {
264275
}
265276

266277
private void assertMaxConfiguredSize(String contentType, int maximumSize, Map<String, Integer> maxRequestBodySize) {
267-
assertEquals(maximumSize, HTTPTools.getMaxRequestBodySize(contentType, maxRequestBodySize));
278+
assertEquals(HTTPTools.getMaxRequestBodySize(contentType, maxRequestBodySize), maximumSize);
268279
}
269280

270281
private String hex(byte[] bytes) {

0 commit comments

Comments
 (0)