public virtual List <SelectItem> GetSecretTypes() { var secrets = new List <SelectItem>(); secrets.AddRange(ClientConsts.GetSecretTypes().Select(x => new SelectItem(x, x))); return(secrets); }
public static Faker <ClientGrantType> ClientGrantTypesFaker() { var fakerClientGrantTypes = new Faker <ClientGrantType>() .RuleFor(x => x.Id, f => f.Random.Number(10000000)) .RuleFor(o => o.GrantType, f => f.PickRandom(ClientConsts.GetGrantTypes())); return(fakerClientGrantTypes); }
public static Faker <ClientDto> ClientFaker(int id) { var clientFaker = new Faker <ClientDto>() .StrictMode(false) .RuleFor(o => o.ClientId, f => Guid.NewGuid().ToString()) .RuleFor(o => o.ClientName, f => Guid.NewGuid().ToString()) .RuleFor(o => o.Id, id) .RuleFor(o => o.AbsoluteRefreshTokenLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.AccessTokenLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.AccessTokenType, f => f.Random.Number(0, 1)) .RuleFor(o => o.AllowAccessTokensViaBrowser, f => f.Random.Bool()) .RuleFor(o => o.AllowOfflineAccess, f => f.Random.Bool()) .RuleFor(o => o.AllowPlainTextPkce, f => f.Random.Bool()) .RuleFor(o => o.AllowRememberConsent, f => f.Random.Bool()) .RuleFor(o => o.AllowedCorsOrigins, f => Enumerable.Range(1, f.Random.Int(1, 10)).Select(x => f.PickRandom(f.Internet.Url())).ToList()) .RuleFor(o => o.AllowedGrantTypes, f => Enumerable.Range(1, f.Random.Int(1, 10)).Select(x => f.PickRandom(ClientConsts.GetGrantTypes())).ToList()) .RuleFor(o => o.AllowedScopes, f => Enumerable.Range(1, f.Random.Int(1, 10)).Select(x => f.PickRandom(ClientMock.GetScopes())).ToList()) .RuleFor(o => o.AlwaysIncludeUserClaimsInIdToken, f => f.Random.Bool()) .RuleFor(o => o.Enabled, f => f.Random.Bool()) .RuleFor(o => o.ProtocolType, f => f.PickRandom(ClientConsts.GetProtocolTypes().Select(x => x.Id))) .RuleFor(o => o.RequireClientSecret, f => f.Random.Bool()) .RuleFor(o => o.Description, f => f.Random.Words(f.Random.Number(1, 7))) .RuleFor(o => o.ClientUri, f => f.Internet.Url()) .RuleFor(o => o.RequireConsent, f => f.Random.Bool()) .RuleFor(o => o.RequirePkce, f => f.Random.Bool()) .RuleFor(o => o.RedirectUris, f => Enumerable.Range(1, f.Random.Int(1, 10)).Select(x => f.PickRandom(f.Internet.Url())).ToList()) .RuleFor(o => o.PostLogoutRedirectUris, f => Enumerable.Range(1, f.Random.Int(1, 10)).Select(x => f.PickRandom(f.Internet.Url())).ToList()) .RuleFor(o => o.FrontChannelLogoutUri, f => f.Internet.Url()) .RuleFor(o => o.FrontChannelLogoutSessionRequired, f => f.Random.Bool()) .RuleFor(o => o.BackChannelLogoutUri, f => f.Internet.Url()) .RuleFor(o => o.BackChannelLogoutSessionRequired, f => f.Random.Bool()) .RuleFor(o => o.IdentityTokenLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.AuthorizationCodeLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.ConsentLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.SlidingRefreshTokenLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.RefreshTokenUsage, f => f.Random.Number(0, 1)) .RuleFor(o => o.UpdateAccessTokenClaimsOnRefresh, f => f.Random.Bool()) .RuleFor(o => o.RefreshTokenExpiration, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.EnableLocalLogin, f => f.Random.Bool()) .RuleFor(o => o.AlwaysSendClientClaims, f => f.Random.Bool()) .RuleFor(o => o.ClientClaimsPrefix, f => Guid.NewGuid().ToString()) .RuleFor(o => o.IncludeJwtId, f => f.Random.Bool()) .RuleFor(o => o.PairWiseSubjectSalt, f => Guid.NewGuid().ToString()) .RuleFor(o => o.Claims, f => new List <ClientClaimDto>()) //Client Claims are managed with seperate method .RuleFor(o => o.IdentityProviderRestrictions, f => Enumerable.Range(1, f.Random.Int(1, 10)).Select(x => f.PickRandom(ClientMock.GetIdentityProviders())).ToList()) .RuleFor(o => o.Properties, f => new List <ClientPropertyDto>()) //Client Properties are managed with seperate method .RuleFor(o => o.LogoUri, f => f.Internet.Url()) .RuleFor(o => o.Updated, f => f.Date.Recent()) .RuleFor(o => o.LastAccessed, f => f.Date.Recent()) .RuleFor(o => o.UserSsoLifetime, f => f.Random.Int()) .RuleFor(o => o.UserCodeType, f => f.Random.Word()) .RuleFor(o => o.DeviceCodeLifetime, f => f.Random.Int()) .RuleFor(o => o.NonEditable, f => f.Random.Bool()) .RuleFor(o => o.RequireRequestObject, f => f.Random.Bool()) .RuleFor(o => o.AllowedIdentityTokenSigningAlgorithms, f => ClientMock.AllowedSigningAlgorithms().Take(f.Random.Number(1, 5)).ToList()); return(clientFaker); }
public virtual List <string> GetStandardClaims(string claim, int limit = 0) { var filteredClaims = ClientConsts.GetStandardClaims() .WhereIf(!string.IsNullOrWhiteSpace(claim), x => x.Contains(claim)) .TakeIf(x => x, limit > 0, limit) .ToList(); return(filteredClaims); }
public virtual List <string> GetGrantTypes(string grant, int limit = 0) { var filteredGrants = ClientConsts.GetGrantTypes() .WhereIf(!string.IsNullOrWhiteSpace(grant), x => x.Contains(grant)) .TakeIf(x => x, limit > 0, limit) .ToList(); return(filteredGrants); }
public static Faker <ClientClaim> ClientClaimFaker(int id) { var clientClaimFaker = new Faker <ClientClaim>() .StrictMode(false) .RuleFor(o => o.Id, id) .RuleFor(o => o.Type, f => f.PickRandom(ClientConsts.GetStandardClaims())) .RuleFor(o => o.Value, f => Guid.NewGuid().ToString()); return(clientClaimFaker); }
public virtual List <string> GetSigningAlgorithms(string algorithm, int limit = 0) { var signingAlgorithms = ClientConsts.SigningAlgorithms() .WhereIf(!string.IsNullOrWhiteSpace(algorithm), x => x.Contains(algorithm)) .TakeIf(x => x, limit > 0, limit) .OrderBy(x => x) .ToList(); return(signingAlgorithms); }
public List <string> GetGrantTypes(string grant) { if (string.IsNullOrWhiteSpace(grant)) { return(new List <string>()); } var filteredGrants = ClientConsts.GetGrantTypes().Where(x => x.Contains(grant)).ToList(); return(filteredGrants); }
public List <string> GetStandardClaims(string claim) { if (string.IsNullOrWhiteSpace(claim)) { return(new List <string>()); } var filteredClaims = ClientConsts.GetStandardClaims().Where(x => x.Contains(claim)).ToList(); return(filteredClaims); }
public static Faker <ClientSecretsDto> ClientSecretFaker(int id, int clientId) { var clientSecretFaker = new Faker <ClientSecretsDto>() .StrictMode(false) .RuleFor(o => o.ClientSecretId, id) .RuleFor(o => o.Type, f => f.PickRandom(ClientConsts.GetSecretTypes())) .RuleFor(o => o.Value, f => Guid.NewGuid().ToString()) .RuleFor(o => o.ClientId, clientId); return(clientSecretFaker); }
public static Faker <ClientSecret> ClientSecretFaker(int id) { var testClientSecret = new Faker <ClientSecret>() .StrictMode(false) .RuleFor(o => o.Id, id) .RuleFor(o => o.Description, f => f.Random.Words(f.Random.Number(1, 7))) .RuleFor(o => o.Type, f => f.PickRandom(ClientConsts.GetSecretTypes())) .RuleFor(o => o.Expiration, f => f.Date.Future()) .RuleFor(o => o.Value, f => Guid.NewGuid().ToString()); return(testClientSecret); }
public static Faker <Client> ClientFaker(int id, bool generateClaims = false, bool generateProperties = false, bool generateSecrets = false) { var clientFaker = new Faker <Client>() .StrictMode(true) .RuleFor(o => o.ClientId, f => Guid.NewGuid().ToString()) .RuleFor(o => o.ClientName, f => Guid.NewGuid().ToString()) .RuleFor(o => o.Id, id) .RuleFor(o => o.AbsoluteRefreshTokenLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.AccessTokenLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.AccessTokenType, f => f.Random.Number(0, 1)) .RuleFor(o => o.AllowAccessTokensViaBrowser, f => f.Random.Bool()) .RuleFor(o => o.AllowOfflineAccess, f => f.Random.Bool()) .RuleFor(o => o.AllowPlainTextPkce, f => f.Random.Bool()) .RuleFor(o => o.AllowRememberConsent, f => f.Random.Bool()) .RuleFor(o => o.AllowedCorsOrigins, f => GetClientCorsOriginFaker().Generate(f.Random.Number(10))) .RuleFor(o => o.AllowedGrantTypes, f => ClientGrantTypesFaker().Generate(1)) .RuleFor(o => o.AllowedScopes, f => ClientScopesFaker().Generate(f.Random.Number(1, 3))) .RuleFor(o => o.AlwaysIncludeUserClaimsInIdToken, f => f.Random.Bool()) .RuleFor(o => o.Enabled, f => f.Random.Bool()) .RuleFor(o => o.ProtocolType, f => f.PickRandom(ClientConsts.GetProtocolTypes().Select(x => x.Id))) .RuleFor(o => o.ClientSecrets, f => generateSecrets ? ClientSecretFaker(0).Generate(f.Random.Number(10)) : new List <ClientSecret>()) //Client Secrets are managed with seperate method .RuleFor(o => o.RequireClientSecret, f => f.Random.Bool()) .RuleFor(o => o.Description, f => f.Random.Words(f.Random.Number(1, 7))) .RuleFor(o => o.ClientUri, f => f.Internet.Url()) .RuleFor(o => o.RequireConsent, f => f.Random.Bool()) .RuleFor(o => o.RequirePkce, f => f.Random.Bool()) .RuleFor(o => o.RedirectUris, f => ClientRedirectUriFaker().Generate(f.Random.Number(10))) .RuleFor(o => o.PostLogoutRedirectUris, f => ClientPostLogoutRedirectUriFaker().Generate(f.Random.Number(10))) .RuleFor(o => o.FrontChannelLogoutUri, f => f.Internet.Url()) .RuleFor(o => o.FrontChannelLogoutSessionRequired, f => f.Random.Bool()) .RuleFor(o => o.BackChannelLogoutUri, f => f.Internet.Url()) .RuleFor(o => o.BackChannelLogoutSessionRequired, f => f.Random.Bool()) .RuleFor(o => o.IdentityTokenLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.AuthorizationCodeLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.ConsentLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.SlidingRefreshTokenLifetime, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.RefreshTokenUsage, f => f.Random.Number(0, 1)) .RuleFor(o => o.UpdateAccessTokenClaimsOnRefresh, f => f.Random.Bool()) .RuleFor(o => o.RefreshTokenExpiration, f => f.Random.Number(int.MaxValue)) .RuleFor(o => o.EnableLocalLogin, f => f.Random.Bool()) .RuleFor(o => o.AlwaysSendClientClaims, f => f.Random.Bool()) .RuleFor(o => o.ClientClaimsPrefix, f => Guid.NewGuid().ToString()) .RuleFor(o => o.IncludeJwtId, f => f.Random.Bool()) .RuleFor(o => o.PairWiseSubjectSalt, f => Guid.NewGuid().ToString()) .RuleFor(o => o.Claims, f => generateClaims ? ClientClaimFaker(0).Generate(f.Random.Number(10)) : new List <ClientClaim>()) //Client Claims are managed with seperate method .RuleFor(o => o.IdentityProviderRestrictions, f => ClientIdPRescrictionFaker().Generate(1)) .RuleFor(o => o.Properties, f => generateProperties ? ClientPropertyFaker(0).Generate(f.Random.Number(10)) : new List <ClientProperty>()) //Client Properties are managed with seperate method .RuleFor(o => o.LogoUri, f => f.Internet.Url()); return(clientFaker); }
public static Faker <ApiScopesDto> GetApiScopeFaker(int id, int resourceId) { var fakerApiScope = new Faker <ApiScopesDto>() .RuleFor(o => o.Name, f => Guid.NewGuid().ToString()) .RuleFor(o => o.ApiScopeId, id) .RuleFor(o => o.ApiResourceId, resourceId) .RuleFor(o => o.Description, f => f.Random.Words(f.Random.Number(1, 5))) .RuleFor(o => o.DisplayName, f => f.Random.Words(f.Random.Number(1, 5))) .RuleFor(o => o.UserClaims, f => Enumerable.Range(1, f.Random.Int(1, 10)) .Select(x => f.PickRandom(ClientConsts.GetStandardClaims())).ToList()) .RuleFor(o => o.Emphasize, f => f.Random.Bool()) .RuleFor(o => o.Required, f => f.Random.Bool()) .RuleFor(o => o.ShowInDiscoveryDocument, f => f.Random.Bool()); return(fakerApiScope); }
public static Faker <ApiResourceDto> GetApiResourceFaker(int id) { var fakerApiResource = new Faker <ApiResourceDto>() .RuleFor(o => o.Name, f => Guid.NewGuid().ToString()) .RuleFor(o => o.Id, id) .RuleFor(o => o.Description, f => f.Random.Words(f.Random.Number(1, 5))) .RuleFor(o => o.DisplayName, f => f.Random.Words(f.Random.Number(1, 5))) .RuleFor(o => o.Enabled, f => f.Random.Bool()) .RuleFor(o => o.UserClaims, f => Enumerable.Range(1, f.Random.Int(1, 10)).Select(x => f.PickRandom(ClientConsts.GetStandardClaims())).ToList()); return(fakerApiResource); }
public IList <string> GetAllGrantTypes() { return(ClientConsts.GetGrantTypes()); }
public static Faker <ApiResourceDto> GetApiResourceFaker(int id) { var fakerApiResource = new Faker <ApiResourceDto>() .RuleFor(o => o.Name, f => Guid.NewGuid().ToString()) .RuleFor(o => o.Id, id) .RuleFor(o => o.Description, f => f.Random.Words(f.Random.Number(1, 5))) .RuleFor(o => o.DisplayName, f => f.Random.Words(f.Random.Number(1, 5))) .RuleFor(o => o.Enabled, f => f.Random.Bool()) .RuleFor(o => o.RequireResourceIndicator, f => f.Random.Bool()) .RuleFor(o => o.UserClaims, f => Enumerable.Range(1, f.Random.Int(1, 10)).Select(x => f.PickRandom(ClientConsts.GetStandardClaims())).ToList()) .RuleFor(o => o.ShowInDiscoveryDocument, f => f.Random.Bool()) .RuleFor(o => o.AllowedAccessTokenSigningAlgorithms, f => ClientMock.AllowedSigningAlgorithms().Take(f.Random.Number(1, 5)).ToList()); return(fakerApiResource); }
public virtual List <SelectItem> GetProtocolTypes() { return(ClientConsts.GetProtocolTypes()); }