public async Task StoresThenRetrievesScopesByName()
        {
            var mockIdStore   = new MockKeyValueStore <string, IdentityResource>("123", new IdentityResource("123", new[] { "openid" }));
            var mockApiStore  = new MockKeyValueStore <string, ApiResource>("api123", new ApiResource("api123"));
            var resourceStore = new CassandraResourceStore(mockIdStore, mockApiStore);
            var apiResource   = await resourceStore.FindApiResourceAsync("api123");

            var idResource = await resourceStore.FindIdentityResourcesByScopeAsync(new[] { "123" });

            Assert.NotNull(apiResource);
            Assert.NotEmpty(idResource);
            Assert.Equal("123", idResource.First().Name);
            Assert.Equal("api123", apiResource.Name);
        }
Exemplo n.º 2
0
        public async Task TestDiscoEndpointBug()
        {
            var sut = CassandraResourceStore.Initialize(_session);
            await sut.AddApiResourceAsync(new ApiResource("something"){ UserClaims = null });

            var resources = await sut.GetAllResources();

            var scopes = new List <string>();

            scopes.AddRange(resources.IdentityResources.Where(x => x.ShowInDiscoveryDocument).Select(x => x.Name));
            var apiScopes = from api in resources.ApiResources
                            from scope in api.Scopes
                            where scope.ShowInDiscoveryDocument
                            select scope.Name;

            scopes.AddRange(apiScopes);

            var claims = new List <string>();

            claims.AddRange(resources.IdentityResources.SelectMany(x => x.UserClaims));
            claims.AddRange(resources.ApiResources.SelectMany(x => x.UserClaims));
        }