mirror of https://github.com/Squidex/squidex.git
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.
51 lines
1.9 KiB
51 lines
1.9 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
using OpenIddict.EntityFrameworkCore.Models;
|
|
using Squidex.EntityFramework.TestHelpers;
|
|
using Squidex.Infrastructure;
|
|
using static OpenIddict.Abstractions.OpenIddictConstants;
|
|
|
|
namespace Squidex.EntityFramework.Domain.Users;
|
|
|
|
public abstract class EFOpenIddictTests<TContext>(ISqlFixture<TContext> fixture)
|
|
where TContext : DbContext, IDbContextWithDialect
|
|
{
|
|
[Fact]
|
|
public async Task Should_allow_openiddict_tokens_without_application()
|
|
{
|
|
await using var dbContext = await fixture.DbContextFactory.CreateDbContextAsync();
|
|
|
|
var authorization = new OpenIddictEntityFrameworkCoreAuthorization
|
|
{
|
|
Id = Guid.NewGuid().ToString(),
|
|
ApplicationId = null,
|
|
CreationDate = DateTime.UtcNow,
|
|
Status = Statuses.Valid,
|
|
Subject = "admin@squidex.io",
|
|
Type = AuthorizationTypes.Permanent,
|
|
};
|
|
|
|
var token = new OpenIddictEntityFrameworkCoreToken
|
|
{
|
|
Id = Guid.NewGuid().ToString(),
|
|
ApplicationId = null,
|
|
Authorization = authorization,
|
|
CreationDate = DateTime.UtcNow,
|
|
ExpirationDate = DateTime.UtcNow.AddMinutes(5),
|
|
Status = Statuses.Valid,
|
|
Subject = "admin@squidex.io",
|
|
Type = "authorization_code",
|
|
};
|
|
|
|
dbContext.Set<OpenIddictEntityFrameworkCoreAuthorization>().Add(authorization);
|
|
dbContext.Set<OpenIddictEntityFrameworkCoreToken>().Add(token);
|
|
|
|
await dbContext.SaveChangesAsync();
|
|
}
|
|
}
|
|
|