public async Task AddClientClaimAsync()
        {
            using (var context = new IdentityServerConfigurationDbContext(_dbContextOptions, _storeOptions))
            {
                var clientRepository = GetClientRepository(context);

                //Generate random new client without id
                var client = ClientMock.GenerateRandomClient(0);

                //Add new client
                await clientRepository.AddClientAsync(client);

                //Get new client
                var clientEntity = await clientRepository.GetClientAsync(client.Id);

                //Assert new client
                ClientAssert(clientEntity, client);

                //Generate random new Client Claim
                var clientClaim = ClientMock.GenerateRandomClientClaim(0);

                //Add new client claim
                await clientRepository.AddClientClaimAsync(clientEntity.Id, clientClaim);

                //Get new client claim
                var newClientClaim =
                    await context.ClientClaims.Where(x => x.Id == clientClaim.Id).SingleOrDefaultAsync();

                newClientClaim.Should().BeEquivalentTo(clientClaim,
                                                       options => options.Excluding(o => o.Id).Excluding(x => x.Client));
            }
        }
Esempio n. 2
0
        public async Task AddClientClaimAsync()
        {
            IClientRepository clientRepository = new ClientDapperRepository(_configuration);

            //Generate random new client without id
            var client = ClientMock.GenerateRandomClient();

            //Add new client
            var clientId = await clientRepository.AddClientAsync(client);

            //Get new client
            var clientEntity = await clientRepository.GetClientAsync(clientId);

            //Assert new client
            clientEntity.ShouldBeEquivalentTo(client, options => options.Excluding(o => o.Id)
                                              .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "AllowedGrantTypes\\[.+\\].Id"))
                                              .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "RedirectUris\\[.+\\].Id"))
                                              .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "PostLogoutRedirectUris\\[.+\\].Id"))
                                              .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "AllowedScopes\\[.+\\].Id"))
                                              .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "IdentityProviderRestrictions\\[.+\\].Id"))
                                              .Excluding(x => Regex.IsMatch(x.SelectedMemberPath, "AllowedCorsOrigins\\[.+\\].Id")));

            //Generate random new Client Claim
            var clientClaim = ClientMock.GenerateRandomClientClaim();

            //Add new client claim
            var clientClaimId = await clientRepository.AddClientClaimAsync(clientEntity.Id, clientClaim);

            //Get new client claim
            var newClientClaim = await clientRepository.GetClientClaimAsync(clientClaimId);

            newClientClaim.ShouldBeEquivalentTo(clientClaim, options => options.Excluding(o => o.Id).Excluding(x => x.Client));
        }
        public async Task GetClientClaimAsync()
        {
            using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore))
            {
                IClientRepository clientRepository = new ClientRepository(context);

                //Generate random new client without id
                var client = ClientMock.GenerateRandomClient(0);

                //Add new client
                await clientRepository.AddClientAsync(client);

                //Get new client
                var clientEntity = await clientRepository.GetClientAsync(client.Id);

                //Assert new client
                clientEntity.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id));

                //Generate random client claim
                var clientClaim = ClientMock.GenerateRandomClientClaim(0);

                //Add new client claim
                await clientRepository.AddClientClaimAsync(clientEntity.Id, clientClaim);

                //Get new client claim
                var newClientClaim = await clientRepository.GetClientClaimAsync(clientClaim.Id);

                newClientClaim.Should().BeEquivalentTo(clientClaim,
                                                       options => options.Excluding(o => o.Id).Excluding(x => x.Client));
            }
        }
Esempio n. 4
0
        public void CanMapClientClaimToModel()
        {
            var clientClaim = ClientMock.GenerateRandomClientClaim(0);

            var clientClaimsDto = clientClaim.ToModel();

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

            clientClaim.Should().BeEquivalentTo(clientClaimsDto);
        }
Esempio n. 5
0
        public void GetStandardClaims()
        {
            IClientRepository clientRepository = new ClientDapperRepository(_configuration);

            //Try get some existing claims
            var randomClientClaim = ClientMock.GenerateRandomClientClaim();

            var grantTypes = clientRepository.GetStandardClaims(randomClientClaim.Type);

            grantTypes.Contains(randomClientClaim.Type).Should().Be(true);
        }
        public void GetStandardClaims()
        {
            using (var context = new IdentityServerConfigurationDbContext(_dbContextOptions, _storeOptions))
            {
                var clientRepository = GetClientRepository(context);

                //Try get some existing claims
                var randomClientClaim = ClientMock.GenerateRandomClientClaim(0);

                var grantTypes = clientRepository.GetStandardClaims(randomClientClaim.Type);
                grantTypes.Contains(randomClientClaim.Type).Should().Be(true);
            }
        }
        public void GetStandardClaims()
        {
            using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore))
            {
                IClientRepository clientRepository = new ClientRepository(context);

                //Try get some existing claims
                var randomClientClaim = ClientMock.GenerateRandomClientClaim(0);

                var grantTypes = clientRepository.GetStandardClaims(randomClientClaim.Type);
                grantTypes.Contains(randomClientClaim.Type).Should().Be(true);
            }
        }
Esempio n. 8
0
        public void CanMapClientClaimToModel()
        {
            var clientClaim = ClientMock.GenerateRandomClientClaim(0);

            var clientClaimsDto = clientClaim.ToModel();

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

            clientClaim.ShouldBeEquivalentTo(clientClaimsDto, options =>
                                             options.Excluding(o => o.Id)
                                             .Excluding(o => o.Client));
        }
        public void CanMapClientClaimToModel()
        {
            var clientClaim = ClientMock.GenerateRandomClientClaim(0);

            var clientClaimDto = clientClaim.ToModel();

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

            clientClaim.Should().BeEquivalentTo(clientClaimDto, options =>
                                                options.Excluding(o => o.ClientClaims)
                                                .Excluding(o => o.ClientClaimId)
                                                .Excluding(o => o.ClientName)
                                                .Excluding(o => o.PageSize)
                                                .Excluding(o => o.TotalCount)
                                                .Excluding(o => o.ClientId));
        }
        public async Task DeleteClientClaimAsync()
        {
            using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore))
            {
                IClientRepository clientRepository = new ClientRepository(context);

                //Generate random new client without id
                var client = ClientMock.GenerateRandomClient(0);

                //Add new client
                await clientRepository.AddClientAsync(client);

                //Get new client
                var clientEntity = await clientRepository.GetClientAsync(client.Id);

                //Assert new client
                clientEntity.ShouldBeEquivalentTo(client, options => options.Excluding(o => o.Id));

                //Generate random new Client Claim
                var clientClaim = ClientMock.GenerateRandomClientClaim(0);

                //Add new client claim
                await clientRepository.AddClientClaimAsync(clientEntity.Id, clientClaim);

                //Get new client claim
                var newClientClaim =
                    await context.ClientClaims.Where(x => x.Id == clientClaim.Id).SingleOrDefaultAsync();

                //Asert
                newClientClaim.ShouldBeEquivalentTo(clientClaim,
                                                    options => options.Excluding(o => o.Id).Excluding(x => x.Client));

                //Try delete it
                await clientRepository.DeleteClientClaimAsync(newClientClaim);

                //Get new client claim
                var deletedClientClaim =
                    await context.ClientClaims.Where(x => x.Id == clientClaim.Id).SingleOrDefaultAsync();

                //Assert
                deletedClientClaim.Should().BeNull();
            }
        }