forked from ddrilling/AsbCloudServer
32 lines
903 B
C#
32 lines
903 B
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Claims;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AsbCloudWebApi.Tests.ControllersTests
|
|
{
|
|
static class ControllerExtentions
|
|
{
|
|
public static void AddUser(this ControllerBase controller)
|
|
{
|
|
var claims = new Claim[] { new Claim("idCompany", "1") };
|
|
controller.AddUser(claims);
|
|
}
|
|
|
|
public static void AddUser(this ControllerBase controller, Claim[] claims)
|
|
{
|
|
var identity = new ClaimsIdentity(claims, "mock");
|
|
var user = new ClaimsPrincipal(identity);
|
|
|
|
controller.ControllerContext = new ControllerContext()
|
|
{
|
|
HttpContext = new DefaultHttpContext() { User = user }
|
|
};
|
|
}
|
|
}
|
|
}
|