arturobernalg commented on code in PR #802:
URL:
https://github.com/apache/httpcomponents-client/pull/802#discussion_r2805216748
##########
httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java:
##########
@@ -400,10 +408,11 @@ void
testBasicAuthenticationCredentialsCachingByPathPrefix() throws Exception {
}
// There should be an auth strategy call for all successful message
exchanges
- Mockito.verify(authStrategy, Mockito.times(2)).select(Mockito.any(),
Mockito.any(), Mockito.any());
+ Mockito.verify(authStrategy, Mockito.times(3)).select(Mockito.any(),
Mockito.any(), Mockito.any());
- Assertions.assertEquals(Arrays.asList(200, 401, 200, 200, 401, 200),
-
responseQueue.stream().map(HttpResponse::getCode).collect(Collectors.toList()));
+ assertThat(
+
responseQueue.stream().map(HttpResponse::getCode).collect(Collectors.toList()),
+ CoreMatchers.equalTo(Arrays.asList(200, 401, 200, 401, 200,
401, 200)));
Review Comment:
> @arturobernalg This worries me a little. I want to understand why the
behavior has changed.
The expectation in that assertion was effectively relying on the client
reusing Basic auth preemptively across unrelated path prefixes within the same
context (so it behaved almost host-wide). With my change we now keep preemptive
auth scoped to the authenticated path prefix, so when the request moves from
/yada/ back to /blah/ it no longer sends Authorization blindly and you see a
fresh 401/200 again.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]