using Hotline.Application.Tests.Infrastructure;
using Hotline.Identity.Accounts;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Authentication;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using XF.Domain.Authentications;
using XF.Domain.Dependency;
using XF.Domain.Repository;
namespace Hotline.Application.Tests.Controller;
public class DefaultHttpContextAccessor : ISessionContext, IScopeDependency
{
private HttpContext _content = new DefaultHttpContext();
private HttpContext GetContext()
{
var context = new DefaultHttpContext();
//var openId = new Claim(AppClaimTypes.OpenId, "测试生成的OpenId");
var id = new ClaimsIdentity("身份");
//id.AddClaim(openId);
context.User = new ClaimsPrincipal(id);
//OpenId = context.User.FindFirstValue(AppClaimTypes.OpenId);
return context;
}
public HttpContext? HttpContext { get => GetContext(); set => _content = value; }
public string? OpenId { get { return TestSessionConstants.OpenId; } set { } }
///
/// Id of current tenant or null for host
///
public string? UserId
{
get
{
return TestSessionConstants.UserId;
}
init { }
}
///
/// Id of current user or throw Exception for guest
///
///
public string RequiredUserId { get { return TestSessionConstants.UserId; } }
public string? UserName { get { return TestSessionConstants.UserName; } init { } }
public string? Phone { get; init; }
///
/// Roles
///
public string[] Roles { get { return TestSessionConstants.Roles; } init { } }
public string? OrgId { get { return TestSessionConstants.OrgId; } init { } }
public string RequiredOrgId { get { return TestSessionConstants.OrgId; } }
public string? OrgName { get; init; }
public int OrgLevel { get; init; }
public string? OrgAreaCode { get; init; }
public bool OrgIsCenter { get; init; }
///
/// 部门行政区划名称
///
public string? OrgAreaName { get; init; }
public string? AreaId { get; init; }
public string? ClientId { get; init; }
///
/// 工号
///
public string? StaffNo { get; init; }
}