Skip to content

Commit b64de9d

Browse files
committed
[FIX] tests
1 parent b40da33 commit b64de9d

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ DEMO_PORT ?= 8787
1313
DEMO_BASE_URL ?= http://$(DEMO_HOST):$(DEMO_PORT)
1414
DEMO_SERVER_HANDLE ?= content
1515
DEMO_DISPATCH_CHECK ?= 1
16-
DEMO_JWT_SECRET ?= emcp-demo-secret
16+
DEMO_JWT_SECRET ?= emcp-demo-secret-0123456789abcdef0123456789abcdef
1717
SAPI_BASE_PATH ?= api
1818
SAPI_VERSION ?= v1
1919

scripts/demo_verify.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@ DEMO_ADMIN_USERNAME=${DEMO_ADMIN_USERNAME:-admin}
1515
DEMO_ADMIN_PASSWORD=${DEMO_ADMIN_PASSWORD:-123456}
1616
EMCP_SERVER_HANDLE=${EMCP_SERVER_HANDLE:-content}
1717
EMCP_DISPATCH_CHECK=${EMCP_DISPATCH_CHECK:-1}
18-
SAPI_JWT_SECRET=${SAPI_JWT_SECRET:-emcp-demo-secret}
18+
SAPI_JWT_SECRET=${SAPI_JWT_SECRET:-emcp-demo-secret-0123456789abcdef0123456789abcdef}
1919
SAPI_BASE_PATH=${SAPI_BASE_PATH:-api}
2020
SAPI_VERSION=${SAPI_VERSION:-v1}
2121
SERVER_LOG=${SERVER_LOG:-/tmp/emcp-demo-php-server.log}
2222
SERVER_PID=
2323

24+
if [ "${#SAPI_JWT_SECRET}" -lt 32 ]; then
25+
echo "[demo-verify] SAPI_JWT_SECRET is shorter than 32 chars; using SHA-256 normalized secret for compatibility."
26+
SAPI_JWT_SECRET=$(printf '%s' "${SAPI_JWT_SECRET}" | php -r '
27+
$secret = stream_get_contents(STDIN);
28+
if (!is_string($secret) || $secret === "") {
29+
$secret = "emcp-demo-secret";
30+
}
31+
echo hash("sha256", $secret);
32+
')
33+
fi
34+
2435
case "${DEMO_DIR}" in
2536
/*) DEMO_DIR_PATH="${DEMO_DIR}" ;;
2637
*) DEMO_DIR_PATH="${REPO_ROOT}/${DEMO_DIR}" ;;

src/eMCPServiceProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ protected function registerMiddlewareAliases(): void
115115
{
116116
$router = $this->app->router;
117117

118+
// Compatibility fallback for environments where "web" middleware group
119+
// is not pre-registered (required by sApi routes).
120+
$router->middlewareGroup('web', (array)config('app.middleware.web', []));
121+
122+
// Compatibility fallback: some sApi builds define "sapi.access" in routes
123+
// but don't register its middleware alias in the service provider.
124+
if (class_exists(\Seiger\sApi\Http\Middleware\ApiAccessLogMiddleware::class)) {
125+
$router->aliasMiddleware('sapi.access', \Seiger\sApi\Http\Middleware\ApiAccessLogMiddleware::class);
126+
}
127+
118128
$router->aliasMiddleware('emcp.permission', EnsureMcpPermission::class);
119129
$router->aliasMiddleware('emcp.jwt', EnsureApiJwt::class);
120130
$router->aliasMiddleware('emcp.scope', EnsureMcpScopes::class);

0 commit comments

Comments
 (0)