Skip to content

Commit

Permalink
Using async Task instead of async void in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josephdecock committed Sep 19, 2024
1 parent 0f04d85 commit 1ed73c9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
7 changes: 4 additions & 3 deletions test/IdentityServer.UnitTests/Validation/IsLocalUrlTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Duende.IdentityServer.Configuration;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Services;
Expand Down Expand Up @@ -61,7 +62,7 @@ public class IsLocalUrlTests

[Theory]
[MemberData(nameof(TestCases))]
public async void GetAuthorizationContextAsync(string returnUrl, bool expected)
public async Task GetAuthorizationContextAsync(string returnUrl, bool expected)
{
var interactionService = new DefaultIdentityServerInteractionService(null, null, null, null, null, null, null,
GetReturnUrlParser(), new LoggerFactory().CreateLogger<DefaultIdentityServerInteractionService>());
Expand Down Expand Up @@ -105,7 +106,7 @@ public void GetIdentityServerRelativeUrl(string returnUrl, bool expected)

[Theory]
[MemberData(nameof(TestCases))]
public async void OidcReturnUrlParser_ParseAsync(string returnUrl, bool expected)
public async Task OidcReturnUrlParser_ParseAsync(string returnUrl, bool expected)
{
var oidcParser = GetOidcReturnUrlParser();
var actual = await oidcParser.ParseAsync(returnUrl);
Expand Down Expand Up @@ -138,7 +139,7 @@ public void ReturnUrlParser_IsValidReturnUrl(string returnUrl, bool expected)

[Theory]
[MemberData(nameof(TestCases))]
public async void ReturnUrlParser_ParseAsync(string returnUrl, bool expected)
public async Task ReturnUrlParser_ParseAsync(string returnUrl, bool expected)
{
var parser = GetReturnUrlParser();
var actual = await parser.ParseAsync(returnUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Duende.IdentityServer;
using Duende.IdentityServer.Configuration;
using Duende.IdentityServer.Validation;
Expand All @@ -31,7 +32,7 @@ public BasicAuthenticationSecretParsing()

[Fact]
[Trait("Category", Category)]
public async void EmptyContext()
public async Task EmptyContext()
{
var context = new DefaultHttpContext();

Expand All @@ -42,7 +43,7 @@ public async void EmptyContext()

[Fact]
[Trait("Category", Category)]
public async void Valid_BasicAuthentication_Request()
public async Task Valid_BasicAuthentication_Request()
{
var context = new DefaultHttpContext();

Expand All @@ -67,7 +68,7 @@ public async void Valid_BasicAuthentication_Request()
[InlineData("cl+ ient", "se+cret")]
[InlineData("cl+ ient", "se+ cret")]
[InlineData("client:urn", "secret")]
public async void Valid_BasicAuthentication_Request_in_various_Formats_Manual(string userName, string password)
public async Task Valid_BasicAuthentication_Request_in_various_Formats_Manual(string userName, string password)
{
Encoding encoding = Encoding.UTF8;
var context = new DefaultHttpContext();
Expand All @@ -94,7 +95,7 @@ public async void Valid_BasicAuthentication_Request_in_various_Formats_Manual(st
[InlineData("cl+ ient", "se+cret")]
[InlineData("cl+ ient", "se+ cret")]
[InlineData("client:urn", "secret")]
public async void Valid_BasicAuthentication_Request_in_various_Formats_IdentityModel(string userName, string password)
public async Task Valid_BasicAuthentication_Request_in_various_Formats_IdentityModel(string userName, string password)
{
Encoding encoding = Encoding.UTF8;
var context = new DefaultHttpContext();
Expand All @@ -112,7 +113,7 @@ public async void Valid_BasicAuthentication_Request_in_various_Formats_IdentityM

[Fact]
[Trait("Category", Category)]
public async void Valid_BasicAuthentication_Request_With_UserName_Only_And_Colon_For_Optional_ClientSecret()
public async Task Valid_BasicAuthentication_Request_With_UserName_Only_And_Colon_For_Optional_ClientSecret()
{
var context = new DefaultHttpContext();

Expand All @@ -129,7 +130,7 @@ public async void Valid_BasicAuthentication_Request_With_UserName_Only_And_Colon

[Fact]
[Trait("Category", Category)]
public async void BasicAuthentication_Request_With_Empty_Basic_Header()
public async Task BasicAuthentication_Request_With_Empty_Basic_Header()
{
var context = new DefaultHttpContext();

Expand All @@ -142,7 +143,7 @@ public async void BasicAuthentication_Request_With_Empty_Basic_Header()

[Fact]
[Trait("Category", Category)]
public async void Valid_BasicAuthentication_Request_ClientId_Too_Long()
public async Task Valid_BasicAuthentication_Request_ClientId_Too_Long()
{
var context = new DefaultHttpContext();

Expand All @@ -159,7 +160,7 @@ public async void Valid_BasicAuthentication_Request_ClientId_Too_Long()

[Fact]
[Trait("Category", Category)]
public async void Valid_BasicAuthentication_Request_ClientSecret_Too_Long()
public async Task Valid_BasicAuthentication_Request_ClientSecret_Too_Long()
{
var context = new DefaultHttpContext();

Expand All @@ -185,7 +186,7 @@ public async void Valid_BasicAuthentication_Request_ClientSecret_Too_Long()
[InlineData(107)]
[InlineData(108)]
[Trait("Category", Category)]
public async void Valid_BasicAuthentication_Request_Maximum_Url_Encoded_Values_Should_Work(int maxLength)
public async Task Valid_BasicAuthentication_Request_Maximum_Url_Encoded_Values_Should_Work(int maxLength)
{
var parser = CreateParser(maxLength);

Expand Down Expand Up @@ -229,7 +230,7 @@ private static BasicAuthenticationSecretParser CreateParser(int maxLength)
[InlineData(107)]
[InlineData(108)]
[Trait("Category", Category)]
public async void Valid_BasicAuthentication_Request_Authorization_Header_Too_Long_Should_Fail(int maxLength)
public async Task Valid_BasicAuthentication_Request_Authorization_Header_Too_Long_Should_Fail(int maxLength)
{
var parser = CreateParser(maxLength);

Expand All @@ -249,7 +250,7 @@ public async void Valid_BasicAuthentication_Request_Authorization_Header_Too_Lon

[Fact]
[Trait("Category", Category)]
public async void BasicAuthentication_Request_With_Empty_Basic_Header_Variation()
public async Task BasicAuthentication_Request_With_Empty_Basic_Header_Variation()
{
var context = new DefaultHttpContext();

Expand All @@ -262,7 +263,7 @@ public async void BasicAuthentication_Request_With_Empty_Basic_Header_Variation(

[Fact]
[Trait("Category", Category)]
public async void BasicAuthentication_Request_With_Unknown_Scheme()
public async Task BasicAuthentication_Request_With_Unknown_Scheme()
{
var context = new DefaultHttpContext();

Expand All @@ -275,7 +276,7 @@ public async void BasicAuthentication_Request_With_Unknown_Scheme()

[Fact]
[Trait("Category", Category)]
public async void BasicAuthentication_Request_With_Malformed_Credentials_NoBase64_Encoding()
public async Task BasicAuthentication_Request_With_Malformed_Credentials_NoBase64_Encoding()
{
var context = new DefaultHttpContext();

Expand All @@ -288,7 +289,7 @@ public async void BasicAuthentication_Request_With_Malformed_Credentials_NoBase6

[Fact]
[Trait("Category", Category)]
public async void BasicAuthentication_Request_With_Malformed_Credentials_Base64_Encoding_UserName_Only()
public async Task BasicAuthentication_Request_With_Malformed_Credentials_Base64_Encoding_UserName_Only()
{
var context = new DefaultHttpContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using Duende.IdentityServer;
using Duende.IdentityServer.Configuration;
using Duende.IdentityServer.Validation;
Expand All @@ -29,7 +30,7 @@ public ClientAssertionSecretParsing()
}

[Fact]
public async void EmptyContext()
public async Task EmptyContext()
{
var context = new DefaultHttpContext();
context.Request.Body = new MemoryStream();
Expand All @@ -41,7 +42,7 @@ public async void EmptyContext()
}

[Fact]
public async void Valid_ClientAssertion()
public async Task Valid_ClientAssertion()
{
var context = new DefaultHttpContext();

Expand All @@ -62,7 +63,7 @@ public async void Valid_ClientAssertion()
}

[Fact]
public async void Missing_ClientAssertionType()
public async Task Missing_ClientAssertionType()
{
var context = new DefaultHttpContext();

Expand All @@ -77,7 +78,7 @@ public async void Missing_ClientAssertionType()
}

[Fact]
public async void Missing_ClientAssertion()
public async Task Missing_ClientAssertion()
{
var context = new DefaultHttpContext();

Expand All @@ -92,7 +93,7 @@ public async void Missing_ClientAssertion()
}

[Fact]
public async void Malformed_PostBody()
public async Task Malformed_PostBody()
{
var context = new DefaultHttpContext();
var body = "malformed";
Expand All @@ -106,7 +107,7 @@ public async void Malformed_PostBody()
}

[Fact]
public async void ClientId_TooLong()
public async Task ClientId_TooLong()
{
var context = new DefaultHttpContext();

Expand All @@ -122,7 +123,7 @@ public async void ClientId_TooLong()
}

[Fact]
public async void ClientAssertion_TooLong()
public async Task ClientAssertion_TooLong()
{
var context = new DefaultHttpContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.IO;
using System.Text;
using System.Threading.Tasks;
using Duende.IdentityServer;
using Duende.IdentityServer.Configuration;
using Duende.IdentityServer.Validation;
Expand All @@ -30,7 +31,7 @@ public FormPostCredentialExtraction()

[Fact]
[Trait("Category", Category)]
public async void EmptyContext()
public async Task EmptyContext()
{
var context = new DefaultHttpContext();
context.Request.Body = new MemoryStream();
Expand All @@ -42,7 +43,7 @@ public async void EmptyContext()

[Fact]
[Trait("Category", Category)]
public async void Valid_PostBody()
public async Task Valid_PostBody()
{
var context = new DefaultHttpContext();

Expand All @@ -60,7 +61,7 @@ public async void Valid_PostBody()

[Fact]
[Trait("Category", Category)]
public async void ClientId_Too_Long()
public async Task ClientId_Too_Long()
{
var context = new DefaultHttpContext();

Expand All @@ -77,7 +78,7 @@ public async void ClientId_Too_Long()

[Fact]
[Trait("Category", Category)]
public async void ClientSecret_Too_Long()
public async Task ClientSecret_Too_Long()
{
var context = new DefaultHttpContext();

Expand All @@ -94,7 +95,7 @@ public async void ClientSecret_Too_Long()

[Fact]
[Trait("Category", Category)]
public async void Missing_ClientId()
public async Task Missing_ClientId()
{
var context = new DefaultHttpContext();

Expand All @@ -110,7 +111,7 @@ public async void Missing_ClientId()

[Fact]
[Trait("Category", Category)]
public async void Missing_ClientSecret()
public async Task Missing_ClientSecret()
{
var context = new DefaultHttpContext();

Expand All @@ -127,7 +128,7 @@ public async void Missing_ClientSecret()

[Fact]
[Trait("Category", Category)]
public async void Malformed_PostBody()
public async Task Malformed_PostBody()
{
var context = new DefaultHttpContext();

Expand Down

0 comments on commit 1ed73c9

Please sign in to comment.