本轮完成了完整的通知公告管理迁移:

原生 GET /api/admin/notices
原生五类系统公示聚合:计划、资格、录取、分数线、报到
原生 PATCH /api/admin/publications/{type}/{id} 显隐控制
权限、事务审计和 Node 返回结构保持一致
开关升级为 ADMIN_NATIVE_NOTICE_MANAGEMENT_ENABLED
兼容旧变量 ADMIN_NATIVE_NOTICE_WRITES_ENABLED
冒烟脚本现在会自动构建 Web,避免使用过期程序集
This commit is contained in:
2026-07-23 08:58:12 +08:00 Unverified
parent 9e21a277f0
commit e845ba8d3a
13 changed files with 597 additions and 37 deletions
+64 -4
View File
@@ -249,9 +249,23 @@ try {
}
$registrationSwitchProcess.Dispose()
$nodeProcess = Start-TestProcess -FileName $nodeExecutable -ArgumentList @('server.mjs') -Environment $nodeEnvironment
$projectPath = Join-Path $repositoryRoot 'src\Eis.Web\Eis.Web.csproj'
$buildProcess = Start-TestProcess -FileName $dotnetExecutable -ArgumentList @(
'build', $projectPath,
'--configuration', 'Release'
) -Environment @{}
if (-not $buildProcess.WaitForExit(60000)) {
$buildProcess.Kill($true)
throw 'Timed out while building the ASP.NET Core migration host'
}
$buildOutput = $buildProcess.StandardOutput.ReadToEnd()
$buildError = $buildProcess.StandardError.ReadToEnd()
if ($buildProcess.ExitCode -ne 0) {
throw "Failed to build the ASP.NET Core migration host`n$buildOutput`n$buildError"
}
$buildProcess.Dispose()
$nodeProcess = Start-TestProcess -FileName $nodeExecutable -ArgumentList @('server.mjs') -Environment $nodeEnvironment
$dotnetProcess = Start-TestProcess -FileName $dotnetExecutable -ArgumentList @(
'run',
'--project', $projectPath,
@@ -426,7 +440,7 @@ try {
ADMIN_NATIVE_ORGANIZATION_WRITES_ENABLED = 'true'
ADMIN_NATIVE_ACCOUNT_BATCHES_ENABLED = 'true'
ADMIN_NATIVE_CONFIGURATION_ENABLED = 'true'
ADMIN_NATIVE_NOTICE_WRITES_ENABLED = 'true'
ADMIN_NATIVE_NOTICE_MANAGEMENT_ENABLED = 'true'
ADMIN_NATIVE_ALLOW_MEMORY = 'true'
LegacyNode__Enabled = 'true'
LegacyNode__BaseUrl = $legacyBaseUrl
@@ -726,6 +740,52 @@ try {
throw "Native admin route '$superOnlyRoute' did not preserve the super-admin boundary"
}
}
$legacyNoticeManagement = Invoke-WebRequest -Uri "$legacyBaseUrl/api/admin/notices" -WebSession $session
$nativeNoticeManagement = Invoke-WebRequest -Uri "$nativeAuthBaseUrl/api/admin/notices" -WebSession $nativeSession
if ($nativeNoticeManagement.Headers['X-EIS-Implementation'] -ne 'aspnet-core') {
throw 'Native notice management list did not use ASP.NET Core'
}
Assert-JsonEquivalent -Expected $legacyNoticeManagement.Content -Actual $nativeNoticeManagement.Content -Label 'Admin notice management list'
$schoolNoticeManagementForbidden = Invoke-WebRequest -Uri "$nativeAuthBaseUrl/api/admin/notices" -WebSession $nativeSchoolSession -SkipHttpErrorCheck
if ($schoolNoticeManagementForbidden.StatusCode -ne 403 -or $schoolNoticeManagementForbidden.Headers['X-EIS-Implementation'] -ne 'aspnet-core') {
throw 'Native notice management list did not preserve the super-admin boundary'
}
$noticeManagementState = $nativeNoticeManagement.Content | ConvertFrom-Json
$managedPlan = @($noticeManagementState.publications | Where-Object { $_.sourceType -eq 'plan' })[0]
if ($null -eq $managedPlan) {
throw 'Seed data did not provide a system plan publication for notice-management smoke testing'
}
$invalidPublicationVisibility = Invoke-WebRequest -Uri "$nativeAuthBaseUrl/api/admin/publications/plan/$($managedPlan.id)" -Method Patch -ContentType 'application/json' -Body (@{ visible = 'false' } | ConvertTo-Json -Compress) -WebSession $nativeSession -SkipHttpErrorCheck
if ($invalidPublicationVisibility.StatusCode -ne 400 -or $invalidPublicationVisibility.Headers['X-EIS-Implementation'] -ne 'aspnet-core') {
throw 'Native system-publication update accepted a non-boolean visibility value'
}
$missingPublication = Invoke-WebRequest -Uri "$nativeAuthBaseUrl/api/admin/publications/plan/missing-publication" -Method Patch -ContentType 'application/json' -Body (@{ visible = $false } | ConvertTo-Json -Compress) -WebSession $nativeSession -SkipHttpErrorCheck
if ($missingPublication.StatusCode -ne 404) {
throw 'Native system-publication update did not return 404 for a missing record'
}
$schoolPublicationForbidden = Invoke-WebRequest -Uri "$nativeAuthBaseUrl/api/admin/publications/plan/$($managedPlan.id)" -Method Patch -ContentType 'application/json' -Body (@{ visible = $false } | ConvertTo-Json -Compress) -WebSession $nativeSchoolSession -SkipHttpErrorCheck
if ($schoolPublicationForbidden.StatusCode -ne 403) {
throw 'Native system-publication update did not preserve the super-admin boundary'
}
$hiddenPublicationResponse = Invoke-WebRequest -Uri "$nativeAuthBaseUrl/api/admin/publications/plan/$($managedPlan.id)" -Method Patch -ContentType 'application/json' -Body (@{ visible = $false } | ConvertTo-Json -Compress) -WebSession $nativeSession
$hiddenPublication = ($hiddenPublicationResponse.Content | ConvertFrom-Json).publication
if ($hiddenPublicationResponse.Headers['X-EIS-Implementation'] -ne 'aspnet-core' -or $hiddenPublication.visible -ne $false -or $hiddenPublication.status -ne 'hidden') {
throw 'Native system-publication update did not hide the requested publication'
}
$hiddenAnnouncements = Invoke-RestMethod -Uri "$nativeAuthBaseUrl/api/public/announcements"
if (@($hiddenAnnouncements.plans | Where-Object { $_.id -eq $managedPlan.id }).Count -ne 0) {
throw 'Native public announcements still exposed a hidden system publication'
}
$restoredPublicationResponse = Invoke-WebRequest -Uri "$nativeAuthBaseUrl/api/admin/publications/plan/$($managedPlan.id)" -Method Patch -ContentType 'application/json' -Body (@{ visible = $true } | ConvertTo-Json -Compress) -WebSession $nativeSession
$restoredPublication = ($restoredPublicationResponse.Content | ConvertFrom-Json).publication
if ($restoredPublication.visible -ne $true -or $restoredPublication.status -ne 'visible') {
throw 'Native system-publication update did not restore the requested publication'
}
$restoredAnnouncements = Invoke-RestMethod -Uri "$nativeAuthBaseUrl/api/public/announcements"
if (@($restoredAnnouncements.plans | Where-Object { $_.id -eq $managedPlan.id }).Count -ne 1) {
throw 'Native public announcements did not restore a visible system publication'
}
$classLoginBody = @{ username = 'class_admin'; password = '12345678' } | ConvertTo-Json -Compress
$legacyClassSession = [Microsoft.PowerShell.Commands.WebRequestSession]::new()
$nativeClassSession = [Microsoft.PowerShell.Commands.WebRequestSession]::new()
@@ -1082,7 +1142,7 @@ try {
NativeAdminOrganizationWrites = 'passed'
NativeAdminAccountBatches = 'passed'
NativeAdminConfiguration = 'passed'
NativeAdminNoticeWrites = 'passed'
NativeAdminNoticeManagement = 'passed'
} | Format-List
}
finally {