Example #1
0
        public async Task AddIdentityResourcePropertyAsync()
        {
            using (var context = new IdentityServerConfigurationDbContext(_dbContextOptions, _storeOptions))
            {
                var identityResourceRepository = GetIdentityResourceRepository(context);

                //Generate random new identity resource without id
                var identityResource = IdentityResourceMock.GenerateRandomIdentityResource(0);

                //Add new identity resource
                await identityResourceRepository.AddIdentityResourceAsync(identityResource);

                //Get new identity resource
                var resource = await identityResourceRepository.GetIdentityResourceAsync(identityResource.Id);

                //Assert new identity resource
                resource.Should().BeEquivalentTo(identityResource, options => options.Excluding(o => o.Id));

                //Generate random new identity resource property
                var identityResourceProperty = IdentityResourceMock.GenerateRandomIdentityResourceProperty(0);

                //Add new identity resource property
                await identityResourceRepository.AddIdentityResourcePropertyAsync(resource.Id, identityResourceProperty);

                //Get new identity resource property
                var resourceProperty = await context.IdentityResourceProperties.Where(x => x.Id == identityResourceProperty.Id)
                                       .SingleOrDefaultAsync();

                resourceProperty.Should().BeEquivalentTo(identityResourceProperty,
                                                         options => options.Excluding(o => o.Id).Excluding(x => x.IdentityResource));
            }
        }
Example #2
0
        public async Task GetIdentityResourcePropertyAsync()
        {
            using (var context = new IdentityServerConfigurationDbContext(_dbContextOptions, _storeOptions))
            {
                var identityResourceRepository = GetIdentityResourceRepository(context);

                //Generate random new identity resource without id
                var identityResource = IdentityResourceMock.GenerateRandomIdentityResource(0);

                //Add new identity resource
                await identityResourceRepository.AddIdentityResourceAsync(identityResource);

                //Get new identity resource
                var resource = await identityResourceRepository.GetIdentityResourceAsync(identityResource.Id);

                //Assert new identity resource
                resource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id).Excluding(o => o.UserClaims));

                resource.UserClaims.ShouldBeEquivalentTo(identityResource.UserClaims,
                                                         option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id"))
                                                         .Excluding(x => x.SelectedMemberPath.EndsWith("IdentityResource")));

                //Generate random new identity resource property
                var identityResourceProperty = IdentityResourceMock.GenerateRandomIdentityResourceProperty(0);

                //Add new identity resource property
                await identityResourceRepository.AddIdentityResourcePropertyAsync(resource.Id, identityResourceProperty);

                //Get new identity resource property
                var resourceProperty = await identityResourceRepository.GetIdentityResourcePropertyAsync(identityResourceProperty.Id);

                resourceProperty.ShouldBeEquivalentTo(identityResourceProperty,
                                                      options => options.Excluding(o => o.Id).Excluding(x => x.IdentityResource));
            }
        }
Example #3
0
        public async Task GetIdentityResourcePropertyAsync()
        {
            using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore))
            {
                var identityResourceRepository = GetIdentityResourceRepository(context);

                //Generate random new identity resource without id
                var identityResource = IdentityResourceMock.GenerateRandomIdentityResource(0);

                //Add new identity resource
                await identityResourceRepository.AddIdentityResourceAsync(identityResource);

                //Get new identity resource
                var resource = await identityResourceRepository.GetIdentityResourceAsync(identityResource.Id);

                //Assert new identity resource
                resource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id));

                //Generate random new identity resource property
                var identityResourceProperty = IdentityResourceMock.GenerateRandomIdentityResourceProperty(0);

                //Add new identity resource property
                await identityResourceRepository.AddIdentityResourcePropertyAsync(resource.Id, identityResourceProperty);

                //Get new identity resource property
                var resourceProperty = await identityResourceRepository.GetIdentityResourcePropertyAsync(identityResourceProperty.Id);

                resourceProperty.ShouldBeEquivalentTo(identityResourceProperty,
                                                      options => options.Excluding(o => o.Id).Excluding(x => x.IdentityResource));
            }
        }