|
18 | 18 | */ |
19 | 19 | package de.yaacc.upnp.server.http; |
20 | 20 |
|
| 21 | +import static org.junit.Assert.assertEquals; |
| 22 | +import static org.junit.Assert.assertFalse; |
| 23 | +import static org.junit.Assert.assertNotNull; |
| 24 | +import static org.junit.Assert.assertTrue; |
| 25 | + |
21 | 26 | import org.apache.hc.core5.http.ContentType; |
22 | 27 | import org.apache.hc.core5.http.io.entity.ByteArrayEntity; |
23 | 28 | import org.apache.hc.core5.http.message.BasicClassicHttpResponse; |
|
26 | 31 |
|
27 | 32 | import java.nio.charset.StandardCharsets; |
28 | 33 |
|
29 | | -import static org.junit.Assert.assertEquals; |
30 | | -import static org.junit.Assert.assertFalse; |
31 | | -import static org.junit.Assert.assertNotNull; |
32 | | -import static org.junit.Assert.assertTrue; |
33 | | - |
34 | 34 | public class HttpRequestSenderTest { |
35 | 35 |
|
36 | 36 | @Test |
@@ -70,11 +70,25 @@ public void testCreateResponse_401_doesNotThrow() throws Exception { |
70 | 70 | StreamResponseMessage msg = new HttpRequestSender().createResponse(buildResponse(401, "Unauthorized")); |
71 | 71 | assertNotNull(msg); |
72 | 72 | assertEquals(401, msg.getOperation().getStatusCode()); |
73 | | - assertEquals("HTTP 401", msg.getOperation().getStatusMessage()); |
| 73 | + assertEquals("Unauthorized", msg.getOperation().getStatusMessage()); |
74 | 74 | assertTrue("401 must report isFailed() so the discovery loop skips the device", |
75 | 75 | msg.getOperation().isFailed()); |
76 | 76 | } |
77 | 77 |
|
| 78 | + /** |
| 79 | + * Regression for issue #232. A 403 produce a synthetic failed |
| 80 | + * UpnpResponse so the caller can skip the device. |
| 81 | + */ |
| 82 | + @Test |
| 83 | + public void testCreateResponse_403_doesNotThrow() throws Exception { |
| 84 | + StreamResponseMessage msg = new HttpRequestSender().createResponse(buildResponse(403, "Forbidden")); |
| 85 | + assertNotNull(msg); |
| 86 | + assertEquals(403, msg.getOperation().getStatusCode()); |
| 87 | + assertEquals("Forbidden", msg.getOperation().getStatusMessage()); |
| 88 | + assertTrue("403 must report isFailed() so the discovery loop skips the device", |
| 89 | + msg.getOperation().isFailed()); |
| 90 | + } |
| 91 | + |
78 | 92 | /** |
79 | 93 | * Regression for issue #219 / PR #221. 503 was added to the canonical |
80 | 94 | * Status enum in that PR; verify it still maps to the canonical |
|
0 commit comments