public void CanMapScope() { var model = new Duende.IdentityServer.Models.ApiScope(); var mappedEntity = model.ToEntity(); var mappedModel = mappedEntity.ToModel(); Assert.NotNull(mappedModel); Assert.NotNull(mappedEntity); }
public void Properties_Map() { var model = new Duende.IdentityServer.Models.ApiScope() { Description = "description", DisplayName = "displayname", Name = "foo", UserClaims = { "c1", "c2" }, Properties = { { "x", "xx" }, { "y", "yy" }, }, Enabled = false }; var mappedEntity = model.ToEntity(); mappedEntity.Description.Should().Be("description"); mappedEntity.DisplayName.Should().Be("displayname"); mappedEntity.Name.Should().Be("foo"); mappedEntity.UserClaims.Count.Should().Be(2); mappedEntity.UserClaims.Select(x => x.Type).Should().BeEquivalentTo(new[] { "c1", "c2" }); mappedEntity.Properties.Count.Should().Be(2); mappedEntity.Properties.Should().Contain(x => x.Key == "x" && x.Value == "xx"); mappedEntity.Properties.Should().Contain(x => x.Key == "y" && x.Value == "yy"); var mappedModel = mappedEntity.ToModel(); mappedModel.Description.Should().Be("description"); mappedModel.DisplayName.Should().Be("displayname"); mappedModel.Enabled.Should().BeFalse(); mappedModel.Name.Should().Be("foo"); mappedModel.UserClaims.Count.Should().Be(2); mappedModel.UserClaims.Should().BeEquivalentTo(new[] { "c1", "c2" }); mappedModel.Properties.Count.Should().Be(2); mappedModel.Properties["x"].Should().Be("xx"); mappedModel.Properties["y"].Should().Be("yy"); }
private static void SeedApiScopeClaims(IAdminStore <Entity.ApiScopeClaim> apiScopeClaimStore, Duende.IdentityServer.Models.ApiScope resource) { foreach (var claim in resource.UserClaims) { apiScopeClaimStore.CreateAsync(new Entity.ApiScopeClaim { ApiScopeId = resource.Name, Id = Guid.NewGuid().ToString(), Type = claim }).GetAwaiter().GetResult(); } }
private static void SeedApiScopeProperties(IAdminStore <Entity.ApiScopeProperty> apiScopePropertyStore, Duende.IdentityServer.Models.ApiScope resource) { foreach (var property in resource.Properties) { apiScopePropertyStore.CreateAsync(new Entity.ApiScopeProperty { ApiScopeId = resource.Name, Id = Guid.NewGuid().ToString(), Key = property.Key, Value = property.Value }).GetAwaiter().GetResult(); } }