Skip to content

Commit

Permalink
Merge pull request #20671 from abpframework/OpenIddict-Auditing
Browse files Browse the repository at this point in the history
Remove audit properties from `OpenIddictAuthorization`  and `OpenIddictToken`.
  • Loading branch information
maliming authored Oct 2, 2024
2 parents d845a36 + 74a2174 commit 4e7f025
Show file tree
Hide file tree
Showing 29 changed files with 45 additions and 922 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -614,14 +614,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
Subject = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: true),
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false)
},
constraints: table =>
{
Expand Down Expand Up @@ -650,14 +643,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
Subject = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: true),
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false)
},
constraints: table =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
Expand Down Expand Up @@ -987,41 +987,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<DateTime?>("CreationDate")
.HasColumnType("datetime2");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("ExtraProperties")
.IsRequired()
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Properties")
.HasColumnType("nvarchar(max)");
Expand Down Expand Up @@ -1146,22 +1116,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<DateTime?>("CreationDate")
.HasColumnType("datetime2");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<DateTime?>("ExpirationDate")
.HasColumnType("datetime2");
Expand All @@ -1170,20 +1124,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Payload")
.HasColumnType("nvarchar(max)");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Timing;

namespace Volo.Abp.OpenIddict.Authorizations;

public class OpenIddictAuthorization : FullAuditedAggregateRoot<Guid>
public class OpenIddictAuthorization : AggregateRoot<Guid>
{
public OpenIddictAuthorization()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Timing;

namespace Volo.Abp.OpenIddict.Tokens;

public class OpenIddictToken : FullAuditedAggregateRoot<Guid>
public class OpenIddictToken : AggregateRoot<Guid>
{
public OpenIddictToken()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public AbpOpenIddictTokenStore_Tests()
_tokenStore = ServiceProvider.GetRequiredService<IOpenIddictTokenStore<OpenIddictTokenModel>>();
_testData = ServiceProvider.GetRequiredService<AbpOpenIddictTestData>();
}

[Fact]
public async Task CountAsync()
{
Expand All @@ -30,18 +30,18 @@ public async Task CountAsync()
[Fact]
public async Task CreateAsync()
{
await _tokenStore.CreateAsync(new OpenIddictTokenModel
await _tokenStore.CreateAsync(new OpenIddictTokenModel
{
ApplicationId = _testData.App1Id,
Payload = "TestPayload3",
Subject = "TestSubject3",
Type = "TestType3",
Status = OpenIddictConstants.Statuses.Inactive,

}, CancellationToken.None);

var tokens = await _tokenStore.FindBySubjectAsync("TestSubject3", CancellationToken.None).ToListAsync();

tokens.Count.ShouldBe(1);
var token = tokens.First();
token.ApplicationId.ShouldBe(_testData.App1Id);
Expand All @@ -50,11 +50,12 @@ await _tokenStore.CreateAsync(new OpenIddictTokenModel
token.Type.ShouldBe("TestType3");
token.Status.ShouldBe(OpenIddictConstants.Statuses.Inactive);
}

[Fact]
public async Task DeleteAsync()
{
var token = await _tokenStore.FindByIdAsync(_testData.Token1Id.ToString(), CancellationToken.None);
token.ShouldNotBeNull();
await _tokenStore.DeleteAsync(token, CancellationToken.None);

token = await _tokenStore.FindByIdAsync(_testData.Token1Id.ToString(), CancellationToken.None);
Expand All @@ -65,31 +66,31 @@ public async Task DeleteAsync()
public async Task FindAsync_Should_Return_Empty_If_Not_Found()
{
var tokens = await _tokenStore.FindAsync("non_existing_subject", _testData.App1Id.ToString(), "non_existing_status", "non_existing_type", CancellationToken.None).ToListAsync();

tokens.Count.ShouldBe(0);
}

[Fact]
public async Task FindAsync_Should_Return_Tokens_If_Found()
{
var tokens = await _tokenStore.FindAsync("TestSubject1", _testData.App1Id.ToString(),OpenIddictConstants.Statuses.Redeemed, "TestType1", CancellationToken.None).ToListAsync();

tokens.Count.ShouldBe(1);
}

[Fact]
public async Task FindByApplicationIdAsync_Should_Return_Empty_If_Not_Found()
{
var tokens = await _tokenStore.FindByApplicationIdAsync(Guid.NewGuid().ToString(), CancellationToken.None).ToListAsync();

tokens.Count.ShouldBe(0);
}

[Fact]
public async Task FindByApplicationIdAsync_Should_Return_Tokens_If_Found()
{
var tokens = await _tokenStore.FindByApplicationIdAsync(_testData.App1Id.ToString(), CancellationToken.None).ToListAsync();

tokens.Count.ShouldBe(1);
}

Expand Down Expand Up @@ -121,7 +122,7 @@ public async Task FindByReferenceIdAsync_Should_Return_Null_If_Not_Found()
var token = await _tokenStore.FindByReferenceIdAsync(Guid.NewGuid().ToString(), CancellationToken.None);
token.ShouldBeNull();
}

[Fact]
public async Task FindByReferenceIdAsync_Should_Return_Token_If_Found()
{
Expand All @@ -145,12 +146,12 @@ public async Task UpdateAsync()

await _tokenStore.UpdateAsync(token, CancellationToken.None);
token = await _tokenStore.FindByIdAsync(_testData.Token1Id.ToString(), CancellationToken.None);

token.ApplicationId.ShouldBe(_testData.App2Id);
token.Payload.ShouldBe("New payload");
token.Subject.ShouldBe("New subject");
token.Type.ShouldBe("New type");
token.Status.ShouldBe(OpenIddictConstants.Statuses.Revoked);
token.ExpirationDate.ShouldBe(now);
}
}
}
Loading

0 comments on commit 4e7f025

Please sign in to comment.