public void Properties_Map()
        {
            var model = new ApiResource()
            {
                Description = "description",
                DisplayName = "displayname",
                Name        = "foo",
                Scopes      = { "foo1", "foo2" },
                Enabled     = false
            };


            var mappedEntity = model.ToEntity();

            mappedEntity.Scopes.Count.Should().Be(2);
            var foo1 = mappedEntity.Scopes.FirstOrDefault(x => x.Scope == "foo1");

            foo1.Should().NotBeNull();
            var foo2 = mappedEntity.Scopes.FirstOrDefault(x => x.Scope == "foo2");

            foo2.Should().NotBeNull();


            var mappedModel = mappedEntity.ToModel();

            mappedModel.Description.Should().Be("description");
            mappedModel.DisplayName.Should().Be("displayname");
            mappedModel.Enabled.Should().BeFalse();
            mappedModel.Name.Should().Be("foo");
        }
        public void Can_Map()
        {
            var model        = new ApiResource();
            var mappedEntity = model.ToEntity();
            var mappedModel  = mappedEntity.ToModel();

            Assert.NotNull(mappedModel);
            Assert.NotNull(mappedEntity);
        }
        public void missing_values_should_use_defaults()
        {
            var entity = new Duende.IdentityServer.EntityFramework.Entities.ApiResource
            {
                Secrets = new System.Collections.Generic.List <Duende.IdentityServer.EntityFramework.Entities.ApiResourceSecret>
                {
                    new Duende.IdentityServer.EntityFramework.Entities.ApiResourceSecret
                    {
                    }
                }
            };

            var def = new ApiResource
            {
                ApiSecrets = { new Duende.IdentityServer.Models.Secret("foo") }
            };

            var model = entity.ToModel();

            model.ApiSecrets.First().Type.Should().Be(def.ApiSecrets.First().Type);
        }
예제 #4
0
 private static void SeedApiClaims(IAdminStore <Entity.ApiClaim> apiClaimStore, Duende.IdentityServer.Models.ApiResource resource)
 {
     foreach (var claim in resource.UserClaims)
     {
         apiClaimStore.CreateAsync(new Entity.ApiClaim
         {
             ApiId = resource.Name,
             Id    = Guid.NewGuid().ToString(),
             Type  = claim
         }).GetAwaiter().GetResult();
     }
 }
예제 #5
0
 private static void SeedApiSecrets(IAdminStore <Entity.ApiSecret> apiSecretStore, Duende.IdentityServer.Models.ApiResource resource)
 {
     foreach (var secret in resource.ApiSecrets)
     {
         apiSecretStore.CreateAsync(new Entity.ApiSecret
         {
             ApiId       = resource.Name,
             Expiration  = secret.Expiration,
             Description = secret.Description,
             Id          = Guid.NewGuid().ToString(),
             Type        = secret.Type,
             Value       = secret.Value
         }).GetAwaiter().GetResult();
     }
 }
예제 #6
0
 private static void SeedApiApiScopes(IAdminStore <Entity.ApiApiScope> apiApiScopeStore, Duende.IdentityServer.Models.ApiResource resource)
 {
     foreach (var apiScope in resource.Scopes)
     {
         apiApiScopeStore.CreateAsync(new Entity.ApiApiScope
         {
             ApiId      = resource.Name,
             ApiScopeId = apiScope,
             Id         = Guid.NewGuid().ToString()
         }).GetAwaiter().GetResult();
     }
 }
예제 #7
0
 private static void SeedApiProperties(IAdminStore <Entity.ApiProperty> apiPropertyStore, Duende.IdentityServer.Models.ApiResource resource)
 {
     foreach (var property in resource.Properties)
     {
         apiPropertyStore.CreateAsync(new Entity.ApiProperty
         {
             ApiId = resource.Name,
             Id    = Guid.NewGuid().ToString(),
             Key   = property.Key,
             Value = property.Value
         }).GetAwaiter().GetResult();
     }
 }