Removing duplicated AutoAuthorizeMiddleware

This commit is contained in:
CountNeuroman 2022-04-10 12:38:57 +03:00
parent 3af7133157
commit f0363e2586
8 changed files with 10 additions and 56 deletions

View File

@ -1,26 +0,0 @@
namespace Basket.FunctionalTests.Base;
class AutoAuthorizeMiddleware
{
public const string IDENTITY_ID = "9e3163b9-1ae6-4652-9dc6-7898ab7b7a00";
private readonly RequestDelegate _next;
public AutoAuthorizeMiddleware(RequestDelegate rd)
{
_next = rd;
}
public async Task Invoke(HttpContext httpContext)
{
var identity = new ClaimsIdentity("cookies");
identity.AddClaim(new Claim("sub", IDENTITY_ID));
identity.AddClaim(new Claim("unique_name", IDENTITY_ID));
identity.AddClaim(new Claim(ClaimTypes.Name, IDENTITY_ID));
httpContext.User.AddIdentity(identity);
await _next.Invoke(httpContext);
}
}

View File

@ -1,4 +1,4 @@
 using FunctionalTests.Middleware;
namespace Basket.FunctionalTests.Base namespace Basket.FunctionalTests.Base
{ {

View File

@ -29,6 +29,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Tests\Services\Application.FunctionalTests\Application.FunctionalTests.csproj" />
<ProjectReference Include="..\Basket.API\Basket.API.csproj" /> <ProjectReference Include="..\Basket.API\Basket.API.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,6 @@
namespace Basket.FunctionalTests; using FunctionalTests.Middleware;
namespace Basket.FunctionalTests;
public class BasketScenarios public class BasketScenarios
: BasketScenarioBase : BasketScenarioBase

View File

@ -1,26 +0,0 @@
namespace Ordering.FunctionalTests;
class AutoAuthorizeMiddleware
{
public const string IDENTITY_ID = "9e3163b9-1ae6-4652-9dc6-7898ab7b7a00";
private readonly RequestDelegate _next;
public AutoAuthorizeMiddleware(RequestDelegate rd)
{
_next = rd;
}
public async Task Invoke(HttpContext httpContext)
{
var identity = new ClaimsIdentity("cookies");
identity.AddClaim(new Claim("sub", IDENTITY_ID));
identity.AddClaim(new Claim("unique_name", IDENTITY_ID));
identity.AddClaim(new Claim(ClaimTypes.Name, IDENTITY_ID));
httpContext.User.AddIdentity(identity);
await _next.Invoke(httpContext);
}
}

View File

@ -28,6 +28,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Tests\Services\Application.FunctionalTests\Application.FunctionalTests.csproj" />
<ProjectReference Include="..\..\..\Web\WebMVC\WebMVC.csproj" /> <ProjectReference Include="..\..\..\Web\WebMVC\WebMVC.csproj" />
<ProjectReference Include="..\Ordering.API\Ordering.API.csproj" /> <ProjectReference Include="..\Ordering.API\Ordering.API.csproj" />
<ProjectReference Include="..\Ordering.Domain\Ordering.Domain.csproj" /> <ProjectReference Include="..\Ordering.Domain\Ordering.Domain.csproj" />

View File

@ -1,4 +1,6 @@
namespace Ordering.FunctionalTests; using FunctionalTests.Middleware;
namespace Ordering.FunctionalTests;
public class OrderingTestsStartup : Startup public class OrderingTestsStartup : Startup
{ {

View File

@ -1,6 +1,6 @@
namespace FunctionalTests.Middleware; namespace FunctionalTests.Middleware;
class AutoAuthorizeMiddleware public class AutoAuthorizeMiddleware
{ {
public const string IDENTITY_ID = "9e3163b9-1ae6-4652-9dc6-7898ab7b7a00"; public const string IDENTITY_ID = "9e3163b9-1ae6-4652-9dc6-7898ab7b7a00";