File tree Expand file tree Collapse file tree
test/DigestAuthenticator.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ public async Task Given_ADigestAuthEndpoint_When_ITryToGetInfo_Then_TheAuthMustB
4242 [ Fact ]
4343 public async Task Given_ADigestAuthEndpoint_When_ITryToInjectOwnClient_Then_TheAuthMustBeResolved ( )
4444 {
45+ bool proxyCalled = false ;
46+
4547 var loggerMock = Substitute . For < ILogger > ( ) ;
4648 loggerMock . BeginScope ( "DigestServerStub" ) ;
4749
@@ -50,13 +52,16 @@ public async Task Given_ADigestAuthEndpoint_When_ITryToInjectOwnClient_Then_TheA
5052
5153 RestClientOptions options = new RestClientOptions ( )
5254 {
53- MaxRedirects = 2
55+ Proxy = new TestProxy ( ( ) => proxyCalled = true )
5456 } ;
5557
5658 var client = _fixture . CreateInjectedOptionClient ( loggerMock , options ) ;
5759 var response = await client . ExecuteAsync ( request ) ;
5860
5961 response . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
6062 loggerMock . ReceivedWithAnyArgs ( ) . LogDebug ( "NONONO" ) ;
63+
64+ Assert . True ( proxyCalled , "Injected RestClientOptions.Proxy should be used in digest handshake." ) ;
65+
6166 }
6267}
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Net ;
5+ using System . Text ;
6+ using System . Threading . Tasks ;
7+
8+ namespace RestSharp . Authenticators . Digest . Tests . Fixtures ;
9+ internal class TestProxy : IWebProxy
10+ {
11+ private readonly Action _onProxyCalled ;
12+
13+ public TestProxy ( Action onProxyCalled )
14+ {
15+ _onProxyCalled = onProxyCalled ;
16+ }
17+
18+ public Uri GetProxy ( Uri destination )
19+ {
20+ _onProxyCalled ( ) ;
21+ return destination ;
22+ }
23+
24+ public bool IsBypassed ( Uri host ) => false ;
25+
26+ public ICredentials ? Credentials { get ; set ; }
27+ }
You can’t perform that action at this time.
0 commit comments