Testing/CI/ACL

This commit is contained in:
2026-03-21 03:01:08 -05:00
parent d1316c8fd6
commit dcebbceb88
60 changed files with 3141 additions and 1479 deletions
+18 -1
View File
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace MageSail\Magesail\Model;
@@ -6,6 +7,7 @@ namespace MageSail\Magesail\Model;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Shell;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface;
/**
* Start/stop tunnel processes per tunnel id; shared by admin Index and cron auto-restart.
@@ -22,7 +24,8 @@ class TunnelManager
private readonly ScopeConfigInterface $scopeConfig,
private readonly EventManager $eventManager,
private readonly TunnelRegistry $tunnelRegistry,
private readonly TunnelProcessPaths $tunnelProcessPaths
private readonly TunnelProcessPaths $tunnelProcessPaths,
private readonly LoggerInterface $logger
) {
}
@@ -68,9 +71,20 @@ class TunnelManager
}
$dir = $this->tunnelProcessPaths->getVarTunnelDir();
if (!\is_dir($dir) && !@mkdir($dir, 0775, true) && !\is_dir($dir)) {
$this->logger->warning('MageSail: could not create var tunnel directory.');
return ['ok' => false, 'error' => 'could_not_create_var_dir'];
}
$scriptDir = $this->getScriptDir();
$startScript = rtrim($scriptDir, '/') . '/start-server.js';
if (!\is_readable($startScript)) {
$this->logger->warning('MageSail: start-server.js missing or not readable at {path}', ['path' => $startScript]);
return ['ok' => false, 'error' => 'script_not_found', 'detail' => $startScript];
}
$nodeModules = rtrim($scriptDir, '/') . '/node_modules';
if (!\is_dir($nodeModules)) {
$this->logger->warning('MageSail: npm dependencies missing (no node_modules in scripts directory). Path: {path}', ['path' => $scriptDir]);
return ['ok' => false, 'error' => 'node_modules_missing', 'detail' => $scriptDir];
}
$keyFile = $this->tunnelProcessPaths->getKeyFilePath($tunnelId);
$logFile = $this->tunnelProcessPaths->getLogFilePath($tunnelId);
$pidFile = $this->tunnelProcessPaths->getPidFilePath($tunnelId);
@@ -99,8 +113,10 @@ class TunnelManager
]);
return ['ok' => true, 'pid' => $pid];
}
$this->logger->warning('MageSail: failed to capture PID after start. Output: {output}', ['output' => $output]);
return ['ok' => false, 'error' => 'pid_capture_failed', 'detail' => $output];
} catch (\Throwable $e) {
$this->logger->error('MageSail: tunnel start exception: ' . $e->getMessage(), ['exception' => $e]);
return ['ok' => false, 'error' => $e->getMessage()];
}
}
@@ -135,6 +151,7 @@ class TunnelManager
]);
return ['ok' => true];
} catch (\Throwable $e) {
$this->logger->error('MageSail: tunnel stop exception: ' . $e->getMessage(), ['exception' => $e]);
return ['ok' => false, 'error' => $e->getMessage()];
}
}