-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable http trace method in jetty (#369)
- Loading branch information
1 parent
acc55f6
commit 15261b9
Showing
2 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
carapace-server/src/test/java/org/carapaceproxy/core/JettyHttpTraceMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.carapaceproxy.core; | ||
|
||
import io.netty.handler.codec.http.HttpMethod; | ||
import org.carapaceproxy.api.UseAdminServer; | ||
import org.junit.Test; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class JettyHttpTraceMethodTest extends UseAdminServer { | ||
|
||
@Test | ||
public void httpTraceMethodTest() throws Exception { | ||
startAdmin(); | ||
String URL = "http://localhost:8761"; | ||
URL url = new URL(URL); | ||
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | ||
conn.setRequestMethod(String.valueOf(HttpMethod.TRACE)); | ||
int code = conn.getResponseCode(); | ||
assertEquals(HttpServletResponse.SC_FORBIDDEN, code); | ||
} | ||
} |