Skip to content

Commit 947b46b

Browse files
committed
✅ Implements some tests.
1 parent 217c0bf commit 947b46b

2 files changed

Lines changed: 34 additions & 27 deletions

File tree

test/unitario/DigestAuthenticator.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PackageId>RestSharp.Authenticators.Digest.Tests</PackageId>
66
<RootNamespace>RestSharp.Authenticators.Digest.Tests</RootNamespace>
77
<GenerateFullPaths>true</GenerateFullPaths>
8-
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
98
</PropertyGroup>
109
<PropertyGroup>
1110
<OutputType>Exe</OutputType>
@@ -36,6 +35,7 @@
3635
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3736
<PrivateAssets>all</PrivateAssets>
3837
</PackageReference>
38+
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
3939
</ItemGroup>
4040
<ItemGroup>
4141
<ProjectReference Include="..\..\src\DigestAuthenticator\DigestAuthenticator.csproj" />

test/unitario/DigestTest.cs

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
1+
using System.Diagnostics;
42
using System.Net;
5-
using System.Text;
6-
using System.Threading.Tasks;
73
using FluentAssertions;
84
using Xunit;
95

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
1114
{
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()
1817
{
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")
2421
{
25-
var client = new RestClient("http://localhost:49896/api")
26-
{
27-
Authenticator = new DigestAuthenticator("eddie", "starwars123")
28-
};
22+
Authenticator = new DigestAuthenticator("eddie", "starwars123")
23+
};
2924

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");
3227

33-
var response = client.Execute(request);
28+
var response = client.Execute(request);
3429

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");
3744
}
3845
}

0 commit comments

Comments
 (0)