Skip to content

Commit

Permalink
[ELY-2315] Add test case for Digest authentication with encoded path
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyllarr committed Mar 16, 2022
1 parent 44f0afc commit beda1cb
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,32 @@ public void testRfc2617EncodedQuery() throws Exception {
Assert.assertEquals(Status.COMPLETE, request2.getResult());
}

@Test
public void testRfc2617EncodedPath() throws Exception {
mockDigestNonce("AAAAAQABsxiWa25/kpFxsPCrpDCFsjkTzs/Xr7RPsi/VVN6faYp21Hia3h4=");
Map<String, Object> props = new HashMap<>();
props.put(CONFIG_REALM, "[email protected]");
props.put("org.wildfly.security.http.validate-digest-uri", "true");
HttpServerAuthenticationMechanism mechanism = digestFactory.createAuthenticationMechanism(DIGEST_NAME, props, getCallbackHandler("Mufasa", "[email protected]", "Circle Of Life"));

String path = "/dir/foo%2Fr/index.html?foo=b%2Fr";
String uri = "http://localhost" + path;
TestingHttpServerRequest request2 = new TestingHttpServerRequest(new String[] {
"Digest username=\"Mufasa\",\n" +
" realm=\"[email protected]\",\n" +
" nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\",\n" +
" uri=\"" + path + "\",\n" +
" qop=auth,\n" +
" nc=00000001,\n" +
" cnonce=\"0a4f113b\",\n" +
" response=\"cc3261565007973c9d647333822091ad\",\n" +
" opaque=\"00000000000000000000000000000000\",\n" +
" algorithm=MD5"
}, new URI(uri));
mechanism.evaluateRequest(request2);
Assert.assertEquals(Status.COMPLETE, request2.getResult());
}

@Test
public void testRfc7616sha256() throws Exception {
mockDigestNonce("7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v");
Expand Down

0 comments on commit beda1cb

Please sign in to comment.