public async Task ShouldAddNewApiSecret()
        {
            var command = ApiResourceFaker.GenerateApiResource().Generate();

            await _apiResourceAppService.Save(command);

            var secret = ApiResourceFaker.GenerateSaveClientSecret(command.Name);

            await _apiResourceAppService.SaveSecret(secret);

            _database.ApiResources.FirstOrDefault(f => f.Name == command.Name).Should().NotBeNull();
            _database.ApiSecrets.Include(i => i.ApiResource).Where(f => f.ApiResource.Name == command.Name).Should().NotBeNull();
        }
Exemple #2
0
        public async Task <ActionResult <DefaultResponse <bool> > > SaveSecret([FromBody] SaveApiSecretViewModel model)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(false));
            }
            await _apiResourceAppService.SaveSecret(model);

            return(Response(true));
        }
        public async Task <ActionResult <IEnumerable <Secret> > > SaveSecret(string resource, [FromBody] SaveApiSecretViewModel model)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(ModelStateErrorResponseError());
            }

            model.ResourceName = resource;
            await _apiResourceAppService.SaveSecret(model);

            var secrets = await _apiResourceAppService.GetSecrets(resource);

            return(ResponsePost(nameof(Secrets), new { resource }, secrets));
        }