-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Diagnostics; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace RestSharp.Authenticators.Digest.Tests | ||
namespace RestSharp.Authenticators.Digest.Tests; | ||
|
||
/// <summary> | ||
/// The integration tests for <see cref="DigestAuthenticator" />. | ||
/// </summary> | ||
[Trait("Category", "IntegrationTests")] | ||
[Trait("Class", nameof(DigestAuthenticator))] | ||
public class DigestTest | ||
{ | ||
/// <summary> | ||
/// The integration tests for <see cref="DigestAuthenticator"/>. | ||
/// </summary> | ||
[Trait("Category", "IntegrationTests")] | ||
[Trait("Class", nameof(DigestAuthenticator))] | ||
public class DigestTest | ||
[SkippableFact] | ||
public void Given_ADigestAuthEndpoint_When_ITryToGetInfo_Then_TheAuthMustBeResolved() | ||
{ | ||
/// <summary> | ||
/// Given an digest auth endpoint, When I try to get info, Then the auth must be resolved. | ||
/// </summary> | ||
[Fact] | ||
public void Given_AnDigestAuthEndpoint_When_ITryToGetInfo_Then_TheAuthMustBeResolved() | ||
Skip.IfNot(Debugger.IsAttached); | ||
|
||
var client = new RestClient("http://localhost:49896/api") | ||
{ | ||
var client = new RestClient("http://localhost:49896/api") | ||
{ | ||
Authenticator = new DigestAuthenticator("eddie", "starwars123") | ||
}; | ||
Authenticator = new DigestAuthenticator("eddie", "starwars123") | ||
}; | ||
|
||
var request = new RestRequest("values", Method.GET); | ||
request.AddHeader("Content-Type", "application/json"); | ||
var request = new RestRequest("values", Method.GET); | ||
request.AddHeader("Content-Type", "application/json"); | ||
|
||
var response = client.Execute(request); | ||
var response = client.Execute(request); | ||
|
||
response.StatusCode.Should().Be(HttpStatusCode.OK); | ||
} | ||
response.StatusCode.Should().Be(HttpStatusCode.OK); | ||
} | ||
|
||
[Theory] | ||
[InlineData( | ||
"Digest realm=\"test - realm\", nonce=\"2021 - 12 - 21 13:40:54.513311Z f152e55bf3d14e28b90f47db5dbd8afb\", qop=\"auth\", algorithm=MD5")] | ||
[InlineData( | ||
"realm=\"test - realm\", nonce=\"2021 - 12 - 21 13:40:54.513311Z f152e55bf3d14e28b90f47db5dbd8afb\", qop=\"auth\", algorithm=MD5")] | ||
public void Given_ADigestAuthenticateHeader_When_ITryCreateObject_Then_AllPropsMustBeFilled(string header) | ||
{ | ||
var digestHeader = new DigestHeader(header); | ||
digestHeader.Nonce.Should().Be("2021 - 12 - 21 13:40:54.513311Z f152e55bf3d14e28b90f47db5dbd8afb"); | ||
digestHeader.Qop.Should().Be("auth"); | ||
digestHeader.Realm.Should().Be("test - realm"); | ||
} | ||
} |