|
33 | 33 | import io.fusionauth.http.server.HTTPServerConfiguration; |
34 | 34 | import org.testng.annotations.Test; |
35 | 35 | import static org.testng.Assert.assertEquals; |
36 | | -import static org.testng.Assert.assertNotNull; |
37 | 36 | import static org.testng.Assert.assertNull; |
38 | 37 |
|
39 | 38 | /** |
@@ -84,7 +83,7 @@ public void post_server_configuration_max_form_data(String scheme, boolean chunk |
84 | 83 | content-length: 0\r |
85 | 84 | \r |
86 | 85 | """) |
87 | | - .expectExceptionOnWrite(SocketException.class); |
| 86 | + .assertOptionalExceptionOnWrite(SocketException.class); |
88 | 87 |
|
89 | 88 | // Large, but max size has been disabled |
90 | 89 | withScheme(scheme) |
@@ -115,7 +114,7 @@ public void post_server_configuration_max_form_data(String scheme, boolean chunk |
115 | 114 | content-length: 0\r |
116 | 115 | \r |
117 | 116 | """) |
118 | | - .expectExceptionOnWrite(SocketException.class); |
| 117 | + .assertOptionalExceptionOnWrite(SocketException.class); |
119 | 118 | } |
120 | 119 |
|
121 | 120 | @Test(dataProvider = "schemes") |
@@ -154,7 +153,7 @@ public void post_server_configuration_max_request_header_size(String scheme) thr |
154 | 153 | content-length: 0\r |
155 | 154 | \r |
156 | 155 | """) |
157 | | - .expectExceptionOnWrite(SocketException.class); |
| 156 | + .assertOptionalExceptionOnWrite(SocketException.class); |
158 | 157 |
|
159 | 158 | // Same big size, but disable header size limit. |
160 | 159 | withScheme(scheme) |
@@ -198,12 +197,6 @@ public Builder(String scheme) { |
198 | 197 | this.scheme = scheme; |
199 | 198 | } |
200 | 199 |
|
201 | | - public Builder expectExceptionOnWrite(Class<? extends Exception> clazz) { |
202 | | - assertNotNull(thrownOnWrite); |
203 | | - assertEquals(thrownOnWrite.getClass(), clazz); |
204 | | - return this; |
205 | | - } |
206 | | - |
207 | 200 | public Builder expectNoExceptionOnWrite() { |
208 | 201 | assertNull(thrownOnWrite); |
209 | 202 | return this; |
@@ -314,6 +307,18 @@ public Builder expectResponse(String response) throws Exception { |
314 | 307 | return this; |
315 | 308 | } |
316 | 309 |
|
| 310 | + public Builder assertOptionalExceptionOnWrite(Class<? extends Exception> clazz) { |
| 311 | + // Note that this assertion really depends upon the system the test is run on, the size of the request, and the amount of data that can be cached. |
| 312 | + // - So this is an optional assertion - if exception is not null, then we should be able to assert some attributes. |
| 313 | + // - With the larger sizes this exception is mostly always thrown when running tests locally, but in GHA, it doesn't always occur. |
| 314 | + if (thrownOnWrite != null) { |
| 315 | + assertEquals(thrownOnWrite.getClass(), clazz); |
| 316 | + assertEquals(thrownOnWrite.getMessage(), "Broken pipe"); |
| 317 | + } |
| 318 | + |
| 319 | + return this; |
| 320 | + } |
| 321 | + |
317 | 322 | public Builder withBodyParameterCount(int bodyParameterCount) { |
318 | 323 | this.bodyParameterCount = bodyParameterCount; |
319 | 324 | return this; |
|
0 commit comments