|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
| 1 | +using System.Diagnostics; |
4 | 2 | using System.Net; |
5 | | -using System.Text; |
6 | | -using System.Threading.Tasks; |
7 | 3 | using FluentAssertions; |
8 | 4 | using Xunit; |
9 | 5 |
|
10 | | -namespace RestSharp.Authenticators.Digest.Tests |
| 6 | +namespace RestSharp.Authenticators.Digest.Tests; |
| 7 | + |
| 8 | +/// <summary> |
| 9 | +/// The integration tests for <see cref="DigestAuthenticator" />. |
| 10 | +/// </summary> |
| 11 | +[Trait("Category", "IntegrationTests")] |
| 12 | +[Trait("Class", nameof(DigestAuthenticator))] |
| 13 | +public class DigestTest |
11 | 14 | { |
12 | | - /// <summary> |
13 | | - /// The integration tests for <see cref="DigestAuthenticator"/>. |
14 | | - /// </summary> |
15 | | - [Trait("Category", "IntegrationTests")] |
16 | | - [Trait("Class", nameof(DigestAuthenticator))] |
17 | | - public class DigestTest |
| 15 | + [SkippableFact] |
| 16 | + public void Given_ADigestAuthEndpoint_When_ITryToGetInfo_Then_TheAuthMustBeResolved() |
18 | 17 | { |
19 | | - /// <summary> |
20 | | - /// Given an digest auth endpoint, When I try to get info, Then the auth must be resolved. |
21 | | - /// </summary> |
22 | | - [Fact] |
23 | | - public void Given_AnDigestAuthEndpoint_When_ITryToGetInfo_Then_TheAuthMustBeResolved() |
| 18 | + Skip.IfNot(Debugger.IsAttached); |
| 19 | + |
| 20 | + var client = new RestClient("http://localhost:49896/api") |
24 | 21 | { |
25 | | - var client = new RestClient("http://localhost:49896/api") |
26 | | - { |
27 | | - Authenticator = new DigestAuthenticator("eddie", "starwars123") |
28 | | - }; |
| 22 | + Authenticator = new DigestAuthenticator("eddie", "starwars123") |
| 23 | + }; |
29 | 24 |
|
30 | | - var request = new RestRequest("values", Method.GET); |
31 | | - request.AddHeader("Content-Type", "application/json"); |
| 25 | + var request = new RestRequest("values", Method.GET); |
| 26 | + request.AddHeader("Content-Type", "application/json"); |
32 | 27 |
|
33 | | - var response = client.Execute(request); |
| 28 | + var response = client.Execute(request); |
34 | 29 |
|
35 | | - response.StatusCode.Should().Be(HttpStatusCode.OK); |
36 | | - } |
| 30 | + response.StatusCode.Should().Be(HttpStatusCode.OK); |
| 31 | + } |
| 32 | + |
| 33 | + [Theory] |
| 34 | + [InlineData( |
| 35 | + "Digest realm=\"test - realm\", nonce=\"2021 - 12 - 21 13:40:54.513311Z f152e55bf3d14e28b90f47db5dbd8afb\", qop=\"auth\", algorithm=MD5")] |
| 36 | + [InlineData( |
| 37 | + "realm=\"test - realm\", nonce=\"2021 - 12 - 21 13:40:54.513311Z f152e55bf3d14e28b90f47db5dbd8afb\", qop=\"auth\", algorithm=MD5")] |
| 38 | + public void Given_ADigestAuthenticateHeader_When_ITryCreateObject_Then_AllPropsMustBeFilled(string header) |
| 39 | + { |
| 40 | + var digestHeader = new DigestHeader(header); |
| 41 | + digestHeader.Nonce.Should().Be("2021 - 12 - 21 13:40:54.513311Z f152e55bf3d14e28b90f47db5dbd8afb"); |
| 42 | + digestHeader.Qop.Should().Be("auth"); |
| 43 | + digestHeader.Realm.Should().Be("test - realm"); |
37 | 44 | } |
38 | 45 | } |
0 commit comments