예제 #1
0
        public async Task <ActionResult <Client> > Post([FromBody] SaveClientViewModel client)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(ModelStateErrorResponseError());
            }

            await _clientAppService.Save(client);

            var newClient = await _clientAppService.GetClientDetails(client.ClientId);

            return(ResponsePost(nameof(GetClient), new { client = client.ClientId }, newClient));
        }
예제 #2
0
        public async Task Should_Update_Client()
        {
            var command = ClientViewModelFaker.GenerateSaveClient().Generate();

            await _clientAppService.Save(command);

            _database.Clients.FirstOrDefault(s => s.ClientId == command.ClientId).Should().NotBeNull();
            _database.ClientPostLogoutRedirectUris.Any().Should().BeTrue();

            InMemoryData.DetachAll();

            var updateCommand = ClientFaker.GenerateClient().Generate();
            await _clientAppService.Update(command.ClientId, updateCommand);

            var updatedClient = await _clientAppService.GetClientDetails(updateCommand.ClientId);

            updatedClient.AllowedCorsOrigins.Should().Contain(s => updateCommand.AllowedCorsOrigins.Contains(s));
            updatedClient.AllowedCorsOrigins.Count.Should().Be(updatedClient.AllowedCorsOrigins.Count);

            updatedClient.ClientSecrets.Should().Contain(s => updateCommand.ClientSecrets.Contains(s));
            updatedClient.ClientSecrets.Count.Should().Be(updatedClient.ClientSecrets.Count);

            updatedClient.AllowedScopes.Should().Contain(s => updateCommand.AllowedScopes.Contains(s));
            updatedClient.AllowedScopes.Count.Should().Be(updatedClient.AllowedScopes.Count);
        }
예제 #3
0
        public async Task <ActionResult <Client> > Post([FromBody] SaveClientWithLogoViewModel client)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(ModelStateErrorResponseError());
            }

            if (client.Logo != null)
            {
                //client.Logo.Normalize();
                client.Logo.VirtualLocation = "images";
                client.LogoUri = await _storage.Upload(client.Logo);
            }
            await _clientAppService.Save(client);

            var newClient = await _clientAppService.GetClientDetails(client.ClientId);

            return(ResponsePost(nameof(GetClient), new { client = client.ClientId }, newClient));
        }