mirror of https://github.com/abpframework/abp.git
8 changed files with 169 additions and 14 deletions
@ -0,0 +1,24 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.test.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.IdentityModel\Volo.Abp.IdentityModel.csproj" /> |
|||
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="appsettings.json" /> |
|||
<Content Include="appsettings.json"> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,42 @@ |
|||
using System; |
|||
using Microsoft.Extensions.Options; |
|||
using Shouldly; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.IdentityModel |
|||
{ |
|||
public class AbpIdentityClientOptions_Tests : AbpIdentityModelTestBase |
|||
{ |
|||
private readonly ICurrentTenant _currentTenant; |
|||
private readonly AbpIdentityClientOptions _identityClientOptions; |
|||
|
|||
public AbpIdentityClientOptions_Tests() |
|||
{ |
|||
_currentTenant = GetRequiredService<ICurrentTenant>(); |
|||
_identityClientOptions = GetRequiredService<IOptions<AbpIdentityClientOptions>>().Value; |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetClientConfiguration_Test() |
|||
{ |
|||
var hostDefaultConfiguration = _identityClientOptions.GetClientConfiguration(_currentTenant); |
|||
hostDefaultConfiguration.UserName.ShouldBe("host_default_admin"); |
|||
|
|||
var hostIdentityConfiguration = _identityClientOptions.GetClientConfiguration(_currentTenant, "Identity"); |
|||
hostIdentityConfiguration.UserName.ShouldBe("host_identity_admin"); |
|||
|
|||
using (_currentTenant.Change(Guid.Parse("f72a344f-651e-49f0-85f6-be260a10e4df"), "Test_Tenant1")) |
|||
{ |
|||
var tenantDefaultConfiguration = _identityClientOptions.GetClientConfiguration(_currentTenant); |
|||
tenantDefaultConfiguration.UserName.ShouldBe("tenant_default_admin"); |
|||
} |
|||
|
|||
using (_currentTenant.Change(Guid.Parse("f72a344f-651e-49f0-85f6-be260a10e4df"))) |
|||
{ |
|||
var tenantIdentityConfiguration = _identityClientOptions.GetClientConfiguration(_currentTenant, "Identity"); |
|||
tenantIdentityConfiguration.UserName.ShouldBe("tenant_identity_admin"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.Testing; |
|||
|
|||
namespace Volo.Abp.IdentityModel |
|||
{ |
|||
public abstract class AbpIdentityModelTestBase : AbpIntegratedTest<AbpIdentityModelTestModule> |
|||
{ |
|||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|||
{ |
|||
options.UseAutofac(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.IdentityModel |
|||
{ |
|||
[DependsOn(typeof(AbpIdentityModelModule))] |
|||
public class AbpIdentityModelTestModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
{ |
|||
"IdentityClients": { |
|||
"Default": { |
|||
"GrantType": "password", |
|||
"ClientId": "Test_App", |
|||
"ClientSecret": "1q2w3e*", |
|||
"UserName": "host_default_admin", |
|||
"UserPassword": "1q2w3E*", |
|||
"Authority": "https://localhost:44395", |
|||
"Scope": "Test_Scope" |
|||
}, |
|||
"Default.Test_Tenant1": { |
|||
"GrantType": "password", |
|||
"ClientId": "Test_App", |
|||
"ClientSecret": "1q2w3e*", |
|||
"UserName": "tenant_default_admin", |
|||
"UserPassword": "1q2w3E*", |
|||
"Authority": "https://localhost:44395", |
|||
"Scope": "Test_Scope" |
|||
}, |
|||
"Identity": { |
|||
"GrantType": "password", |
|||
"ClientId": "Test_App", |
|||
"ClientSecret": "1q2w3e*", |
|||
"UserName": "host_identity_admin", |
|||
"UserPassword": "1q2w3E*", |
|||
"Authority": "https://localhost:44395", |
|||
"Scope": "Test_Scope" |
|||
}, |
|||
"Identity.f72a344f-651e-49f0-85f6-be260a10e4df": { |
|||
"GrantType": "password", |
|||
"ClientId": "Test_App", |
|||
"ClientSecret": "1q2w3e*", |
|||
"UserName": "tenant_identity_admin", |
|||
"UserPassword": "1q2w3E*", |
|||
"Authority": "https://localhost:44395", |
|||
"Scope": "Test_Scope" |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue