Skip to content

Commit 3648a78

Browse files
committed
Fix JndiRealm tests
1 parent 97bb21d commit 3648a78

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

test/org/apache/catalina/realm/TestJNDIRealm.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public class TestJNDIRealm {
5454
private static final String REALM = "test-realm";
5555

5656
private static final String NONCE = "test-nonce";
57+
private static final String CNONCE = "cnonce";
58+
private static final String NC = "00000001";
59+
private static final String QOP = "auth";
5760
// Not digested but doesn't matter for the purposes of the test
5861
private static final String DIGEST_A2 = "method:request-uri";
5962
public static final String USER_PASSWORD_ATTR = "test-pwd";
@@ -72,9 +75,9 @@ public void testAuthenticateWithoutUserPassword() throws Exception {
7275

7376
// WHEN
7477
String expectedResponse =
75-
HexUtils.toHexString(md5Helper.digest((digestA1() + ":" + NONCE + ":" + DIGEST_A2).getBytes()));
78+
HexUtils.toHexString(md5Helper.digest((digestA1() + ":" + NONCE + ":" + NC + ":" + CNONCE + ":" + QOP + ":" + DIGEST_A2).getBytes()));
7679
Principal principal =
77-
realm.authenticate(USER, expectedResponse, NONCE, null, null, null, REALM, DIGEST_A2, ALGORITHM);
80+
realm.authenticate(USER, expectedResponse, NONCE, NC, CNONCE, QOP, REALM, DIGEST_A2, ALGORITHM);
7881

7982
// THEN
8083
Assert.assertNull(principal);
@@ -88,9 +91,9 @@ public void testAuthenticateWithUserPassword() throws Exception {
8891

8992
// WHEN
9093
String expectedResponse =
91-
HexUtils.toHexString(md5Helper.digest((digestA1() + ":" + NONCE + ":" + DIGEST_A2).getBytes()));
94+
HexUtils.toHexString(md5Helper.digest((digestA1() + ":" + NONCE + ":" + NC + ":" + CNONCE + ":" + QOP + ":" + DIGEST_A2).getBytes()));
9295
Principal principal =
93-
realm.authenticate(USER, expectedResponse, NONCE, null, null, null, REALM, DIGEST_A2, ALGORITHM);
96+
realm.authenticate(USER, expectedResponse, NONCE, NC, CNONCE, QOP, REALM, DIGEST_A2, ALGORITHM);
9497

9598
// THEN
9699
assertThat(principal, instanceOf(GenericPrincipal.class));
@@ -106,9 +109,9 @@ public void testAuthenticateWithUserPasswordAndCredentialHandler() throws Except
106109

107110
// WHEN
108111
String expectedResponse =
109-
HexUtils.toHexString(md5Helper.digest((digestA1() + ":" + NONCE + ":" + DIGEST_A2).getBytes()));
112+
HexUtils.toHexString(md5Helper.digest((digestA1() + ":" + NONCE + ":" + NC + ":" + CNONCE + ":" + QOP + ":" + DIGEST_A2).getBytes()));
110113
Principal principal =
111-
realm.authenticate(USER, expectedResponse, NONCE, null, null, null, REALM, DIGEST_A2, ALGORITHM);
114+
realm.authenticate(USER, expectedResponse, NONCE, NC, CNONCE, QOP, REALM, DIGEST_A2, ALGORITHM);
112115

113116
// THEN
114117
assertThat(principal, instanceOf(GenericPrincipal.class));

0 commit comments

Comments
 (0)