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
+4
View File
@@ -2,6 +2,10 @@
MageSail (`MageSail_Magesail`) integrates [Holesail](https://www.npmjs.com/package/holesail) with Magento 2 Admin: tunnel lifecycle, optional NGINX global-map updates, and storefront routing for tunneled hosts.
## Development tests (repository root)
PHPUnit, PHPStan (tests + scanned `Model/`), and PHPCS run from the repo root after `composer install` — see the root [`composer.json`](../composer.json), [`phpunit.xml.dist`](../phpunit.xml.dist), and [`.github/workflows/ci.yml`](../.github/workflows/ci.yml).
## Guides
| Document | Description |
+14 -10
View File
@@ -2,15 +2,15 @@
Admin route prefix: **`magesail`** (see [`Magesail/etc/adminhtml/routes.xml`](../Magesail/etc/adminhtml/routes.xml)). URLs are under your Magento admin base (`/admin_xxx/magesail/...`).
## Menu: MageSail → Holesail Tunnel
## Menu: MageSail
Defined in [`Magesail/etc/adminhtml/menu.xml`](../Magesail/etc/adminhtml/menu.xml). The module registers a **top-level** admin sidebar entry **MageSail** with `sortOrder="78"`. The sail icon uses `.admin__menu .item-magesail.parent.level-0 > a:before` in [`view/adminhtml/web/css/magesail-admin-menu.css`](../Magesail/view/adminhtml/web/css/magesail-admin-menu.css), following the same stacked-icon layout as Magentos `.admin__menu-link()` pattern in the admin theme (`_menu.less`: block `::before`, `margin-bottom` on level-0 links).
Defined in [`Magesail/etc/adminhtml/menu.xml`](../Magesail/etc/adminhtml/menu.xml). The module registers a **top-level** admin sidebar entry **MageSail** (`resource` **`MageSail_Magesail::magesail`**) with `sortOrder="78"`. **Holesail Tunnel** (Manage Tunnel, How-To, About) is grouped under a submenu; **NGINX Global Map** and **Configuration** are direct children of **MageSail** so admins with only **config** ACL still see those items. The sail icon uses `.admin__menu .item-magesail.parent.level-0 > a:before` in [`view/adminhtml/web/css/magesail-admin-menu.css`](../Magesail/view/adminhtml/web/css/magesail-admin-menu.css).
### Manage Tunnel
- **Action**: `magesail/tunnel/index` → [`Controller/Adminhtml/Tunnel/Index.php`](../Magesail/Controller/Adminhtml/Tunnel/Index.php)
- **Layout / template**: [`view/adminhtml/layout/magesail_tunnel_index.xml`](../Magesail/view/adminhtml/layout/magesail_tunnel_index.xml), [`view/adminhtml/templates/tunnel/index.phtml`](../Magesail/view/adminhtml/templates/tunnel/index.phtml)
- **Block**: [`Block/Adminhtml/Tunnel.php`](../Magesail/Block/Adminhtml/Tunnel.php)
- **Block**: [`Block/Adminhtml/Tunnel.php`](../Magesail/Block/Adminhtml/Tunnel.php) — UI init JSON for RequireJS [`magesail-tunnel-ui.js`](../Magesail/view/adminhtml/web/js/magesail-tunnel-ui.js) via `x-magento-init` in the template.
The same URL shows two in-page tabs: **Tunnels list** (grid, log tails, start/stop/remove) and **Add a tunnel** (provision form). With no tunnels yet, the **Add a tunnel** tab is selected by default. Optional URL fragments `#magesail-list` and `#magesail-add` (also `#list` / `#add`) open the corresponding tab after load. Long-running actions (**Create and start tunnel**, **Start** / **Stop** / **Remove** on a row) show an in-page **Please wait…** overlay; after a successful create or any successful reload, the URL is set to `#magesail-list` before reload so **Tunnels list** is active.
@@ -51,7 +51,7 @@ Start/stop/delete return JSON when the request is AJAX (`X-Requested-With: XMLHt
### NGINX Global Map
- **Action**: `magesail/nginx/map` → [`Controller/Adminhtml/Nginx/Map.php`](../Magesail/Controller/Adminhtml/Nginx/Map.php)
- **Block / template**: [`Block/Adminhtml/Nginx/Map.php`](../Magesail/Block/Adminhtml/Nginx/Map.php), [`view/adminhtml/templates/nginx/map.phtml`](../Magesail/view/adminhtml/templates/nginx/map.phtml)
- **Block / template**: [`Block/Adminhtml/Nginx/Map.php`](../Magesail/Block/Adminhtml/Nginx/Map.php), [`view/adminhtml/templates/nginx/map.phtml`](../Magesail/view/adminhtml/templates/nginx/map.phtml) — editor logic in [`magesail-nginx-map.js`](../Magesail/view/adminhtml/web/js/magesail-nginx-map.js) with translated strings from the block.
Full-screen tools for the configured **global map** file: on load, **Parse & Load Blocks** runs automatically (when the map path is configured); read raw content, write, parse into blocks, save blocks, run **`nginx -t`** via a minimal generated config, trigger reload (or wrapper), and diagnostics. Sub-actions are selected with request param **`action`**: `read`, `write`, `validate`, `reload`, `parse`, `save_blocks`, `diagnostics` (AJAX/JSON when `X-Requested-With: XMLHttpRequest` or `ajax=1`).
@@ -67,7 +67,7 @@ Requires **`MageSail_Magesail::config`** ACL resource. Operational details: [ngi
- **Action**: `magesail/howto/index` → [`Controller/Adminhtml/Howto/Index.php`](../Magesail/Controller/Adminhtml/Howto/Index.php)
- **Layout / template**: [`view/adminhtml/layout/magesail_howto_index.xml`](../Magesail/view/adminhtml/layout/magesail_howto_index.xml), [`view/adminhtml/templates/howto/index.phtml`](../Magesail/view/adminhtml/templates/howto/index.phtml)
- **Menu id**: `MageSail_Magesail::howto` listed after **Configuration** under **Holesail Tunnel**; **ACL**: `MageSail_Magesail::tunnel`.
- **Menu id**: `MageSail_Magesail::howto` — under **Holesail Tunnel**; **ACL**: `MageSail_Magesail::tunnel_view`.
In-page guide: recommends **Holesail Browser** (extension) as the primary client for Magento; tunnel workflow; copy-paste examples for **NGINX**, **Apache httpd**, **NGINX Proxy Manager**, and **cURL**; CLI/npm option; **Use TLS** when using local port **443**; security notes; pointers to multistore / NGINX docs. Styles: [`magesail-howto.css`](../Magesail/view/adminhtml/web/css/magesail-howto.css).
@@ -77,13 +77,17 @@ In-page guide: recommends **Holesail Browser** (extension) as the primary client
- **Layout / template**: [`view/adminhtml/layout/magesail_about_index.xml`](../Magesail/view/adminhtml/layout/magesail_about_index.xml), [`view/adminhtml/templates/about/index.phtml`](../Magesail/view/adminhtml/templates/about/index.phtml)
- **Block**: [`Block/Adminhtml/About.php`](../Magesail/Block/Adminhtml/About.php) reads [`composer.json`](../Magesail/composer.json) for name, version, description, license; Packagist link; `getCopyrightNotice()` for the legal line.
- **Template**: in-depth **About this module** (purpose, Manage Tunnel / store views / routing / NGINX map / cron), **Documentation** pointer to `docs/`, footer **Copyright (C) 2026 LIVEPORT P2P SOLUTIONS PVT. LTD.** Styles: [`magesail-about.css`](../Magesail/view/adminhtml/web/css/magesail-about.css).
- **Menu id**: `MageSail_Magesail::about` — after **How-To**; **ACL**: `MageSail_Magesail::tunnel`.
- **Menu id**: `MageSail_Magesail::about` — after **How-To**; **ACL**: `MageSail_Magesail::tunnel_view`.
## ACL
[`Magesail/etc/acl.xml`](../Magesail/etc/acl.xml):
[`Magesail/etc/acl.xml`](../Magesail/etc/acl.xml) (nested under **`MageSail_Magesail::magesail`** → **`MageSail_Magesail::tunnel`**):
- **`MageSail_Magesail::tunnel`** — Manage Tunnel and related tunnel actions.
- **`MageSail_Magesail::config`** — Configuration section and NGINX Global Map menu item.
- **`MageSail_Magesail::magesail`** — Top-level **MageSail** menu visibility (see data patch below).
- **`MageSail_Magesail::tunnel_view`** — View **Manage Tunnel** (grid, log tail, status polling), **How-To**, **About**. Does **not** allow create/start/stop/remove (those return “not allowed”).
- **`MageSail_Magesail::tunnel_manage`** — Mutating tunnel actions (create/start/stop/remove) in addition to what **view** allows when combined with **tunnel_view** for the UI.
- **`MageSail_Magesail::config`** — **Configuration** redirect and **NGINX Global Map** editor.
Assign roles under **System → Permissions → User Roles**.
Legacy installs that had only **`MageSail_Magesail::tunnel`** or **`MageSail_Magesail::config`** in `authorization_rule` receive extra rules from [`Setup/Patch/Data/GrantMagesailMenuAcl.php`](../Magesail/Setup/Patch/Data/GrantMagesailMenuAcl.php) on `setup:upgrade`: **`magesail`** menu ACL; roles with **tunnel** also get **tunnel_view** and **tunnel_manage** so behavior stays full-access until you tighten roles.
**Status / Logtail** controllers allow **tunnel**, **tunnel_view**, or **tunnel_manage** (or legacy **tunnel** rule). Assign roles under **System → Permissions → User Roles**.
+1 -1
View File
@@ -27,7 +27,7 @@ Controlled only by Admin config **Auto-restart on crash** — no code changes in
## Database log table
[`MagesailLog`](../Magesail/Model/MagesailLog.php) inserts into **`magesail_logs`** (`message`, `created_at`), created by [`Setup/InstallSchema.php`](../Magesail/Setup/InstallSchema.php). Messages are truncated to 255 characters.
[`MagesailLog`](../Magesail/Model/MagesailLog.php) inserts into **`magesail_logs`** (`message`, `created_at`), defined in [`db_schema.xml`](../Magesail/etc/db_schema.xml). Messages are truncated to 255 characters.
## File logs
+6 -2
View File
@@ -3,7 +3,7 @@
## Requirements
- **Magento 2**: 2.4.x (framework alignment via Composer; see [`Magesail/composer.json`](../Magesail/composer.json)).
- **PHP**: 8.1, 8.2, or 8.3 (`~8.1||~8.2||~8.3` in composer).
- **PHP**: 8.18.4 (see [`Magesail/composer.json`](../Magesail/composer.json)).
- **Node.js**: 18+ recommended for the Holesail script.
- **npm**: To install dependencies under `Magesail/scripts/`.
- **Shell**: `ps`, `kill`, `nohup` (Linux/macOS typical).
@@ -42,6 +42,10 @@ php bin/magento setup:di:compile
php bin/magento cache:flush
```
## Database schema
The `magesail_logs` table is defined in declarative schema [`Magesail/etc/db_schema.xml`](../Magesail/etc/db_schema.xml). Older releases used `Setup/InstallSchema.php`; that installer was removed in favor of `setup:upgrade` + declarative schema only. Existing installations that already ran the old installer keep their table; new installs get the same structure from `db_schema.xml`.
## Node dependencies
One-time (from the `scripts` directory — use the path that matches your install):
@@ -58,7 +62,7 @@ npm install
- `php bin/magento module:status MageSail_Magesail` → enabled.
- Admin: **MageSail → Holesail Tunnel** appears (**Manage Tunnel**, **NGINX Global Map**, **Configuration**) in the main sidebar as a **top-level** **MageSail** entry (no dependency on other extensions).
- Database: table `magesail_logs` after `setup:upgrade` (see [`Setup/InstallSchema.php`](../Magesail/Setup/InstallSchema.php)).
- Database: table `magesail_logs` after `setup:upgrade` (see [`db_schema.xml`](../Magesail/etc/db_schema.xml)).
- Optional: open **Manage Tunnel**, add a test tunnel (website/group, port, hostname), then **Remove** if you only wanted to verify the UI.
## Upgrading from older single-tunnel MageSail
+1 -1
View File
@@ -50,7 +50,7 @@ See [request-routing-and-plugins.md](request-routing-and-plugins.md) for behavio
| Class | File | Responsibility |
|-------|------|------------------|
| `InstallSchema` | `Setup/InstallSchema.php` | Creates `magesail_logs` table. |
| (declarative) | [`etc/db_schema.xml`](../Magesail/etc/db_schema.xml) | Declares `magesail_logs` table. |
## Scripts shipped as PHP (not autoloaded as module code)