test(security): invalidate data scope snapshots

This commit is contained in:
2026-08-04 09:46:44 +08:00
parent e290719d4a
commit 2063cb59fd
2 changed files with 10 additions and 2 deletions

View File

@@ -3,6 +3,8 @@ using System.Net.Http.Json;
using System.Text.Json;
using Microsoft.Extensions.DependencyInjection;
using Tiku.Api.Contracts;
using Tiku.Application.Auth;
using Tiku.Application.Security;
using Tiku.Domain.Catalog;
using Tiku.Domain.Common;
using Tiku.Domain.Content;
@@ -305,6 +307,8 @@ public sealed class ContentManagementEndpointTests
item.TenantId == tenantId && item.Code == "integration_test_admin");
role.DataScope = JsonSerializer.SerializeToElement(value);
await dbContext.SaveChangesAsync();
await scope.ServiceProvider.GetRequiredService<IAuthorizationStateInvalidator>()
.BumpScopeAsync(AuthRealm.Tenant, tenantId);
}
private static async Task<JsonDocument> ReadJsonAsync(HttpResponseMessage response)
@@ -312,4 +316,4 @@ public sealed class ContentManagementEndpointTests
var stream = await response.Content.ReadAsStreamAsync();
return await JsonDocument.ParseAsync(stream);
}
}
}

View File

@@ -7,6 +7,8 @@ using Microsoft.Extensions.DependencyInjection;
using Tiku.Api.Contracts;
using Tiku.Application.Commerce;
using Tiku.Application.Jobs;
using Tiku.Application.Auth;
using Tiku.Application.Security;
using Tiku.Domain.Catalog;
using Tiku.Domain.Commerce;
using Tiku.Domain.Identity;
@@ -676,6 +678,8 @@ public sealed class TenantCommerceEndpointTests
item.TenantId == tenantId && item.Code == "integration_test_admin");
role.DataScope = JsonSerializer.SerializeToElement(value);
await dbContext.SaveChangesAsync();
await scope.ServiceProvider.GetRequiredService<IAuthorizationStateInvalidator>()
.BumpScopeAsync(AuthRealm.Tenant, tenantId);
}
private sealed record LoginSeed(Guid TenantId, Guid UserId, string Phone);
@@ -698,4 +702,4 @@ public sealed class TenantCommerceEndpointTests
throw new NotSupportedException();
}
}
}
}