-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor dependencies and improve thread safety (#65)
Removed unused JWT and Azure Functions Worker dependencies in `Program.cs` and `SampleIsolatedFunctions.V4.csproj`. Updated authentication scheme in `TestFunction.cs`. Improved thread safety in `FunctionsAuthorizationProvider.cs` and `FunctionsAuthorizationMetadataMiddleware.cs` using `string.Intern` and `KeyedMonitor`. Upgraded `Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore` to version `1.3.2`. Added `ConcurrentTests` to test middleware concurrency. Related issues: #62, #64 Co-authored-by: Arturo Martinez <[email protected]>
- Loading branch information
Showing
8 changed files
with
80 additions
and
31 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
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
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// <copyright file="IntegrationTests.cs" company="DarkLoop" author="Arturo Martinez"> | ||
// Copyright (c) DarkLoop. All rights reserved. | ||
// </copyright> | ||
|
||
using System.Net; | ||
|
||
namespace Isolated.Tests | ||
{ | ||
[TestClass] | ||
public class ConcurrentTests | ||
{ | ||
[TestMethod] | ||
[Ignore("This is to test middleware concurrency")] | ||
public async Task TestFunctionAuthorizationMetadataCollectionAsync() | ||
{ | ||
// Arrange | ||
var client = new HttpClient { BaseAddress = new Uri("http://localhost:7005/") }; | ||
|
||
// Act | ||
var message1 = new HttpRequestMessage(HttpMethod.Get, "api/testfunction"); | ||
var message2 = new HttpRequestMessage(HttpMethod.Get, "api/testfunction"); | ||
var message3 = new HttpRequestMessage(HttpMethod.Get, "api/testfunction"); | ||
var message4 = new HttpRequestMessage(HttpMethod.Get, "api/testfunction"); | ||
var request1 = client.SendAsync(message1); | ||
var request2 = client.SendAsync(message2); | ||
var request3 = client.SendAsync(message3); | ||
var request4 = client.SendAsync(message4); | ||
|
||
// Assert | ||
await Task.WhenAll(request1, request2, request3, request4); | ||
Assert.AreEqual(HttpStatusCode.Unauthorized, request1.Result.StatusCode); | ||
Assert.AreEqual(HttpStatusCode.Unauthorized, request2.Result.StatusCode); | ||
Assert.AreEqual(HttpStatusCode.Unauthorized, request3.Result.StatusCode); | ||
Assert.AreEqual(HttpStatusCode.Unauthorized, request4.Result.StatusCode); | ||
} | ||
} | ||
} |