Browse Source

Modify test. UserId is a Guid type

pull/223/head
Christian Arenas 7 years ago
parent
commit
c9484a0834
3 changed files with 26 additions and 5 deletions
  1. +1
    -1
      test/Services/IntegrationTests/Services/Locations/LocationsScenarioBase.cs
  2. +4
    -3
      test/Services/IntegrationTests/Services/Locations/LocationsScenarios.cs
  3. +21
    -1
      test/Services/IntegrationTests/Services/Locations/LocationsTestsStartup.cs

+ 1
- 1
test/Services/IntegrationTests/Services/Locations/LocationsScenarioBase.cs View File

@ -27,7 +27,7 @@ namespace IntegrationTests.Services.Locations
return $"api/v1/locations/{id}";
}
public static string UserLocationBy(int id)
public static string UserLocationBy(Guid id)
{
return $"api/v1/locations/user/{id}";
}


+ 4
- 3
test/Services/IntegrationTests/Services/Locations/LocationsScenarios.cs View File

@ -7,6 +7,7 @@ using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using System;
namespace IntegrationTests.Services.Locations
{
@ -18,7 +19,7 @@ namespace IntegrationTests.Services.Locations
{
using (var server = CreateServer())
{
var userId = 1234;
var userId = new Guid("4611ce3f-380d-4db5-8d76-87a8689058ed");
var content = new StringContent(BuildLocationsRequest(-122.315752, 47.604610), UTF8Encoding.UTF8, "application/json");
// Expected result
@ -50,7 +51,7 @@ namespace IntegrationTests.Services.Locations
{
using (var server = CreateServer())
{
var userId = 1234;
var userId = new Guid("4611ce3f-380d-4db5-8d76-87a8689058ed");
var content = new StringContent(BuildLocationsRequest(-122.119998, 47.690876), UTF8Encoding.UTF8, "application/json");
// Expected result
@ -82,7 +83,7 @@ namespace IntegrationTests.Services.Locations
{
using (var server = CreateServer())
{
var userId = 1234;
var userId = new Guid("4611ce3f-380d-4db5-8d76-87a8689058ed");
var content = new StringContent(BuildLocationsRequest(-121.040360, 48.091631), UTF8Encoding.UTF8, "application/json");
// Expected result


+ 21
- 1
test/Services/IntegrationTests/Services/Locations/LocationsTestsStartup.cs View File

@ -3,7 +3,10 @@
using IntegrationTests.Middleware;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.eShopOnContainers.Services.Locations.API;
using System.Security.Claims;
using System.Threading.Tasks;
public class LocationsTestsStartup : Startup
{
@ -15,12 +18,29 @@
{
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
{
app.UseMiddleware<AutoAuthorizeMiddleware>();
app.UseMiddleware<LocationAuthorizeMiddleware>();
}
else
{
base.ConfigureAuth(app);
}
}
class LocationAuthorizeMiddleware
{
private readonly RequestDelegate _next;
public LocationAuthorizeMiddleware(RequestDelegate rd)
{
_next = rd;
}
public async Task Invoke(HttpContext httpContext)
{
var identity = new ClaimsIdentity("cookies");
identity.AddClaim(new Claim("sub", "4611ce3f-380d-4db5-8d76-87a8689058ed"));
httpContext.User.AddIdentity(identity);
await _next.Invoke(httpContext);
}
}
}
}

Loading…
Cancel
Save