d98cd83fe5
- StatusSession: ответ на ванильный статус на том же порту. Первый байт потока различает наш протокол и гостей: R - наш кадр, иначе старый пинг (FE) или новый handshake + request + ping. Логин в старом стиле получает вежливый отказ словами. - Reader: первый байт, уже прочитанный вручную, теперь правильно исключается из головы - раньше счётчик дважды пропускал его. - TokenAuth: точные причины отказа (не подписано, другой сервер, не тот вид, истёк, не тот игрок) и Verdict для каждой сессии. - ClientSession: первое чтение смотрит на байт и отдаёт гостей статусу; остальное идёт через прежнее расщепление. - StatusTest: 5 проверок (json, modern, pong, legacy, отказ). Легаси-пинг читался как знаковый байт; исправлено на беззнаковый. - StatusRouteTest: 3 проверки через настоящий сервер и настоящие порты. - watch-game.ps1: удаляет устаревший dev-token перед стартом сервера.
73 lines
3.0 KiB
PowerShell
73 lines
3.0 KiB
PowerShell
# End to end test: a real server, a real socket, a real login.
|
|
#
|
|
# This is the test that matters for the login path. A unit test can show that a
|
|
# hash matches itself; only this shows that somebody can actually register,
|
|
# connect, prove a password, get a token, redeem it and arrive as a player, and
|
|
# that a wrong password does not.
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$Repo = Split-Path -Parent $PSScriptRoot
|
|
if (-not $Repo) { $Repo = $PSCommandPath | Split-Path -Parent | Split-Path -Parent }
|
|
$Workspace = Split-Path -Parent $Repo
|
|
$Out = Join-Path $Repo 'build'
|
|
|
|
function Say($text) { Write-Host " $text" -ForegroundColor Cyan }
|
|
|
|
$Protocol = Join-Path $Workspace 'rsx-protocol\build\classes'
|
|
$Auth = Join-Path $Workspace 'rsx-auth\build\classes'
|
|
$PluginApi = Join-Path $Workspace 'rsx-plugin-api\build\classes'
|
|
foreach ($dep in @($Protocol, $Auth, $PluginApi)) {
|
|
if (-not (Test-Path $dep)) {
|
|
Write-Host " Missing dependency: $dep" -ForegroundColor Red
|
|
Write-Host ' Build rsx-protocol, rsx-auth and rsx-plugin-api first.' -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $Out | Out-Null
|
|
|
|
$mainOut = Join-Path $Out 'classes'
|
|
Remove-Item $mainOut -Recurse -Force -ErrorAction SilentlyContinue
|
|
New-Item -ItemType Directory -Force -Path $mainOut | Out-Null
|
|
$mainFiles = @(Get-ChildItem (Join-Path $Repo 'src\main\java') -Recurse -Filter '*.java' |
|
|
ForEach-Object { $_.FullName })
|
|
$cp = "$Protocol;$Auth;$PluginApi"
|
|
& javac -encoding UTF-8 --release 17 -Xlint:-options -nowarn -cp $cp -d $mainOut $mainFiles
|
|
if ($LASTEXITCODE -ne 0) { Write-Host ' Main failed.' -ForegroundColor Red; exit 1 }
|
|
|
|
$testOut = Join-Path $Out 'test-classes'
|
|
Remove-Item $testOut -Recurse -Force -ErrorAction SilentlyContinue
|
|
New-Item -ItemType Directory -Force -Path $testOut | Out-Null
|
|
$testFiles = @(Get-ChildItem (Join-Path $Repo 'src\test\java') -Recurse -Filter '*.java' |
|
|
ForEach-Object { $_.FullName })
|
|
& javac -encoding UTF-8 --release 17 -Xlint:-options -nowarn -cp "$cp;$mainOut" -d $testOut $testFiles
|
|
if ($LASTEXITCODE -ne 0) { Write-Host ' Test failed to compile.' -ForegroundColor Red; exit 1 }
|
|
Say "compiled $($mainFiles.Count) main + $($testFiles.Count) test files"
|
|
|
|
$suites = @(
|
|
'net.rustnotmc.server.ServerTest',
|
|
'net.rustnotmc.server.world.WorldTest',
|
|
'net.rustnotmc.server.world.NodeTest',
|
|
'net.rustnotmc.server.world.LodTest',
|
|
'net.rustnotmc.server.item.InventoryTest',
|
|
'net.rustnotmc.server.craft.CraftTest',
|
|
'net.rustnotmc.server.hitbox.HitboxTest',
|
|
'net.rustnotmc.server.player.PlayerDataTest',
|
|
'net.rustnotmc.server.combat.DamageTest',
|
|
'net.rustnotmc.server.status.StatusTest',
|
|
'net.rustnotmc.server.status.StatusRouteTest',
|
|
'net.rustnotmc.server.PlayTest'
|
|
)
|
|
foreach ($suite in $suites) {
|
|
Say "running $suite"
|
|
& java -cp "$cp;$mainOut;$testOut" $suite (Join-Path $Out 'selftest')
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host ''
|
|
Write-Host " $suite FAILED" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
Write-Host ''
|
|
Write-Host ' Server tests passed.' -ForegroundColor Green |