You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.9 KiB
58 lines
1.9 KiB
using System.Reflection; |
|
using System.Security.Claims; |
|
using AutoFixture; |
|
using AutoFixture.Xunit2; |
|
using Bit.Core.Auth.Identity; |
|
using Duende.IdentityServer.Models; |
|
using Duende.IdentityServer.Validation; |
|
|
|
namespace Bit.Identity.Test.AutoFixture; |
|
|
|
internal class ProfileDataRequestContextCustomization : ICustomization |
|
{ |
|
public void Customize(IFixture fixture) |
|
{ |
|
fixture.Customize<ProfileDataRequestContext>(composer => composer |
|
.With(o => o.Subject, new ClaimsPrincipal(new ClaimsIdentity([ |
|
new Claim("sub", Guid.NewGuid().ToString()), |
|
new Claim("name", "Test User"), |
|
new Claim("email", "test@example.com") |
|
]))) |
|
.With(o => o.Client, new Client { ClientId = "web" }) |
|
.With(o => o.ValidatedRequest, () => null) |
|
.With(o => o.RequestedResources, new ResourceValidationResult()) |
|
.With(o => o.IssuedClaims, []) |
|
.Without(o => o.Caller)); |
|
} |
|
} |
|
|
|
public class ProfileDataRequestContextAttribute : CustomizeAttribute |
|
{ |
|
public override ICustomization GetCustomization(ParameterInfo parameter) |
|
{ |
|
return new ProfileDataRequestContextCustomization(); |
|
} |
|
} |
|
|
|
internal class IsActiveContextCustomization : ICustomization |
|
{ |
|
public void Customize(IFixture fixture) |
|
{ |
|
fixture.Customize<IsActiveContext>(composer => composer |
|
.With(o => o.Subject, new ClaimsPrincipal(new ClaimsIdentity([ |
|
new Claim("sub", Guid.NewGuid().ToString()), |
|
new Claim(Claims.SecurityStamp, "test-security-stamp") |
|
]))) |
|
.With(o => o.Client, new Client { ClientId = "web" }) |
|
.With(o => o.IsActive, false) |
|
.Without(o => o.Caller)); |
|
} |
|
} |
|
|
|
public class IsActiveContextAttribute : CustomizeAttribute |
|
{ |
|
public override ICustomization GetCustomization(ParameterInfo parameter) |
|
{ |
|
return new IsActiveContextCustomization(); |
|
} |
|
}
|
|
|