ok2c commented on a change in pull request #230:
URL:
https://github.com/apache/httpcomponents-client/pull/230#discussion_r447627383
##########
File path:
httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java
##########
@@ -321,12 +323,26 @@ public void testParseNTLMAuthChallenge() throws Exception
{
Assert.assertEquals(null, challenge1.getValue());
}
- private static void assertNameValuePair (
- final NameValuePair expected,
- final NameValuePair result) {
- Assert.assertNotNull(result);
- Assert.assertEquals(expected.getName(), result.getName());
- Assert.assertEquals(expected.getValue(), result.getValue());
+ @Test
+ public void testParseParameterAndToken68AuthChallengeMix() throws
Exception {
+ final CharArrayBuffer buffer = new CharArrayBuffer(64);
+ buffer.append("scheme1 aaaa , scheme2 aaaa==, scheme3 aaaa=aaaa,
scheme4 aaaa=");
+ final ParserCursor cursor = new ParserCursor(0, buffer.length());
+ final List<AuthChallenge> challenges =
parser.parse(ChallengeType.TARGET, buffer, cursor);
+ Assert.assertNotNull(challenges);
+ Assert.assertEquals(4, challenges.size());
+ final AuthChallenge challenge1 = challenges.get(0);
+ Assert.assertThat(challenge1.getSchemeName(),
CoreMatchers.equalTo("scheme1"));
+ Assert.assertThat(challenge1.getValue(), CoreMatchers.equalTo("aaaa"));
+ final AuthChallenge challenge2 = challenges.get(1);
+ Assert.assertThat(challenge2.getSchemeName(),
CoreMatchers.equalTo("scheme2"));
+ Assert.assertThat(challenge2.getValue(),
CoreMatchers.equalTo("aaaa=="));
+ final AuthChallenge challenge3 = challenges.get(2);
+ Assert.assertThat(challenge3.getSchemeName(),
CoreMatchers.equalTo("scheme3"));
+ Assert.assertThat(challenge3.getValue(), CoreMatchers.nullValue());
Review comment:
@michael-o This is precisely the problem as there is no way of telling
if you are looking at a parameter or at a padded token68. The current solution
is to assume that anything looking ambiguous is likely a token86 but
`aaaa=aaaa` definitely more likely a parameter.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]