mirror of https://github.com/abpframework/abp.git
Browse Source
Add `FrontChannelLogoutUri` property and related methods to OpenIddict application classespull/23257/head
committed by
GitHub
20 changed files with 255 additions and 161 deletions
@ -0,0 +1,79 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Reflection; |
||||
|
using System.Reflection.Emit; |
||||
|
using Microsoft.AspNetCore.Mvc.ApplicationParts; |
||||
|
using NSubstitute; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.ApplicationPart; |
||||
|
|
||||
|
public class ApplicationPartSorter_Tests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void Should_Sort_ApplicationParts_By_Module_Dependencies() |
||||
|
{ |
||||
|
var moduleDescriptors = new List<IAbpModuleDescriptor>(); |
||||
|
var partManager = new ApplicationPartManager(); |
||||
|
|
||||
|
for (var i = 0; i < 10; i++) |
||||
|
{ |
||||
|
var assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName($"ModuleA{i}.dll"), AssemblyBuilderAccess.Run); |
||||
|
partManager.ApplicationParts.Add(new AssemblyPart(assembly)); |
||||
|
moduleDescriptors.Add(CreateModuleDescriptor(assembly)); |
||||
|
} |
||||
|
var randomApplicationParts = partManager.ApplicationParts.OrderBy(x => Guid.NewGuid()).ToList(); // Shuffle the parts
|
||||
|
|
||||
|
// Additional part
|
||||
|
randomApplicationParts.AddFirst(new CompiledRazorAssemblyPart(typeof(AbpAspNetCoreModule).Assembly)); |
||||
|
randomApplicationParts.Insert(5, new CompiledRazorAssemblyPart(typeof(AbpAspNetCoreMvcModule).Assembly)); |
||||
|
randomApplicationParts.AddLast(new CompiledRazorAssemblyPart(typeof(AbpVirtualFileSystemModule).Assembly)); |
||||
|
|
||||
|
partManager.ApplicationParts.Clear(); |
||||
|
foreach (var part in randomApplicationParts) |
||||
|
{ |
||||
|
partManager.ApplicationParts.Add(part); |
||||
|
} |
||||
|
|
||||
|
var moduleContainer = CreateFakeModuleContainer(moduleDescriptors); |
||||
|
|
||||
|
ApplicationPartSorter.Sort(partManager, moduleContainer); |
||||
|
|
||||
|
// Act
|
||||
|
partManager.ApplicationParts.Count.ShouldBe(13); // 10 modules + 3 additional parts
|
||||
|
|
||||
|
var applicationParts = partManager.ApplicationParts.Reverse().ToList(); // Reverse the order to match the expected output
|
||||
|
|
||||
|
applicationParts[0].ShouldBeOfType<CompiledRazorAssemblyPart>().Assembly.ShouldBe(typeof(AbpAspNetCoreModule).Assembly); |
||||
|
applicationParts[1].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA0"); |
||||
|
applicationParts[2].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA1"); |
||||
|
applicationParts[3].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA2"); |
||||
|
applicationParts[4].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA3"); |
||||
|
applicationParts[5].ShouldBeOfType<CompiledRazorAssemblyPart>().Assembly.ShouldBe(typeof(AbpAspNetCoreMvcModule).Assembly); |
||||
|
applicationParts[6].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA4"); |
||||
|
applicationParts[7].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA5"); |
||||
|
applicationParts[8].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA6"); |
||||
|
applicationParts[9].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA7"); |
||||
|
applicationParts[10].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA8"); |
||||
|
applicationParts[11].ShouldBeOfType<AssemblyPart>().Assembly.GetName().Name.ShouldStartWith("ModuleA9"); |
||||
|
applicationParts[12].ShouldBeOfType<CompiledRazorAssemblyPart>().Assembly.ShouldBe(typeof(AbpVirtualFileSystemModule).Assembly); |
||||
|
} |
||||
|
|
||||
|
private static IModuleContainer CreateFakeModuleContainer(List<IAbpModuleDescriptor> moduleDescriptors) |
||||
|
{ |
||||
|
var fakeModuleContainer = Substitute.For<IModuleContainer>(); |
||||
|
fakeModuleContainer.Modules.Returns(moduleDescriptors); |
||||
|
return fakeModuleContainer; |
||||
|
} |
||||
|
|
||||
|
private static IAbpModuleDescriptor CreateModuleDescriptor(Assembly assembly) |
||||
|
{ |
||||
|
var moduleDescriptor = Substitute.For<IAbpModuleDescriptor>(); |
||||
|
moduleDescriptor.Assembly.Returns(assembly); |
||||
|
return moduleDescriptor; |
||||
|
} |
||||
|
} |
||||
@ -1,16 +1,22 @@ |
|||||
using OpenIddict.Abstractions; |
using System; |
||||
|
using OpenIddict.Abstractions; |
||||
|
|
||||
namespace Volo.Abp.OpenIddict.Applications; |
namespace Volo.Abp.OpenIddict.Applications; |
||||
|
|
||||
public class AbpApplicationDescriptor : OpenIddictApplicationDescriptor |
public class AbpApplicationDescriptor : OpenIddictApplicationDescriptor |
||||
{ |
{ |
||||
|
/// <summary>
|
||||
|
/// Gets or sets the front-channel logout URI associated with the application.
|
||||
|
/// </summary>
|
||||
|
public virtual Uri FrontChannelLogoutUri { get; set; } |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// URI to further information about client.
|
/// URI to further information about client.
|
||||
/// </summary>
|
/// </summary>
|
||||
public string ClientUri { get; set; } |
public virtual string ClientUri { get; set; } |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// URI to client logo.
|
/// URI to client logo.
|
||||
/// </summary>
|
/// </summary>
|
||||
public string LogoUri { get; set; } |
public virtual string LogoUri { get; set; } |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue