public async Task FindResourcesByScopeAsync_on_duplicate_api_scopes_should_succeed() { var store = new MockResourceStore() { ApiResources = { new ApiResource { Name = "api1", Scopes ={ "a" } }, new ApiResource() { Name = "api2", Scopes ={ "a" } }, }, ApiScopes = { new ApiScope("a") } }; var result = await store.FindResourcesByScopeAsync(new string[] { "a" }); result.ApiResources.Count.Should().Be(2); result.ApiScopes.Count.Should().Be(1); result.ApiResources.Select(x => x.Name).Should().BeEquivalentTo(new[] { "api1", "api2" }); result.ApiScopes.Select(x => x.Name).Should().BeEquivalentTo(new[] { "a" }); }
public async Task FindResourcesByScopeAsync_without_duplicate_api_scopes_should_succeed() { var store = new MockResourceStore() { ApiResources = { new ApiResource("A"), new ApiResource("B") } }; await store.FindResourcesByScopeAsync(new string[] { "A" }); }
public void FindResourcesByScopeAsync_on_duplicate_api_scopes_should_fail() { var store = new MockResourceStore() { ApiResources = { new ApiResource("A"), new ApiResource("A") } }; Func <Task> a = () => store.FindResourcesByScopeAsync(new string[] { "A" }); a.Should().Throw <Exception>().And.Message.ToLowerInvariant().Should().Contain("duplicate").And.Contain("api scopes"); }
public async Task FindResourcesByScopeAsync_without_duplicate_identity_scopes_should_succeed() { var store = new MockResourceStore() { IdentityResources = { new IdentityResource { Name = "A" }, new IdentityResource { Name = "B" } } }; await store.FindResourcesByScopeAsync(new string[] { "A" }); }
public void FindResourcesByScopeAsync_on_duplicate_identity_scopes_should_fail() { var store = new MockResourceStore() { IdentityResources = { new IdentityResource { Name = "A" }, new IdentityResource { Name = "A" } } }; Func <Task> a = () => store.FindResourcesByScopeAsync(new string[] { "A" }); a.Should().Throw <Exception>().And.Message.ToLowerInvariant().Should().Contain("duplicate").And.Contain("identity scopes"); }
public async Task FindResourcesByScopeAsync_with_duplicate_api_scopes_on_single_api_resource_should_succeed_and_only_reuturn_one_resource() { var store = new MockResourceStore() { ApiResources = { new ApiResource { Name = "api1", Scopes ={ "a", "a" } } }, ApiScopes = { new ApiScope("a"), } }; var result = await store.FindResourcesByScopeAsync(new string[] { "a" }); result.ApiResources.Count.Should().Be(1); }