Commit Graph
4 Commits
Author SHA1 Message Date
Divarion_D 6662e72798 refactor(geoip): generic GitHubReleases client + domain-owned release sync
Make the GitHub-release GeoIP updates cohesive and testable, and keep the
GitHubReleases class a generic release client.

- GitHubReleases: drop the domain-specific getGeolite()/getIspDatabase()/
  getAsnCatalog() and the private releaseAsset() — they hard-coded the
  maxmind paths and GeoIP filenames, which don't belong in a generic
  GitHub-releases client. Add the generic assetUrl($version, $asset)
  primitive; domain code now composes its own specs around it. Also drop a
  stale usage example that referenced the removed getGeolite().

- New XcVm\Core\GeoIP\GeoLiteReleaseUpdater owns the release-asset sync:
  builds the GeoLite2-City/Country and GeoIP2-ISP specs (url via assetUrl,
  md5 via getAssetHash, local maxmind path), downloads them through ONE
  path, and records the version into maxmind/version.json. This unifies
  GeoIP2-ISP with GeoLite2 — the ISP now gets the same dir self-heal,
  checksum-tolerant "always save" behaviour, status lines and chmod 0750
  (was 0640) instead of the leaner fetchReleaseFile() it used before.

- MaxMindCronJob is now a thin orchestrator (updateGeoLite/updateIsp);
  AsnCatalogSync builds its own blocked_asns spec via assetUrl/getAssetHash.

- Tests: GeoLiteReleaseUpdaterTest (specs/paths/version, error paths) via a
  mocked repo + protected download/record seams; GitHubReleasesTest covers
  assetUrl().
2026-09-10 16:11:29 +03:00
Divarion_D 567641137d test: fix stale update-channel tests and define BIN_PATH in bootstrap
Three unit tests were failing against correct production code:

- FfmpegPathsTest errored on an undefined BIN_PATH constant. The test
  bootstrap defined FFMPEG_BIN_* but not BIN_PATH, so FfmpegPaths::binary()
  faulted before it could fall back. Define BIN_PATH to a fixture-less path
  so version lookups miss and the FFMPEG_BIN_40 fallback is exercised.
- GitHubReleasesTest expected the old 'unstable' channel name; the channel
  was renamed to 'beta' ('unstable' kept as a legacy alias). Update the
  cache-switch test to expect 'beta' (and assert the alias normalizes), and
  make the reject-invalid test use a genuinely unknown channel ('nightly').

Full suite now green (461 passing).
2026-08-31 22:22:34 +03:00
Divarion-D da291e20f8 chore(psr4): phase 3 (Core) — namespace remaining Core subdirs
Namespace the rest of Core, completing the Core layer:
- Backup, Boundary, Cache (CacheInterface/FileCache/RedisCache), Diagnostics,
  GeoIP (GeoIPService/MaxMindUpdater), Init (LegacyInitializer), Localization
  (Translator), Process (Thread/Multithread/ProcessManager), Updates
  (GitHubReleases), Util (NetworkUtils, AdminHelpers, Encryption, GeoIP,
  ImageUtils/ImageResizeService, Mobile_Detect, StreamUtils, SystemInfo,
  TimeUtils), Validation (InputValidator) → XcVm\Core\<Subdir>.
- Rename GithubReleases.php → GitHubReleases.php so the file matches its class
  name (PSR-4 is case-sensitive); fix the WebApiBootstrap require accordingly.
- Qualify built-ins (\Exception, \DateTime, \DateTimeZone, \Redis,
  \RuntimeException, \BadMethodCallException, ...) and still-global deps
  (\ServerRepository, \CacheReader, \DatabaseFactory, \BouquetService,
  \CategoryService, \FfmpegPaths, \StreamSorter, \XC_VM). LegacyInitializer's
  Domain calls stay \-qualified (the known Core→Domain exception).
- Add use to referrers; fix leading-backslash refs from earlier commits; fix
  string class refs class_exists('Translator'/'NetworkUtils'/...) → ::class.
  Remove the duplicate global 'use BoundaryInterface;' in MinistraModule.
- phpstan-baseline.neon regenerated.

Core is now fully namespaced (procedural constant/error/RequestGuard files stay
global by design; M3uParser/PhpM3u8 remain vendored). Verified: php -l clean;
PHPStan no errors; PHPUnit 295/295; leading-backslash re-sweep clean.
2026-06-24 22:35:33 +03:00
Divarion-D e737025ff8 test: add targeted PHPUnit setup and docs, fix GitHubReleases cache switching
- add PHPUnit bootstrap and config under tests/
- add focused unit tests for GitHubReleases, InputValidator and FfmpegPaths
- fix GitHubReleases cache file handling when switching update channel
- document PHPUnit PHAR usage and debug run commands in RU/EN docs
- document SFTP sync for tests/ and contributor test workflow
- remove broad smoke coverage approach in favor of per-file tests
2026-04-17 22:55:54 +03:00