fix: актуальные ресурсы Zoomzilla и проверяемый выпуск (refs #11)
This commit is contained in:
1 parent
144dda6d88
commit
e9a2a0d568
25 files changed
+1255
-67
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/** preland#11: разрешено менять только согласованный ключ requisites. */
|
||||
declare(strict_types=1);
|
||||
$root = dirname(__DIR__);
|
||||
$expected = json_decode(file_get_contents($root . '/release/requisites.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
$saved = json_decode(file_get_contents($root . '/config.json'), true, 512, JSON_THROW_ON_ERROR);
|
||||
if (($saved['requisites'] ?? null) !== $expected) {
|
||||
fwrite(STDERR, "FAILED: Git config содержит старые реквизиты\n"); exit(1);
|
||||
}
|
||||
$raw = "{\n \"host\" : \"custom.example\", \"nested\":{\"requisites\":[\"do not change\"]},\n \"requisites\": [\"old\",\"escaped \\\"quote\"], \"utm\" : {\"focus\":\"custom\"}, \"unknown\":\"\\u0041\"\n}\n";
|
||||
$path = tempnam(sys_get_temp_dir(), 'requs-');
|
||||
try {
|
||||
foreach ([$raw, '{"host":"other.example","unknown":{"a":1}}'] as $fixture) {
|
||||
file_put_contents($path, $fixture);
|
||||
exec(PHP_BINARY . ' ' . escapeshellarg($root . '/bin/ensure-requisites-config.php') . ' ' . escapeshellarg($path), $output, $code);
|
||||
if ($code !== 10) throw new RuntimeException('Ожидалась точечная замена requisites');
|
||||
$after = file_get_contents($path);
|
||||
$beforeData = json_decode($fixture, true, 512, JSON_THROW_ON_ERROR);
|
||||
$afterData = json_decode($after, true, 512, JSON_THROW_ON_ERROR);
|
||||
if ($afterData['requisites'] !== $expected) throw new RuntimeException('Реквизиты не заменены');
|
||||
unset($beforeData['requisites'], $afterData['requisites']);
|
||||
if ($beforeData !== $afterData) throw new RuntimeException('Другие значения изменены');
|
||||
if (isset($afterData['nested']) && !str_contains($after, '"unknown":"\\u0041"')) throw new RuntimeException('Изменены байты чужих полей');
|
||||
exec(PHP_BINARY . ' ' . escapeshellarg($root . '/bin/ensure-requisites-config.php') . ' ' . escapeshellarg($path), $output, $code);
|
||||
if ($code !== 0 || file_get_contents($path) !== $after) throw new RuntimeException('Повторная операция не идемпотентна');
|
||||
}
|
||||
} finally { unlink($path); }
|
||||
echo "OK: requisites-only, чужие поля/байты сохранены, повторный запуск без изменений\n";
|
||||
Reference in new issue
Block a user