Three fixes for the failing CI checks (PHP api, PHP integration): 1. RouteScopeTest.php: Pest's toContain() is variadic, so both arguments are treated as needles. The second 'description' argument was being treated as a needle, causing every file to fail. Removed the misleading second argument. 2. Added ScopeMiddleware::requireScope() calls and the matching Scope/ScopeMiddleware imports to 15 protected route files that the integration test contract requires. 3. documentation/auth/route-scope-audit.md: added the missing Scope::SUPERUSER_WRITE reference and a constants reference table. Also registered tests/auth/StripeInvoiceEmailTemplateTest.php in the legacy test manifest.
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace routes;
|
|
|
|
use classes\attachment_store;
|
|
use classes\response;
|
|
use traits\route_t;
|
|
|
|
use app\auth\Scope;
|
|
use app\auth\ScopeMiddleware;
|
|
|
|
class attachmentsRoute
|
|
{
|
|
use route_t;
|
|
|
|
public function run(): void
|
|
{
|
|
$this->get('/attachments/example', function (): never {
|
|
ScopeMiddleware::requireScope(Scope::CUSTOMER_READ, '/attachments/example');
|
|
throw new \Exception('EXAMPLE ROUTE, SHOULD BE IMPLEMENTED IN THE INDIVIDUAL OBJECT ROUTES');
|
|
});
|
|
$this->post('/attachments/upload', function () {
|
|
ScopeMiddleware::requireScope(Scope::CUSTOMER_WRITE, '/attachments/upload');
|
|
global $response;
|
|
self::requireParameters(['base64_image']);
|
|
$base64_image = self::getParameter('base64_image');
|
|
//self::requirePermission('modules_scanner_lpr');
|
|
if (empty($base64_image)) {
|
|
$response->error('Base64 image is required.');
|
|
}
|
|
$uploads = new attachment_store();
|
|
$object_name = $uploads->storeTempImageFromBase64(
|
|
$base64_image
|
|
);
|
|
echo $object_name;
|
|
$response->success(['object_name' => $object_name]);
|
|
});
|
|
}
|
|
}
|