Added new IdentityResource Test

pull/190/head
Alper Ebicoglu 8 years ago
parent 56d6abe7c4
commit bce5fa63d8

@ -34,8 +34,8 @@ namespace Volo.Abp.IdentityServer
{
AddClients();
AddPersistentGrants();
//AddIdentityResources();
AddApiResources();
AddIdentityResources();
}
private void AddClients()
@ -125,26 +125,25 @@ namespace Volo.Abp.IdentityServer
});
}
//private void AddIdentityResources()
//{
// _identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create())
// {
// Enabled = true,
// Description = "Test-Identity-Resource-Description-1",
// DisplayName = "Test-Identity-Resource-DisplayName-1",
// Name = "Test-Identity-Resource-Name-1",
// Required = true,
// ShowInDiscoveryDocument = true,
// Emphasize = true,
// UserClaims = new List<IdentityClaim>
// {
// new IdentityClaim(_guidGenerator.Create())
// {
// Type = "Test-Identity-Resource-1-IdentityClaim-Type-1",
// IdentityResourceId = _guidGenerator.Create(),
// }
// }
// });
//}
private void AddIdentityResources()
{
_identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create())
{
Enabled = true,
Description = "Test-Identity-Resource-Description-1",
DisplayName = "Test-Identity-Resource-DisplayName-1",
Name = "Test-Identity-Resource-Name-1",
Required = true,
ShowInDiscoveryDocument = true,
Emphasize = true,
UserClaims = new List<IdentityClaim>
{
new IdentityClaim(_guidGenerator.Create())
{
Type = "Test-Identity-Resource-1-IdentityClaim-Type-1"
}
}
});
}
}
}

@ -57,5 +57,22 @@ namespace Volo.Abp.IdentityServer.Clients
apiResources[0].Scopes.GroupBy(x=>x.Name).Count().ShouldBe(1);
apiResources[0].Scopes.GroupBy(x=>x.Name).First().Key.ShouldBe("Test-ApiResource-ApiScope-Name-1");
}
[Fact]
public async Task FindIdentityResourcesByScopeAsync_Should_Return_For_Given_Scopes()
{
//Act
var identityResourcesByScope = await _resourceStore.FindIdentityResourcesByScopeAsync(new List<string>
{
"Test-Identity-Resource-Name-1"
});
//Assert
var resourcesByScope = identityResourcesByScope as IdentityResource[] ?? identityResourcesByScope.ToArray();
resourcesByScope.Length.ShouldBe(1);
resourcesByScope.First().DisplayName.ShouldBe("Test-Identity-Resource-DisplayName-1");
resourcesByScope.First().Description.ShouldBe("Test-Identity-Resource-Description-1");
resourcesByScope.First().Required.ShouldBe(true);
}
}
}

Loading…
Cancel
Save