/// <summary> /// 获取全部资源 /// </summary> public async Task <Resources> GetAllResourcesAsync() { var identityResources = (await IdentityResourceService.GetAllAsync()).Where(t => t.Enabled == true).Select(ToResource); var apiResources = (await ApiResourceService.GetAllAsync()).Where(t => t.Enabled == true).Select(ToResource); return(new Resources(identityResources, apiResources)); }
public IdentityResourcesController(IdentityResourceService identityResourceService, IMapper mapper, ILogger <IdentityResourcesController> logger) { _identityResourceService = identityResourceService; _mapper = mapper; _logger = logger; }
public async Task RemoveIdentityResourceAsync() { using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore)) { IIdentityResourceRepository identityResourceRepository = new IdentityResourceRepository(context); var localizerIdentityResourceMock = new Mock <IIdentityResourceServiceResources>(); var localizerIdentityResource = localizerIdentityResourceMock.Object; IIdentityResourceService identityResourceService = new IdentityResourceService(identityResourceRepository, localizerIdentityResource); //Generate random new identity resource var identityResourceDto = IdentityResourceDtoMock.GenerateRandomIdentityResource(0); await identityResourceService.AddIdentityResourceAsync(identityResourceDto); //Get new identity resource var identityResource = await context.IdentityResources.Where(x => x.Name == identityResourceDto.Name).SingleOrDefaultAsync(); var newIdentityResourceDto = await identityResourceService.GetIdentityResourceAsync(identityResource.Id); //Assert new identity resource identityResourceDto.ShouldBeEquivalentTo(newIdentityResourceDto, options => options.Excluding(o => o.Id)); //Remove identity resource await identityResourceService.DeleteIdentityResourceAsync(newIdentityResourceDto); //Try Get Removed identity resource var removeIdentityResource = await context.IdentityResources.Where(x => x.Id == identityResource.Id) .SingleOrDefaultAsync(); //Assert removed identity resource removeIdentityResource.Should().BeNull(); } }
public ClientsController(ClientService clientService, IdentityResourceService identityResourceService, ApiScopeService apiScopeService, IMapper mapper, ILogger <ClientsController> logger) { _clientService = clientService; _identityResourceService = identityResourceService; _apiScopeService = apiScopeService; _mapper = mapper; _logger = logger; }
public void Setup() { IdentityResourceDataAccessMock = new Mock <IIdentityResourceDataAccess>(); IdentityResourceService = new IdentityResourceService(IdentityResourceDataAccessMock.Object); var connectionId = new ConnectionId(new ServerId(new ClusterId(1), new DnsEndPoint("localhost", 27017)), 2); var writeConcernErrorConstructor = typeof(WriteError).GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)[0]; var writeError = (WriteError)writeConcernErrorConstructor.Invoke(new object[] { ServerErrorCategory.DuplicateKey, 11000, "writeError", new BsonDocument("details", "writeError") }); MongoWriteException = new MongoWriteException(connectionId, writeError, null, null); }
public async Task UpdateIdentityResourceAsync() { using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore)) { IIdentityResourceRepository identityResourceRepository = new IdentityResourceRepository(context); var localizerIdentityResourceMock = new Mock <IIdentityResourceServiceResources>(); var localizerIdentityResource = localizerIdentityResourceMock.Object; IIdentityResourceService identityResourceService = new IdentityResourceService(identityResourceRepository, localizerIdentityResource); //Generate random new identity resource var identityResourceDto = IdentityResourceDtoMock.GenerateRandomIdentityResource(0); await identityResourceService.AddIdentityResourceAsync(identityResourceDto); //Get new identity resource var identityResource = await context.IdentityResources.Where(x => x.Name == identityResourceDto.Name).SingleOrDefaultAsync(); var newIdentityResourceDto = await identityResourceService.GetIdentityResourceAsync(identityResource.Id); //Assert new identity resource identityResourceDto.ShouldBeEquivalentTo(newIdentityResourceDto, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(identityResource).State = EntityState.Detached; //Generete new identity resuorce with added item id var updatedIdentityResource = IdentityResourceDtoMock.GenerateRandomIdentityResource(identityResource.Id); //Update identity resuorce await identityResourceService.UpdateIdentityResourceAsync(updatedIdentityResource); var updatedIdentityResourceDto = await identityResourceService.GetIdentityResourceAsync(identityResource.Id); //Assert updated identity resuorce updatedIdentityResource.ShouldBeEquivalentTo(updatedIdentityResourceDto, options => options.Excluding(o => o.Id)); } }
/// <summary> /// 查找身份资源列表 /// </summary> /// <param name="names">资源标识列表</param> public async Task <IEnumerable <IdentityResource> > FindIdentityResourcesByScopeAsync(IEnumerable <string> names) { var result = await IdentityResourceService.GetResources(names?.ToList()); return(result.Where(t => t.Enabled == true).Select(ToResource).ToList()); }
public IdentityResourceController(IdentityResourceService identityResourceService) { _identityResourceService = identityResourceService; }
public IdentityResourceController(IdentityResourceService service) { this.service = service; }
private IIdentityResourceService GetIdentityResourceService(IIdentityResourceRepository repository, IIdentityResourceServiceResources identityResourceServiceResources, IAuditEventLogger auditEventLogger) { IIdentityResourceService identityResourceService = new IdentityResourceService(repository, identityResourceServiceResources, auditEventLogger); return(identityResourceService); }
private IIdentityResourceService GetIdentityResourceService(IIdentityResourceRepository repository, IIdentityResourceServiceResources identityResourceServiceResources) { IIdentityResourceService identityResourceService = new IdentityResourceService(repository, identityResourceServiceResources); return(identityResourceService); }
private IIdentityResourceService <AdminDbContext> GetIdentityResourceService(IIdentityResourceRepository <AdminDbContext> repository, IIdentityResourceServiceResources identityResourceServiceResources) { IIdentityResourceService <AdminDbContext> identityResourceService = new IdentityResourceService <AdminDbContext>(repository, identityResourceServiceResources); return(identityResourceService); }