|
@@ -26,10 +26,11 @@ public class TestBase
|
|
|
public readonly IFixture _fixture;
|
|
|
private readonly IServiceScopeFactory _scopeFactory;
|
|
|
public readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
+ public readonly IThirdIdentiyService _thirdIdentiyService;
|
|
|
|
|
|
- public TestBase(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor)
|
|
|
+ public TestBase(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService)
|
|
|
{
|
|
|
-
|
|
|
+ _thirdIdentiyService = thirdIdentiyService;
|
|
|
_fixture = new Fixture();
|
|
|
_accountRepository = accountRepository;
|
|
|
_roleRepository = roleRepository;
|
|
@@ -47,6 +48,7 @@ public class TestBase
|
|
|
httpContextAccessor.HttpContext = new DefaultHttpContext();
|
|
|
SetZuoXi();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void SetPaiDanYuan()
|
|
@@ -104,6 +106,7 @@ public class TestBase
|
|
|
d => d.Includes(x => x.Roles)).GetAwaiter().GetResult();
|
|
|
}
|
|
|
var user = _userRepository.GetAsync(account.Id).GetAwaiter().GetResult();
|
|
|
+ var third = _thirdIdentiyService.GetTokenAsync(new Share.Dtos.Snapshot.ThirdTokenDto());
|
|
|
|
|
|
List<Claim> userClaims = [
|
|
|
new(JwtClaimTypes.Subject, account.Id),
|
|
@@ -117,6 +120,7 @@ public class TestBase
|
|
|
new(AppClaimTypes.DepartmentAreaName, user.Organization?.AreaName ?? string.Empty),
|
|
|
new(AppClaimTypes.DepartmentLevel, user.Organization?.Level.ToString() ?? string.Empty),
|
|
|
new(AppClaimTypes.AreaId, user.OrgId?.GetHigherOrgId() ?? string.Empty),
|
|
|
+ new(AppClaimTypes.OpenId, third.Result.OpenId ?? string.Empty),
|
|
|
];
|
|
|
ClaimsIdentity identity = new ClaimsIdentity(userClaims);
|
|
|
var principal = new ClaimsPrincipal(identity);
|