public async Task GetApiSecretAsync()
        {
            using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore))
            {
                var apiResourceRepository = GetApiResourceRepository(context);

                //Generate random new api resource
                var apiResource = ApiResourceMock.GenerateRandomApiResource(0);

                //Add new api resource
                await apiResourceRepository.AddApiResourceAsync(apiResource);

                //Generate random new api secret
                var apiSecret = ApiResourceMock.GenerateRandomApiSecret(0);

                //Add new api secret
                await apiResourceRepository.AddApiSecretAsync(apiResource.Id, apiSecret);

                //Get new api secret
                var newApiSecret = await apiResourceRepository.GetApiSecretAsync(apiSecret.Id);

                //Assert new api secret
                newApiSecret.ShouldBeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id));
            }
        }
        public async Task DeleteApiSecretAsync()
        {
            using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore))
            {
                var apiResourceRepository = GetApiResourceRepository(context);

                //Generate random new api resource
                var apiResource = ApiResourceMock.GenerateRandomApiResource(0);

                //Add new api resource
                await apiResourceRepository.AddApiResourceAsync(apiResource);

                //Generate random new api scope
                var apiSecret = ApiResourceMock.GenerateRandomApiSecret(0);

                //Add new api secret
                await apiResourceRepository.AddApiSecretAsync(apiResource.Id, apiSecret);

                //Get new api resource
                var newApiSecret = await context.ApiSecrets.Where(x => x.Id == apiSecret.Id).SingleOrDefaultAsync();

                //Assert new api resource
                newApiSecret.ShouldBeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id));

                //Try delete it
                await apiResourceRepository.DeleteApiSecretAsync(newApiSecret);

                //Get deleted api secret
                var deletedApiSecret = await context.ApiSecrets.Where(x => x.Id == newApiSecret.Id).SingleOrDefaultAsync();

                //Assert if it exist
                deletedApiSecret.Should().BeNull();
            }
        }
Beispiel #3
0
        public async Task GetApiSecretAsync()
        {
            using (var context = new IdentityServerConfigurationDbContext(_dbContextOptions, _storeOptions))
            {
                var apiResourceRepository = GetApiResourceRepository(context);

                //Generate random new api resource
                var apiResource = ApiResourceMock.GenerateRandomApiResource(0);

                //Add new api resource
                await apiResourceRepository.AddApiResourceAsync(apiResource);

                //Generate random new api secret
                var apiSecret = ApiResourceMock.GenerateRandomApiSecret(0);

                //Add new api secret
                await apiResourceRepository.AddApiSecretAsync(apiResource.Id, apiSecret);

                //Get new api secret
                var newApiSecret = await apiResourceRepository.GetApiSecretAsync(apiSecret.Id);

                //Assert new api secret
                newApiSecret.Should().BeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id)
                                                     .Excluding(o => o.ApiResource.Secrets)
                                                     .Excluding(o => o.ApiResource.UserClaims)
                                                     .Excluding(o => o.ApiResource.Scopes));
            }
        }
Beispiel #4
0
        public async Task DeleteApiSecretAsync()
        {
            IApiResourceRepository apiResourceRepository = new ApiResourceDapperRepository(_configuration);

            //Generate random new api resource
            var apiResource = ApiResourceMock.GenerateRandomApiResource();

            //Add new api resource
            var apiResourceId = await apiResourceRepository.AddApiResourceAsync(apiResource);

            //Generate random new api scope
            var apiSecret = ApiResourceMock.GenerateRandomApiSecret();

            //Add new api secret
            var apiSecretId = await apiResourceRepository.AddApiSecretAsync(apiResourceId, apiSecret);

            //Get new api resource
            var newApiSecret = await apiResourceRepository.GetApiSecretAsync(apiSecretId);

            //Assert new api resource
            newApiSecret.ShouldBeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id).Excluding(x => x.ApiResource).Excluding(x => x.Expiration));

            //Try delete it
            await apiResourceRepository.DeleteApiSecretAsync(newApiSecret);

            //Get deleted api secret
            var deletedApiSecret = await apiResourceRepository.GetApiSecretAsync(newApiSecret.Id);

            //Assert if it exist
            deletedApiSecret.Should().BeNull();
        }
Beispiel #5
0
        public void CanMapApiSecretToModel()
        {
            //Generate entity
            var apiSecret = ApiResourceMock.GenerateRandomApiSecret(1);

            //Try map to DTO
            var apiSecretsDto = apiSecret.ToModel();

            //Assert
            apiSecretsDto.Should().NotBeNull();

            apiSecret.Should().BeEquivalentTo(apiSecretsDto);

            apiSecret.Id.Should().Be(apiSecretsDto.ApiSecretId);
        }
Beispiel #6
0
        public void CanMapApiSecretToModel()
        {
            //Generate entity
            var apiSecret = ApiResourceMock.GenerateRandomApiSecret(1);

            //Try map to DTO
            var apiSecretsDto = apiSecret.ToModel();

            //Assert
            apiSecretsDto.Should().NotBeNull();

            apiSecret.ShouldBeEquivalentTo(apiSecretsDto, options =>
                                           options.Excluding(o => o.ApiResource)
                                           .Excluding(o => o.Created)
                                           .Excluding(o => o.Id));

            apiSecret.Id.Should().Be(apiSecretsDto.ApiSecretId);
        }
        public void CanMapApiSecretToModel()
        {
            //Generate entity
            var apiSecret = ApiResourceMock.GenerateRandomApiSecret(1);

            //Try map to DTO
            var apiSecretDto = apiSecret.ToModel();

            //Assert
            apiSecretDto.Should().NotBeNull();

            apiSecret.Should().BeEquivalentTo(apiSecretDto, options =>
                                              options.Excluding(o => o.Created)
                                              .Excluding(o => o.ApiSecretId)
                                              .Excluding(o => o.ApiResourceName)
                                              .Excluding(o => o.TypeList)
                                              .Excluding(o => o.HashType)
                                              .Excluding(o => o.HashTypes)
                                              .Excluding(o => o.ApiResourceSecrets)
                                              .Excluding(o => o.TotalCount)
                                              .Excluding(o => o.PageSize));

            apiSecret.Id.Should().Be(apiSecretDto.ApiSecretId);
        }