print text=slot-ok
- 2. *
- > print text=slot-order-fail
- 2. *
- > print text=slot-form-fail
-2. *
- > print text=slot-mount-fail
diff --git a/tests/ext/web-form-smoke.mq.md b/tests/ext/web-form-smoke.mq.md
deleted file mode 100644
index 565abe9..0000000
--- a/tests/ext/web-form-smoke.mq.md
+++ /dev/null
@@ -1,70 +0,0 @@
----
-title: web form smoke
-description: Offline form fields / validate / submit (no listen).
-import web:ext/web/web.mq.md
-import articles:web-fixtures/db/articles.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-**store = > web.db url="sqlite:web-fixtures/data/form-smoke.db"**
-**schema = > articles.schema**
-> `store`.init name=articles fields=`schema`
-
-`fields` =
-
-| 字段 | 标签 | 类型 | 必填 | 默认 |
-|------|------|------|------|------|
-| title | Title | text | true | |
-| body | Body | textarea | false | |
-
-`rules` =
-
-| 字段 | 规则 | 消息 |
-|------|------|------|
-| title | required | Title is required |
-| title | max:120 | Title is too long |
-
-**f = > web.form table="articles" action="insert"**
-**f = > `f`.fields fields=`fields`**
-**f = > `f`.rules rules=`rules`**
-
-`bad` =
-
-| title | body |
-|-------|------|
-| | hello |
-
-**v = > `f`.validate data=`bad`**
-**ok = > json.get value=`v` key="ok"**
-1. `ok`
- > print text=validate-should-fail
-2. *
- > print text=validate-ok
-
-`good` =
-
-| title | body |
-|-------|------|
-| From form | Body via submit |
-
-**sub = > `f`.submit data=`good` db=`store`**
-**sok = > json.get value=`sub` key="ok"**
-1. `sok`
- > print text=submit-ok
-2. *
- > print text=submit-fail
-
-**rows = > `store`.select table="articles" limit=10**
-**n = > len value=`rows`**
-1. `n` >= 1
- > print text=db-ok
-2. *
- > print text=db-fail
-
-**html = > `f`.render id="article"**
-1. `html`
- > print text=render-ok
-2. *
- > print text=render-fail
diff --git a/tests/ext/web-form-source-live-server.mq.md b/tests/ext/web-form-source-live-server.mq.md
deleted file mode 100644
index b2ceeb4..0000000
--- a/tests/ext/web-form-source-live-server.mq.md
+++ /dev/null
@@ -1,123 +0,0 @@
----
-title: web form source live server
-description: Request-context field sources — body only; author/slug stamped server-side.
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-`post_schema` =
-
-| 字段 | 类型 | 必填 |
-|------|------|------|
-| id | integer | false |
-| slug | text | true |
-| title | text | true |
-| content | text | true |
-
-`comment_schema` =
-
-| 字段 | 类型 | 必填 |
-|------|------|------|
-| id | integer | false |
-| post_slug | text | true |
-| author | text | true |
-| body | text | true |
-| created_at | text | false |
-
-**store = > web.db url="sqlite:web-fixtures/data/form-source-live.db"**
-> `store`.init name=posts fields=`post_schema`
-> `store`.init name=comments fields=`comment_schema`
-> `store`.exec sql="DELETE FROM comments"
-> `store`.exec sql="DELETE FROM posts"
-
-`seed` =
-
-| slug | title | content |
-|------|-------|---------|
-| hello | Hello | Body of hello |
-
-> `store`.insert table=posts rows=`seed`
-
-`detail` =
-
-| 属性 | 值 | 样式 |
-|------|-----|------|
-| title | posts.title | |
-| body | posts.content | |
-
-`post_q` =
-
-| 字段 | 操作 | 值 |
-|------|------|-----|
-| slug | = | {slug} |
-
-`comment_fields` =
-
-| 字段 | 标签 | 类型 | 必填 | 默认 | 来源 |
-|------|------|------|------|------|------|
-| body | Comment | textarea | true | | client |
-| author | | text | true | | session.username |
-| post_slug | | text | true | | route.slug |
-| created_at | | text | false | | now |
-
-`comment_rules` =
-
-| 字段 | 规则 | 消息 |
-|------|------|------|
-| body | required | body required |
-| author | required | login required |
-| post_slug | required | slug required |
-
-**cf = > web.form table="comments" action="insert"**
-**cf = > `cf`.fields fields=`comment_fields`**
-**cf = > `cf`.rules rules=`comment_rules`**
-
-`comment_cards` =
-
-| 属性 | 值 | 样式 |
-|------|-----|------|
-| title | comments.author | |
-| body | comments.body | |
-| meta | comments.created_at | |
-
-`comment_q` =
-
-| 字段 | 操作 | 值 |
-|------|------|-----|
-| post_slug | = | {slug} |
-
-**post = > web.page title="Post" intro=""**
-**post = > `post`.compose_main main=`detail`**
-**post = > `post`.query query=`post_q`**
-**post = > `post`.detail detail=True**
-**post = > `post`.compose_list main=`comment_cards` query=`comment_q` order="-created_at" target="#comment-list"**
-**post = > `post`.compose_form form=`cf` id="comment" target="#comment-form-mount"**
-
-`users` =
-
-| 行 | 用户 | 密码 |
-|----|------|------|
-| 1 | alice | secret |
-
-**app = > web.app page=`post` db=`store` port=18117**
-**app = > `app`.route path="/post/{slug}" page=`post`**
-**app = > `app`.auth users=`users` login_path="/login" login_redirect="/" session_ttl=3600**
-**app = > `app`.mount_form id="comment" form=`cf`**
-
-`api` =
-
-| 路径 | 方法 | 表 | 条件 | 排序 | 上限 |
-|------|------|----|------|------|------|
-| /api/comments | GET | comments | | "-created_at" | 50 |
-
-**app = > `app`.configure json=`api`**
-> `app`.listen
diff --git a/tests/ext/web-g12-api-key-smoke.mq.md b/tests/ext/web-g12-api-key-smoke.mq.md
deleted file mode 100644
index 6a50c62..0000000
--- a/tests/ext/web-g12-api-key-smoke.mq.md
+++ /dev/null
@@ -1,30 +0,0 @@
----
-title: web G12 API key smoke (W-G12)
-description: Offline web_api_key_check via Go libweb.so.
-import plugin:lib/plugin.mq.md
----
-
-# main
-
-**p = "../../plugins/web/build/libweb.so"**
-> plugin.load path=`p`
-
-**pepper = "smoke-pepper"**
-
-`keys` =
-
-| hash | scopes |
-|------|--------|
-| 0ae9134cca7eff9d756fbf52402ee28ae0c2be22f01e53653e4fe86021479703 | read,api |
-
-**ok = > web_api_key_check key="smoke-secret" authorization="" pepper=`pepper` keys=`keys`**
-1. [ok](ok)
- > print text=api-key-ok
-2. *
- > print text=api-key-fail
-
-**bad = > web_api_key_check key="wrong" authorization="" pepper=`pepper` keys=`keys`**
-1. [ok](bad)
- > print text=api-key-bad-ok
-2. *
- > print text=api-key-bad-fail
diff --git a/tests/ext/web-go-abi-smoke.mq.md b/tests/ext/web-go-abi-smoke.mq.md
deleted file mode 100644
index fe1dbb5..0000000
--- a/tests/ext/web-go-abi-smoke.mq.md
+++ /dev/null
@@ -1,16 +0,0 @@
----
-title: web Go ABI smoke (W-G0)
-description: Load Go libweb.so; probe web_go_ready + web_page_new.
-import plugin:lib/plugin.mq.md
----
-
-# main
-
-**p = "../../plugins/web/build/libweb.so"**
-> plugin.load path=`p`
-
-**r = > web_go_ready**
-> print text=`r`
-
-**page = > web_page_new title="Go Web" intro="W-G0" shell_css="" layout="" asset_version=""**
-> print text=`page`
diff --git a/tests/ext/web-hosting-helpers.mq.md b/tests/ext/web-hosting-helpers.mq.md
deleted file mode 100644
index db9c2b0..0000000
--- a/tests/ext/web-hosting-helpers.mq.md
+++ /dev/null
@@ -1,23 +0,0 @@
----
-title: web hosting live helpers
-description: Tiny lib used by hosting live-server invoke route (nested plugin call).
-import web:ext/web/web.mq.md
----
-
-## echo
-+ `msg`=""
-+ `payload`=None
-
-Nested plugin call (`web.page`) while `app.listen` is the outer plugin frame —
-must not clear GLOBAL_HOST so a second HTTP invoke still works.
-
-**pg = > web.page title=`msg`**
-**title = [title](pg)**
-
-`out` =
-
-| ok | msg | title |
-|----|-----|-------|
-| true | `msg` | `title` |
-
-*out*
diff --git a/tests/ext/web-hosting-live-server.mq.md b/tests/ext/web-hosting-live-server.mq.md
deleted file mode 100644
index 7e1599b..0000000
--- a/tests/ext/web-hosting-live-server.mq.md
+++ /dev/null
@@ -1,22 +0,0 @@
----
-title: web hosting live server
-description: Listen with proxy (→ mock upstream) and invoke routes for gold.rs.
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
-import demo:web-hosting-helpers.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-**pg = > web.page title="hosting-live"**
-**app = > web.app page=`pg` host=127.0.0.1 port=18141**
-**app = > `app`.proxy path="/proxy/sse" upstream="http://127.0.0.1:18142/sse" stream=True methods="POST"**
-**app = > `app`.invoke path="/api/echo" fn="demo.echo" method="POST" body="json"**
-> `app`.listen
diff --git a/tests/ext/web-intro-compose.mq.md b/tests/ext/web-intro-compose.mq.md
deleted file mode 100644
index 8c45e06..0000000
--- a/tests/ext/web-intro-compose.mq.md
+++ /dev/null
@@ -1,55 +0,0 @@
----
-title: web compose_intro bind table
-description: Intro uses the same front/back/style bind as compose_main.
-import web:ext/web/web.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-`intro` =
-
-| front | back | style |
-|-------|------|-------|
-| kicker | Demo kicker | kicker |
-| title | Hello | intro_title |
-| lede | "Try code and [link](/x)." | lede |
-| claim | A | claim |
-| claim | B | claim |
-| step | First step | step |
-
-**page = > web.page title="Intro bind"**
-**page = > page.compose_intro intro=intro**
-**html = > page.render**
-
-**a = > split value=`html` sep="class=\"kicker\""**
-**na = > len value=`a`**
-**b = > split value=`html` sep="class=\"intro_title\""**
-**nb = > len value=`b`**
-**c = > split value=`html` sep="href=\"/x\""**
-**nc = > len value=`c`**
-**d = > split value=`html` sep="class=\"claim\""**
-**nd = > len value=`d`**
-**e = > split value=`html` sep="class=\"steps\""**
-**ne = > len value=`e`**
-1. `na` > 1
- 1. `nb` > 1
- 1. `nc` > 1
- 1. `nd` > 1
- 1. `ne` > 1
- > print text=compose-intro-ok
- 2. *
- > print text=compose-intro-steps-missing
- > sys.exit code=1
- 2. *
- > print text=compose-intro-claim-missing
- > sys.exit code=1
- 2. *
- > print text=compose-intro-link-missing
- > sys.exit code=1
- 2. *
- > print text=compose-intro-title-missing
- > sys.exit code=1
-2. *
- > print text=compose-intro-kicker-missing
- > sys.exit code=1
diff --git a/tests/ext/web-middleware-live-server.mq.md b/tests/ext/web-middleware-live-server.mq.md
deleted file mode 100644
index 3ce4b67..0000000
--- a/tests/ext/web-middleware-live-server.mq.md
+++ /dev/null
@@ -1,62 +0,0 @@
----
-title: web middleware live server
-description: Offline-assembled app that listens with CORS/security/compress/body_limit/json.
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-`schema` =
-
-| 字段 | 类型 |
-|------|------|
-| title | text |
-| body | text |
-
-**store = > web.db url="sqlite:web-fixtures/data/mw-live.db"**
-> `store`.init name=articles fields=`schema`
-> `store`.exec sql="DELETE FROM articles"
-
-`rows` =
-
-| title | body |
-|-------|------|
-| Hello | first post |
-
-> `store`.insert table=articles rows=`rows`
-
-**pg = > web.page title="live"**
-**app = > web.app page=`pg` db=`store` port=18099**
-
-`cors` =
-
-| 允许来源 | 方法 | 头 | 暴露头 | 凭证 |
-|----------|------|----|--------|------|
-| https://a.example | GET,POST | Content-Type | X-Total | true |
-
-`sec` =
-
-| 头 | 值 |
-|----|----|
-| X-Frame-Options | DENY |
-| X-Content-Type-Options | nosniff |
-
-`api` =
-
-| 路径 | 方法 | 表 | 条件 | 排序 | 上限 |
-|------|------|----|----|----|------|
-| /api/posts | GET | articles | | | 10 |
-| /api/publish | POST | articles | | | 10 |
-
-**app = > `app`.configure cors=`cors` security=`sec` compress=True body_limit=1000 json=`api`**
-> `app`.listen
diff --git a/tests/ext/web-middleware-smoke.mq.md b/tests/ext/web-middleware-smoke.mq.md
deleted file mode 100644
index e778206..0000000
--- a/tests/ext/web-middleware-smoke.mq.md
+++ /dev/null
@@ -1,147 +0,0 @@
----
-title: web middleware smoke
-description: Offline assemble of CORS/security/compress/json middleware (no listen).
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-
-
-`cors` =
-
-| 允许来源 | 方法 | 头 | 暴露头 | 凭证 |
-|----------|------|----|--------|------|
-| https://a.example | GET,POST | Content-Type,Authorization | X-Total | true |
-| https://b.example | GET | Content-Type | | |
-
-
-
-`sec` =
-
-| 头 | 值 |
-|----|----|
-| X-Frame-Options | DENY |
-| X-Content-Type-Options | nosniff |
-| Content-Security-Policy | default-src 'self' |
-
-
-
-`api` =
-
-| 路径 | 方法 | 表 | 条件 | 排序 | 上限 |
-|------|------|----|----|----|------|
-| /api/posts | GET | articles | | "-created_at" | 20 |
-| /api/publish | POST | articles | | | 10 |
-
-
-
-**pg = > web.page title="mw"**
-**app = > web.app page=`pg`**
-**app = > `app`.configure cors=`cors` security=`sec` compress=True body_limit=1048576 json=`api`**
-
-**mw = [middleware](app)**
-
-
-
-**cobj = [cors](mw)**
-**origins = [allow_origins](cobj)**
-**o0 = [1](origins)**
-1. `o0` == "https://a.example"
- > print text=cors-origin-ok
-2. *
- > print text=cors-origin-fail
-
-**methods = [methods](cobj)**
-**m1 = [2](methods)**
-1. `m1` == "POST"
- > print text=cors-method-ok
-2. *
- > print text=cors-method-fail
-
-**expose = [expose_headers](cobj)**
-**e0 = [1](expose)**
-1. `e0` == "X-Total"
- > print text=cors-expose-ok
-2. *
- > print text=cors-expose-fail
-
-**cred = [credentials](cobj)**
-1. `cred`
- > print text=cors-cred-ok
-2. *
- > print text=cors-cred-fail
-
-
-
-**secmap = [security](mw)**
-**frame = [X-Frame-Options](secmap)**
-1. `frame` == "DENY"
- > print text=security-frame-ok
-2. *
- > print text=security-frame-fail
-
-**csp = [Content-Security-Policy](secmap)**
-1. `csp` == "default-src 'self'"
- > print text=security-csp-ok
-2. *
- > print text=security-csp-fail
-
-
-
-**comp = [compress](mw)**
-1. `comp`
- > print text=compress-ok
-2. *
- > print text=compress-fail
-
-**bl = [body_limit](mw)**
-1. `bl` == 1048576
- > print text=body-limit-ok
-2. *
- > print text=body-limit-fail
-
-
-
-**jmap = [json_routes](mw)**
-**posts = [api/posts](jmap)**
-**pok = [method](posts)**
-1. `pok` == "GET"
- > print text=json-get-ok
-2. *
- > print text=json-get-fail
-
-**ptable = [table](posts)**
-1. `ptable` == "articles"
- > print text=json-table-ok
-2. *
- > print text=json-table-fail
-
-**porder = [order](posts)**
-1. `porder` == "-created_at"
- > print text=json-order-ok
-2. *
- > print text=json-order-fail
-
-**plimit = [limit](posts)**
-1. `plimit` == 20
- > print text=json-limit-ok
-2. *
- > print text=json-limit-fail
-
-**pub = [api/publish](jmap)**
-**pmethod = [method](pub)**
-1. `pmethod` == "POST"
- > print text=json-post-ok
-2. *
- > print text=json-post-fail
diff --git a/tests/ext/web-net-smoke.mq.md b/tests/ext/web-net-smoke.mq.md
deleted file mode 100644
index 44b4eff..0000000
--- a/tests/ext/web-net-smoke.mq.md
+++ /dev/null
@@ -1,148 +0,0 @@
----
-title: web network-extension smoke
-description: Session/auth/ws ABI primitives (offline).
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-
-
-`users` =
-
-| 行 | 用户 | 密码 |
-|----|------|------|
-| 1 | admin | secret |
-| 2 | 站长 | pw123 |
-
-
-
-**sess = > web_session_new ttl_sec=120**
-**sid = [id](sess)**
-1. `sid` != ""
- > print text=session-new-ok
-2. *
- > print text=session-new-fail
-
-**set1 = > web_session_set id=`sid` key="theme" value="dark"**
-**ok1 = [ok](set1)**
-1. `ok1`
- > print text=session-set-ok
-2. *
- > print text=session-set-fail
-
-**get1 = > web_session_get id=`sid` key="theme"**
-**v1 = [value](get1)**
-1. `v1` == "dark"
- > print text=session-get-ok
-2. *
- > print text=session-get-fail
-
-**del1 = > web_session_del id=`sid` key="theme"**
-**ok2 = [ok](del1)**
-1. `ok2`
- > print text=session-del-ok
-2. *
- > print text=session-del-fail
-
-**get2 = > web_session_get id=`sid` key="theme"**
-**ok3 = [ok](get2)**
-1. `ok3`
- > print text=session-del-confirm-fail
-2. *
- > print text=session-del-confirm
-
-
-
-**login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120**
-**lok = [ok](login)**
-1. `lok`
- > print text=auth-login-ok
-2. *
- > print text=auth-login-fail
-
-**sid2 = [session_id](login)**
-**check = > web_auth_check session_id=`sid2`**
-**cok = [ok](check)**
-1. `cok`
- > print text=auth-check-ok
-2. *
- > print text=auth-check-fail
-
-**badlogin = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120**
-**bok = [ok](badlogin)**
-1. `bok`
- > print text=auth-bad-should-fail
-2. *
- > print text=auth-bad-ok
-
-**zhlogin = > web_auth_login username="站长" password="pw123" users=`users` session_ttl=120**
-**zhok = [ok](zhlogin)**
-1. `zhok`
- > print text=auth-zh-ok
-2. *
- > print text=auth-zh-fail
-
-**logout = > web_auth_logout session_id=`sid2`**
-**dok = [ok](logout)**
-1. `dok`
- > print text=auth-logout-ok
-2. *
- > print text=auth-logout-fail
-
-**check2 = > web_auth_check session_id=`sid2`**
-**cok2 = [ok](check2)**
-1. `cok2`
- > print text=auth-logout-confirm-fail
-2. *
- > print text=auth-logout-confirm
-
-
-
-**pg = > web.page title="ws-test"**
-**app = > web.app page=`pg` admin=True**
-**app = > `app`.route_ws path="/live" echo=True**
-**routes = [ws_routes](app)**
-**has_live = [/live](routes)**
-1. `has_live`
- > print text=ws-route-ok
-2. *
- > print text=ws-route-fail
-
-**app = > `app`.auth users=`users` session_ttl=120**
-**authobj = [auth](app)**
-**ausers = [users](authobj)**
-**au1 = [用户]([1](ausers))**
-**ou1 = [用户]([1](users))**
-1. `au1` == `ou1`
- > print text=app-auth-ok
-2. *
- > print text=app-auth-fail
-
-
-
-**authz = > web.auth users=`users` session_ttl=120**
-**login2 = > `authz`.login username="admin" password="secret"**
-**lok2 = [ok](login2)**
-1. `lok2`
- > print text=ext-auth-ok
-2. *
- > print text=ext-auth-fail
-
-**ws = > web.ws timeout_sec=1**
-**badurl = > `ws`.connect url="ws://127.0.0.1:1" message="hi"**
-**bwok = [ok](badurl)**
-1. `bwok`
- > print text=ws-connect-should-fail
-2. *
- > print text=ws-connect-error-ok
\ No newline at end of file
diff --git a/tests/ext/web-p3-live-server.mq.md b/tests/ext/web-p3-live-server.mq.md
deleted file mode 100644
index 7868816..0000000
--- a/tests/ext/web-p3-live-server.mq.md
+++ /dev/null
@@ -1,23 +0,0 @@
----
-title: web P3 live — gallery HTML + download ETag
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-**blob = > web.storage url="file:web-fixtures/data/p3-live-blobs"**
-> `blob`.put key="uploads/hello.txt" body="etag-body" content_type="text/plain"
-
-**pg = > web.page title="p3-live"**
-**app = > web.app page=`pg` port=18131**
-**app = > `app`.download path="/_media/{*key}" storage=`blob` disposition="inline"**
-**app = > `app`.gallery path="/gallery" storage=`blob` prefix="uploads/" title="P3 Gallery" download_base="/_media"**
-> `app`.listen
diff --git a/tests/ext/web-p3-smoke.mq.md b/tests/ext/web-p3-smoke.mq.md
deleted file mode 100644
index ad071c5..0000000
--- a/tests/ext/web-p3-smoke.mq.md
+++ /dev/null
@@ -1,107 +0,0 @@
----
-title: web P3 smoke — audit timestamps, FK, RBAC, gallery (offline)
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-**store = > web.db url="sqlite:web-fixtures/data/p3-smoke.db"**
-> `store`.exec sql="DROP TABLE IF EXISTS comments"
-> `store`.exec sql="DROP TABLE IF EXISTS posts"
-
-`post_fields` =
-
-| 字段 | 类型 | 可空 |
-|------|------|------|
-| id | int | 否 |
-| title | text | 否 |
-| created_at | timestamp | 是 |
-| updated_at | timestamp | 是 |
-
-> `store`.init name="posts" fields=`post_fields`
-
-`comment_fields` =
-
-| 字段 | 类型 | 可空 | 外键 |
-|------|------|------|------|
-| id | int | 否 | |
-| post_id | int | 否 | posts |
-| body | text | 否 | |
-
-> `store`.init name="comments" fields=`comment_fields`
-
-`rows` =
-
-| @ | title |
-|---|-------|
-| 1 | Hello P3 |
-
-> `store`.insert table="posts" rows=`rows`
-
-**got = > `store`.get table="posts" id=1**
-**ca = [created_at](got)**
-1. `ca`
- > print text=audit-insert-ok
-2. *
- > print text=audit-insert-fail
-
-**upd = > json.parse text={"title":"Hello P3b"}**
-> `store`.update table="posts" id=1 row=`upd`
-**got2 = > `store`.get table="posts" id=1**
-**ua2 = [updated_at](got2)**
-1. `ua2`
- > print text=audit-update-ok
-2. *
- > print text=audit-update-fail
-
-**fk = > `store`.query sql="SELECT sql FROM sqlite_master WHERE type='table' AND name='comments'"**
-**fkddl = [sql]([1]([rows](fk)))**
-1. `fkddl`
- > print text=fk-ok
-2. *
- > print text=fk-fail
-
-`users` =
-
-| username | password | role |
-|----------|----------|------|
-| admin | secret | admin |
-| alice | secret | author |
-
-**login = > web_auth_login username="alice" password="secret" users=`users` session_ttl=120**
-**role = [role](login)**
-1. `role` == "author"
- > print text=rbac-login-ok
-2. *
- > print text=rbac-login-fail
-
-**pg = > web.page title="p3"**
-**app = > web.app page=`pg` port=18130**
-**app = > `app`.auth users=`users`**
-**app = > `app`.gate path="/write*" roles="admin,author"**
-**gates = [gates](app)**
-**ng = > len value=`gates`**
-**gpath = [path]([1](gates))**
-1. `ng` == 1 and `gpath` == "/write*"
- > print text=rbac-gate-ok
-2. *
- > print text=rbac-gate-fail
-
-**blob = > web.storage url="file:web-fixtures/data/p3-gallery"**
-> `blob`.put key="uploads/a.txt" body="hi" content_type="text/plain"
-**app = > `app`.gallery path="/gallery" storage=`blob` prefix="uploads/" title="Media" download_base="/_media"**
-**gal = [gallery_routes](app)**
-**g = [/gallery](gal)**
-1. `g`
- > print text=gallery-ok
-2. *
- > print text=gallery-fail
diff --git a/tests/ext/web-part-smoke.mq.md b/tests/ext/web-part-smoke.mq.md
deleted file mode 100644
index c4d6370..0000000
--- a/tests/ext/web-part-smoke.mq.md
+++ /dev/null
@@ -1,52 +0,0 @@
----
-title: web part smoke
-description: Routed pages stamp _route and emit {path}/_part/{id} slot sources.
-import web:ext/web/web.mq.md
-import nav:web-fixtures/components/nav.mq.md
-import side:web-fixtures/components/side.mq.md
-import foot:web-fixtures/components/foot.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-`layout` =
-
-| 组件 | 样式 |
-|------|------|
-| nav.`nav` | |
-| side.`side` | |
-| foot.`foot` | |
-
-**home = > web.page title="Home" intro="
Home
"**
-**home = > `home`.compose_components components=`layout`**
-
-**about = > web.page title="About" intro="
About
"**
-**about = > `about`.compose_components components=`layout`**
-
-**app = > web.app page=`home` host=127.0.0.1 port=18081**
-**app = > `app`.route path="/about" page=`about`**
-
-**routes = > json.get value=`app` key="routes"**
-**routed = > json.get value=`routes` key="/about"**
-**route = > json.get value=`routed` key="_route"**
-1. `route` == "/about"
- > print text=route-stamp-ok
-2. *
- > print text=route-stamp-fail
-
-**home_html = > `home`.render**
-**home_chunks = > split value=`home_html` sep="/_part/"**
-**hn = > len value=`home_chunks`**
-1. `hn` >= 2
- > print text=home-part-ok
-2. *
- > print text=home-part-fail
-
-**about_html = > `routed`.render**
-**about_chunks = > split value=`about_html` sep="/about/_part/"**
-**an = > len value=`about_chunks`**
-1. `an` >= 2
- > print text=route-part-ok
-2. *
- > print text=route-part-fail
diff --git a/tests/ext/web-proxy-invoke-smoke.mq.md b/tests/ext/web-proxy-invoke-smoke.mq.md
deleted file mode 100644
index 5e3c019..0000000
--- a/tests/ext/web-proxy-invoke-smoke.mq.md
+++ /dev/null
@@ -1,75 +0,0 @@
----
-title: web proxy/invoke smoke
-description: Offline assemble of app.proxy and app.invoke routes (no listen).
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-`proxy_tbl` =
-
-| path | upstream | stream | strip_prefix | methods | headers_from_env | timeout_ms |
-|------|----------|--------|--------------|---------|------------------|------------|
-| /proxy/chat | $OPENAI_BASE_URL | True | /proxy | POST | OPENAI_API_KEY=Authorization | 60000 |
-
-`invoke_tbl` =
-
-| path | method | fn | body | return |
-|------|--------|-----|------|--------|
-| /api/echo | POST | demo.echo | json | json |
-
-**pg = > web.page title="proxy-invoke"**
-**app = > web.app page=`pg`**
-**app = > `app`.configure proxy=`proxy_tbl` invoke=`invoke_tbl`**
-**app = > `app`.proxy path="/v1/stream" upstream="https://example.com/v1/chat" stream=True headers_from_env="TOKEN=X-Token"**
-**app = > `app`.invoke path="/api/ping" fn="demo.ping" method="GET" body="query"**
-
-**proutes = [proxy_routes](app)**
-**chat = [proxy/chat](proutes)**
-**up = [upstream](chat)**
-1. `up` == "$OPENAI_BASE_URL"
- > print text=proxy-table-ok
-2. *
- > print text=proxy-table-fail
-
-**stream = [stream](chat)**
-1. `stream`
- > print text=proxy-stream-ok
-2. *
- > print text=proxy-stream-fail
-
-**hdr = [headers_from_env](chat)**
-1. `hdr` == "OPENAI_API_KEY=Authorization"
- > print text=proxy-env-ok
-2. *
- > print text=proxy-env-fail
-
-**v1 = [v1/stream](proutes)**
-**v1u = [upstream](v1)**
-1. `v1u` == "https://example.com/v1/chat"
- > print text=proxy-method-ok
-2. *
- > print text=proxy-method-fail
-
-**iroutes = [invoke_routes](app)**
-**echo = [api/echo](iroutes)**
-**efn = [fn](echo)**
-1. `efn` == "demo.echo"
- > print text=invoke-table-ok
-2. *
- > print text=invoke-table-fail
-
-**ping = [api/ping](iroutes)**
-**pm = [method](ping)**
-1. `pm` == "GET"
- > print text=invoke-method-ok
-2. *
- > print text=invoke-method-fail
diff --git a/tests/ext/web-rbac-artifact-smoke.mq.md b/tests/ext/web-rbac-artifact-smoke.mq.md
new file mode 100644
index 0000000..0328e59
--- /dev/null
+++ b/tests/ext/web-rbac-artifact-smoke.mq.md
@@ -0,0 +1,18 @@
+---
+title: ext/security rbac smoke
+import rbac:ext/security/rbac.mq.md
+---
+
+# main
+
+**gate = > rbac.rbac**
+**r = > `gate`.can permissions="desk:access,posts:read" needed="desk:access"**
+**ok = [ok](r)**
+**allowed = [allowed](r)**
+1. `ok`
+ 1. `allowed`
+ > print text=rbac-ok
+ 2. *
+ > print text=rbac-fail
+2. *
+ > print text=rbac-fail
diff --git a/tests/ext/web-rbac-can-smoke.mq.md b/tests/ext/web-rbac-can-smoke.mq.md
deleted file mode 100644
index 6861f7b..0000000
--- a/tests/ext/web-rbac-can-smoke.mq.md
+++ /dev/null
@@ -1,56 +0,0 @@
----
-title: web RBAC smoke
-description: app.rbac flag + gate permissions CSV stored on app bag
-import web:ext/web/web.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-> print text=rbac-smoke-start
-
-**首页 = > web.page title="home"**
-`用户表` =
-| 用户名 | 密码 | 角色 |
-|--------|------|------|
-| admin | secret | admin |
-
-**应用 = > web.app page=`首页` admin=False**
-**应用 = > `应用`.enable_rbac**
-**authbag = > json.get value=`应用` key="auth"**
-**rbac_on = > json.get value=`authbag` key="rbac"**
-1. `rbac_on` == True
- > print text=rbac-flag-ok
-2. *
- > print text=rbac-flag-fail
-
-**应用 = > `应用`.auth users=`用户表` login_path="/login"**
-**authbag2 = > json.get value=`应用` key="auth"**
-**rbac_kept = > json.get value=`authbag2` key="rbac"**
-1. `rbac_kept` == True
- > print text=rbac-survives-auth-ok
-2. *
- > print text=rbac-survives-auth-fail
-
-**应用 = > `应用`.gate path="/desk" permissions="desk:access" match="prefix" on_deny="redirect" exclude="/login"**
-**gates = > json.get value=`应用` key="gates"**
-**g1 = > at value=`gates` index=1**
-**perms = > json.get value=`g1` key="permissions"**
-**p0 = > at value=`perms` index=0**
-1. `p0` == "desk:access"
- > print text=gate-perm-ok
-2. *
- > print text=gate-perm-fail
-
-**应用2 = > web.app page=`首页` admin=False**
-**应用2 = > `应用2`.gate path="/desk/roles" permissions="roles:manage" roles="editor" match="exact"**
-**gates2 = > json.get value=`应用2` key="gates"**
-**g0 = > at value=`gates2` index=0**
-**perms2 = > json.get value=`g0` key="permissions"**
-**p1 = > at value=`perms2` index=0**
-1. `p1` == "roles:manage"
- > print text=gate-roles-manage-ok
-2. *
- > print text=gate-roles-manage-fail
-
-> print text=rbac-smoke-done
diff --git a/tests/ext/web-rbac-db-smoke.mq.md b/tests/ext/web-rbac-db-smoke.mq.md
deleted file mode 100644
index f9a4f58..0000000
--- a/tests/ext/web-rbac-db-smoke.mq.md
+++ /dev/null
@@ -1,49 +0,0 @@
----
-title: web RBAC db register/assign smoke
-description: EnsureSchema path via create_role + assign + can
-import web:ext/web/web.mq.md
-import json:lib/json.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-> print text=rbac-db-start
-
-**db = > web.db url="sqlite::memory:"**
-**url = > json.get value=`db` key="url"**
-**rbac = > web.rbac**
-
-**seed = > `rbac`.create_role url=`db` name="reviewer"**
-**ok1 = > json.get value=`seed` key="ok"**
-1. `ok1` == True
- > print text=create-role-ok
-2. *
- > print text=create-role-fail
- > sys.exit code=1
-
-**setp = > `rbac`.set_role_permissions url=`db` role="reviewer" permissions="comments:create,desk:access"**
-**ok2 = > json.get value=`setp` key="ok"**
-1. `ok2` == True
- > print text=set-perms-ok
-2. *
- > print text=set-perms-fail
- > sys.exit code=1
-
-**can = > `rbac`.can permissions="comments:create,desk:access" needed="desk:access"**
-**allowed = > json.get value=`can` key="allowed"**
-1. `allowed` == True
- > print text=can-ok
-2. *
- > print text=can-fail
- > sys.exit code=1
-
-**deny = > `rbac`.can permissions="comments:create" needed="roles:manage"**
-**denied = > json.get value=`deny` key="allowed"**
-1. `denied` == False
- > print text=can-deny-ok
-2. *
- > print text=can-deny-fail
- > sys.exit code=1
-
-> print text=rbac-db-done
diff --git a/tests/ext/web-route-smoke.mq.md b/tests/ext/web-route-smoke.mq.md
deleted file mode 100644
index e0d7ade..0000000
--- a/tests/ext/web-route-smoke.mq.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-title: web route smoke
-description: Offline app.route registration (no listen).
-import web:ext/web/web.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-**home = > web.page title="Home" intro="
Home
"**
-**about = > web.page title="About" intro="
About
"**
-**app = > web.app page=`home` host=127.0.0.1 port=18081**
-**app = > `app`.route path="/about" page=`about`**
-**app = > `app`.route path="docs" page=`about`**
-
-**routes = > json.get value=`app` key="routes"**
-**about_page = > json.get value=`routes` key="/about"**
-**docs_page = > json.get value=`routes` key="/docs"**
-
-1. `about_page`
- > print text=about-ok
-2. *
- > print text=about-fail
-
-1. `docs_page`
- > print text=docs-ok
-2. *
- > print text=docs-fail
-
-**html = > `about`.render**
-1. `html`
- > print text=render-ok
-2. *
- > print text=render-fail
diff --git a/tests/ext/web-security-smoke.mq.md b/tests/ext/web-security-smoke.mq.md
deleted file mode 100644
index 19ce888..0000000
--- a/tests/ext/web-security-smoke.mq.md
+++ /dev/null
@@ -1,48 +0,0 @@
----
-title: web security smoke (W3)
-description: Password hash ABI + legacy plaintext login (offline).
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-
-
-**hash = > web_password_hash password="secret"**
-**h = [hash](hash)**
-1. `h` != ""
- > print text=hash-ok
-2. *
- > print text=hash-fail
-
-
-
-`users` =
-
-| 行 | 用户 | 密码 |
-|----|------|------|
-| 1 | admin | secret |
-
-**login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120**
-**lok = [ok](login)**
-1. `lok`
- > print text=auth-login-ok
-2. *
- > print text=auth-login-fail
-
-**bad = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120**
-**bok = [ok](bad)**
-1. `bok`
- > print text=auth-bad-should-fail
-2. *
- > print text=auth-bad-reject-ok
diff --git a/tests/ext/web-select-smoke.mq.md b/tests/ext/web-select-smoke.mq.md
deleted file mode 100644
index 3e6ccd4..0000000
--- a/tests/ext/web-select-smoke.mq.md
+++ /dev/null
@@ -1,57 +0,0 @@
----
-title: web db.select where smoke
-description: Offline select with map and filter-table where (no listen).
-import web:ext/web/web.mq.md
-import articles:web-fixtures/db/articles.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-**store = > web.db url="sqlite:web-fixtures/data/select-smoke.db"**
-**schema = > articles.schema**
-> `store`.init name=articles fields=`schema`
-> `store`.exec sql="DELETE FROM articles"
-
-`rows` =
-
-| title | body |
-|-------|------|
-| Alpha | first |
-| Beta | second |
-| Alpha again | third |
-
-> `store`.insert table=articles rows=`rows`
-
-`eq` =
-
-| title | body |
-|-------|------|
-| Alpha | first |
-
-**hit = > `store`.select table="articles" where=`eq` limit=50**
-**n = > len value=`hit`**
-1. `n` == 1
- > print text=map-where-ok
-2. *
- > print text=map-where-fail
-
-`filt` =
-
-| 字段 | 操作 | 值 |
-|------|------|-----|
-| title | like | %Alpha% |
-
-**like_rows = > `store`.select table="articles" where=`filt` limit=50**
-**ln = > len value=`like_rows`**
-1. `ln` == 2
- > print text=like-ok
-2. *
- > print text=like-fail
-
-**all = > `store`.select table="articles" limit=50**
-**an = > len value=`all`**
-1. `an` == 3
- > print text=all-ok
-2. *
- > print text=all-fail
diff --git a/tests/ext/web-smoke.mq.md b/tests/ext/web-smoke.mq.md
deleted file mode 100644
index ccd7d6c..0000000
--- a/tests/ext/web-smoke.mq.md
+++ /dev/null
@@ -1,81 +0,0 @@
----
-title: web assemble smoke
-description: Offline assemble + render markers (no listen).
-import web:ext/web/web.mq.md
-import shell:web-fixtures/styles/shell.mq.md
-import nav:web-fixtures/components/nav.mq.md
-import side:web-fixtures/components/side.mq.md
-import foot:web-fixtures/components/foot.mq.md
-import articles:web-fixtures/db/articles.mq.md
-import fs:lib/fs.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-**store = > web.db url="sqlite:web-fixtures/data/smoke.db"**
-**fields = > articles.schema**
-> `store`.init name=articles fields=`fields`
-**rows = > `store`.select table="articles" limit=1**
-1. `rows`
- **_ = 1**
-2. *
- **seed = > articles.seed**
- > `store`.insert table=articles rows=`seed`
-
-`home` =
-
-| 组件 | 样式 |
-|------|------|
-| nav.`nav` | shell.`topnav` |
-| side.`side` | shell.`side_panel` |
-| foot.`foot` | |
-
-`index` =
-
-| 属性 | 值 | 样式 |
-|------|-----|------|
-| title | articles.`articles`.title | shell.`card_title` |
-| body | articles.`articles`.body | shell.`card_body` |
-
-**page = > web.page title="smoke" intro="
smoke
"**
-**page = > `page`.compose_components components=`home`**
-**page = > `page`.compose_main main=`index`**
-**html = > `page`.render db=`store`**
-
-1. `html`
- > print text=render-ok
-2. *
- > print text=render-fail
-
-**nav = > json.get value=`page` key="nav"**
-1. `nav`
- > print text=compose-nav-ok
-2. *
- > print text=compose-nav-fail
-
-**side = > json.get value=`page` key="sidebar"**
-1. `side`
- > print text=compose-side-ok
-2. *
- > print text=compose-side-fail
-
-**css = > json.get value=`page` key="styles_css"**
-1. `css`
- > print text=styles-ok
-2. *
- > print text=styles-fail
-
-**parts = > json.get value=`page` key="parts"**
-**index_part = > json.get value=`parts` key="index"**
-1. `index_part`
- > print text=compose-ok
-2. *
- > print text=compose-fail
-
-**got = > `store`.get table="articles" id=1**
-**title = > json.get value=`got` key="title"**
-1. `title` == "Hello Marqdo"
- > print text=db-ok
-2. *
- > print text=db-fail
diff --git a/tests/ext/web-spa-helpers-smoke.mq.md b/tests/ext/web-spa-helpers-smoke.mq.md
deleted file mode 100644
index ce2ec0c..0000000
--- a/tests/ext/web-spa-helpers-smoke.mq.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-title: browser spa helpers smoke
-description: store_set / spa_goto effect bags
-import browser:lib/browser.mq.md
-import json:lib/json.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**set = > browser.store_set key="k" value="v" scope="memory"**
-**op = > json.get value=`set` key="storage"**
-**op_name = > json.get value=`op` key="op"**
-**scope = > json.get value=`op` key="scope"**
-1. `op_name` == "set"
- 1. `scope` == "memory"
- > print text=store-set-ok
- 2. *
- > print text=scope-fail
- > sys.exit code=1
-2. *
- > print text=op-fail
- > sys.exit code=1
-
-**nav = > browser.spa_goto url="/item" replace=False**
-**n = > json.get value=`nav` key="navigate"**
-**url = > json.get value=`n` key="url"**
-1. `url` == "/item"
- > print text=spa-goto-ok
-2. *
- > print text=spa-goto-fail
- > sys.exit code=1
-
-> print text=spa-helpers-ok
diff --git a/tests/ext/web-static-artifact-smoke.mq.md b/tests/ext/web-static-artifact-smoke.mq.md
new file mode 100644
index 0000000..36e70bf
--- /dev/null
+++ b/tests/ext/web-static-artifact-smoke.mq.md
@@ -0,0 +1,20 @@
+---
+title: web static artifact smoke
+import web:ext/web/web.mq.md
+---
+
+# main
+
+**pg = > web.page title="static"**
+**app = > web.app page=`pg`**
+**app = > `app`.static dir="web-fixtures/public" mount="/static"**
+**d = [static_dir](app)**
+**m = [static_mount](app)**
+1. `d`
+ > print text=dir-ok
+2. *
+ > print text=dir-fail
+1. `m` == "/static"
+ > print text=mount-ok
+2. *
+ > print text=mount-fail
diff --git a/tests/ext/web-static-smoke.mq.md b/tests/ext/web-static-smoke.mq.md
deleted file mode 100644
index 6ed6f48..0000000
--- a/tests/ext/web-static-smoke.mq.md
+++ /dev/null
@@ -1,31 +0,0 @@
----
-title: web static smoke
-description: Offline app.static registration (no listen).
-import web:ext/web/web.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-**home = > web.page title="Home"**
-**app = > web.app page=`home` host=127.0.0.1 port=18081**
-**app = > `app`.static dir="web-fixtures/public" mount="/static"**
-
-**dir = > json.get value=`app` key="static_dir"**
-1. `dir` == "web-fixtures/public"
- > print text=dir-ok
-2. *
- > print text=dir-fail
-
-**mount = > json.get value=`app` key="static_mount"**
-1. `mount` == "/static"
- > print text=mount-ok
-2. *
- > print text=mount-fail
-
-**app2 = > `app`.static dir="assets" mount="/assets"**
-**m2 = > json.get value=`app2` key="static_mount"**
-1. `m2` == "/assets"
- > print text=custom-ok
-2. *
- > print text=custom-fail
diff --git a/tests/ext/web-tenant-bag-smoke.mq.md b/tests/ext/web-tenant-bag-smoke.mq.md
deleted file mode 100644
index 6ccd224..0000000
--- a/tests/ext/web-tenant-bag-smoke.mq.md
+++ /dev/null
@@ -1,30 +0,0 @@
----
-title: web tenant bag smoke
-description: app.tenant mode=path stores config
-import web:ext/web/web.mq.md
-import json:lib/json.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**首页 = > web.page title="t"**
-**应用 = > web.app page=`首页` admin=False**
-**应用 = > `应用`.tenant mode="path" param="t" column="tenant_id" default_scope=True**
-**bag = > json.get value=`应用` key="tenant"**
-**mode = > json.get value=`bag` key="mode"**
-**param = > json.get value=`bag` key="param"**
-**scope = > json.get value=`bag` key="default_scope"**
-1. `mode` == "path"
- 1. `param` == "t"
- 1. `scope` == True
- > print text=tenant-bag-ok
- 2. *
- > print text=scope-fail
- > sys.exit code=1
- 2. *
- > print text=param-fail
- > sys.exit code=1
-2. *
- > print text=mode-fail
- > sys.exit code=1
diff --git a/tests/ext/web-upload-live-server.mq.md b/tests/ext/web-upload-live-server.mq.md
deleted file mode 100644
index f38a343..0000000
--- a/tests/ext/web-upload-live-server.mq.md
+++ /dev/null
@@ -1,31 +0,0 @@
----
-title: web upload live server (W5)
-description: Listen with upload + download routes for curl gold.
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-**blob = > web.storage url="file:tests/ext/web-fixtures/data/upload-live-blobs"**
-
-`types` =
-
-| 类型 | 扩展名 |
-|------|--------|
-| text/plain | txt |
-| image/png | png |
-
-**pg = > web.page title="upload-live"**
-**app = > web.app page=`pg` port=18101**
-**app = > `app`.configure body_limit=1048576**
-**app = > `app`.upload path="/_upload" field="file" storage=`blob` prefix="live/" max_bytes=1024 types=`types`**
-**app = > `app`.download path="/_media/{*key}" storage=`blob` disposition="attachment"**
-> `app`.listen
diff --git a/tests/ext/web-upload-smoke.mq.md b/tests/ext/web-upload-smoke.mq.md
deleted file mode 100644
index 7cbc689..0000000
--- a/tests/ext/web-upload-smoke.mq.md
+++ /dev/null
@@ -1,77 +0,0 @@
----
-title: web upload smoke (W5)
-description: Offline validate + save into file: storage.
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-`types` =
-
-| 类型 | 扩展名 |
-|------|--------|
-| image/png | png |
-| text/plain | txt |
-
-**m = > web.media**
-**ok = > `m`.validate filename="a.png" content_type="image/png" size=100 max_bytes=1000 types=`types`**
-**ook = [ok](ok)**
-1. `ook`
- > print text=validate-ok
-2. *
- > print text=validate-fail
-
-**bad = > `m`.validate filename="a.exe" content_type="application/octet-stream" size=100 max_bytes=1000 types=`types`**
-**bok = [ok](bad)**
-1. `bok`
- > print text=reject-type-fail
-2. *
- > print text=reject-type-ok
-
-**big = > `m`.validate filename="a.png" content_type="image/png" size=9000 max_bytes=1000 types=`types`**
-**gok = [ok](big)**
-1. `gok`
- > print text=reject-size-fail
-2. *
- > print text=reject-size-ok
-
-**blob = > web.storage url="file:tests/ext/web-fixtures/data/upload-blobs"**
-**m = > web.media storage=`blob`**
-**saved = > `m`.save path="tests/ext/web-fixtures/upload/sample.txt" content_type="text/plain" prefix="smoke/"**
-**sok = [ok](saved)**
-**skey = [key](saved)**
-1. `sok`
- > print text=save-ok
-2. *
- > print text=save-fail
-
-**got = > `blob`.get key=`skey`**
-**body = [body](got)**
-1. `body` == "hello-upload"
- > print text=save-roundtrip-ok
-2. *
- > print text=save-roundtrip-fail
-
-
-
-`fields` =
-
-| name | label | type |
-|------|-------|------|
-| title | Title | text |
-| file | File | file |
-
-**frm = > web.form table="x" fields=`fields`**
-**html = > `frm`.render id="up"**
-1. `html`
- > print text=form-file-ok
-2. *
- > print text=form-file-fail
diff --git a/tests/ext/web-use-smoke.mq.md b/tests/ext/web-use-smoke.mq.md
new file mode 100644
index 0000000..d012850
--- /dev/null
+++ b/tests/ext/web-use-smoke.mq.md
@@ -0,0 +1,24 @@
+---
+title: web.use middleware smoke
+description: First-class middleware via web.use (replaces configure junk drawer).
+import web:ext/web/web.mq.md
+---
+
+# main
+
+`headers` =
+
+| header | value |
+|--------|-------|
+| X-Content-Type-Options | nosniff |
+| X-Frame-Options | DENY |
+
+**pg = > web.page title="use-smoke"**
+**app = > web.app page=`pg`**
+**app = > web.use app=`app` middleware=`headers`**
+**mw = [middleware](app)**
+**sec = [security](mw)**
+1. `sec`
+ > print text=use-ok
+2. *
+ > print text=use-fail
diff --git a/tests/ext/web-w7-finish-smoke.mq.md b/tests/ext/web-w7-finish-smoke.mq.md
deleted file mode 100644
index 6701dd4..0000000
--- a/tests/ext/web-w7-finish-smoke.mq.md
+++ /dev/null
@@ -1,82 +0,0 @@
----
-title: web W7 finish smoke — unique index, sitemap, cache-control (offline)
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-**store = > web.db url="sqlite:web-fixtures/data/w7-smoke.db"**
-> `store`.exec sql="DROP TABLE IF EXISTS posts"
-
-`fields` =
-
-| 字段 | 类型 | 可空 | 唯一 | 索引 |
-|------|------|------|------|------|
-| id | int | 否 | | |
-| slug | text | 否 | 是 | 是 |
-| title | text | 否 | | |
-
-> `store`.init name=posts fields=`fields`
-
-**idx = > `store`.query sql="SELECT name FROM sqlite_master WHERE type='index' AND tbl_name='posts'"**
-**nidx = > len value=[rows](idx)**
-1. `nidx` >= 1
- > print text=unique-ok
-2. *
- > print text=unique-fail
-
-`items` =
-
-| loc | 更新 |
-|-----|------|
-| / | 2026-08-28 |
-| /about | 2026-08-28 |
-
-**sm = > web_sitemap_build base="https://example.com" items=`items`**
-**xml = [xml](sm)**
-1. `xml`
- > print text=sitemap-ok
-2. *
- > print text=sitemap-fail
-
-**pg = > web.page title="w7"**
-**notfound = > web.page title="Missing"**
-**app = > web.app page=`pg` port=18120**
-**app = > `app`.configure cache_control="public, max-age=60" access_log=False**
-**app = > `app`.redirect from="/old" to="/new" permanent=True**
-**app = > `app`.error_page status=404 page=`notfound`**
-**app = > `app`.sitemap path="/sitemap.xml" base="https://example.com" items=`items`**
-**app = > `app`.robots sitemap="https://example.com/sitemap.xml"**
-**rd = [redirects](app)**
-**has = [/old](rd)**
-1. `has`
- > print text=redirect-ok
-2. *
- > print text=redirect-fail
-
-**rb = [robots_body](app)**
-1. `rb`
- > print text=robots-ok
-2. *
- > print text=robots-fail
-
-**mw = [middleware](app)**
-**cc = [cache_control](mw)**
-1. `cc` == "public, max-age=60"
- > print text=cache-control-ok
-2. *
- > print text=cache-control-fail
-
-**p404 = [page_404](app)**
-1. `p404`
- > print text=error-page-ok
-2. *
- > print text=error-page-fail
diff --git a/tests/ext/web-w7-live-server.mq.md b/tests/ext/web-w7-live-server.mq.md
deleted file mode 100644
index 0198a99..0000000
--- a/tests/ext/web-w7-live-server.mq.md
+++ /dev/null
@@ -1,31 +0,0 @@
----
-title: web W7 live server — 404, redirect, sitemap, robots, cache-control
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-`items` =
-
-| loc | note |
-|-----|------|
-| / | home |
-| /about | about |
-
-**pg = > web.page title="w7-live"**
-**nf = > web.page title="Not Found Page"**
-**app = > web.app page=`pg` port=18121**
-**app = > `app`.configure cache_control="public, max-age=120"**
-**app = > `app`.redirect from="/legacy" to="/" permanent=True**
-**app = > `app`.error_page status=404 page=`nf`**
-**app = > `app`.sitemap path="/sitemap.xml" base="http://127.0.0.1:18121" items=`items`**
-**app = > `app`.robots sitemap="http://127.0.0.1:18121/sitemap.xml"**
-> `app`.listen
diff --git a/tests/ext/web-ws-broadcast-live-server.mq.md b/tests/ext/web-ws-broadcast-live-server.mq.md
deleted file mode 100644
index 8dddc29..0000000
--- a/tests/ext/web-ws-broadcast-live-server.mq.md
+++ /dev/null
@@ -1,20 +0,0 @@
----
-title: web ws broadcast live server
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-**pg = > web.page title="ws-live"**
-**app = > web.app page=`pg` port=18112**
-**app = > `app`.configure access_log=True**
-**app = > `app`.route_ws path="/room" mode="broadcast" require_auth=False**
-> `app`.listen
diff --git a/tests/ext/web-ws-broadcast-smoke.mq.md b/tests/ext/web-ws-broadcast-smoke.mq.md
deleted file mode 100644
index 5e5b1af..0000000
--- a/tests/ext/web-ws-broadcast-smoke.mq.md
+++ /dev/null
@@ -1,33 +0,0 @@
----
-title: web ws broadcast + access_log smoke (offline)
-import web:ext/web/web.mq.md
-import plugin:lib/plugin.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**p = > plugin.native_path name="web"**
-1. `p`
- > plugin.load path=`p`
-2. *
- > sys.exit code=1
-
-**pg = > web.page title="w6b"**
-**app = > web.app page=`pg` port=18111**
-**app = > `app`.route_ws path="/room" mode="broadcast"**
-**routes = [ws_routes](app)**
-**room = [/room](routes)**
-**mode = [mode](room)**
-1. `mode` == "broadcast"
- > print text=ws-broadcast-route-ok
-2. *
- > print text=ws-broadcast-route-fail
-
-**app = > `app`.configure access_log=True compress=False**
-**mw = [middleware](app)**
-**al = [access_log](mw)**
-1. `al`
- > print text=access-log-ok
-2. *
- > print text=access-log-fail
diff --git a/tests/ext/web-ws-room-bag-smoke.mq.md b/tests/ext/web-ws-room-bag-smoke.mq.md
deleted file mode 100644
index a669ae0..0000000
--- a/tests/ext/web-ws-room-bag-smoke.mq.md
+++ /dev/null
@@ -1,36 +0,0 @@
----
-title: web WS room + on_message bag smoke
-description: route_ws mode=room stores room_key, on_message, presence
-import web:ext/web/web.mq.md
-import json:lib/json.mq.md
-import sys:lib/sys.mq.md
----
-
-# main
-
-**首页 = > web.page title="ws"**
-**应用 = > web.app page=`首页` admin=False**
-**应用 = > `应用`.route_ws path="/chat/{id}" mode="room" room_key="chat.room.{id}" on_message="chat.persist" presence=True**
-**routes = > json.get value=`应用` key="ws_routes"**
-**spec = > json.get value=`routes` key="/chat/{id}"**
-**mode = > json.get value=`spec` key="mode"**
-**rk = > json.get value=`spec` key="room_key"**
-**om = > json.get value=`spec` key="on_message"**
-**pr = > json.get value=`spec` key="presence"**
-1. `mode` == "room"
- 1. `rk` == "chat.room.{id}"
- 1. `om` == "chat.persist"
- 1. `pr` == True
- > print text=ws-room-bag-ok
- 2. *
- > print text=presence-fail
- > sys.exit code=1
- 2. *
- > print text=on-message-fail
- > sys.exit code=1
- 2. *
- > print text=room-key-fail
- > sys.exit code=1
-2. *
- > print text=mode-fail
- > sys.exit code=1
diff --git a/tests/ext/web-zh-smoke.mq.md b/tests/ext/web-zh-smoke.mq.md
deleted file mode 100644
index 08ffb63..0000000
--- a/tests/ext/web-zh-smoke.mq.md
+++ /dev/null
@@ -1,82 +0,0 @@
----
-title: web zh API smoke
-description: Offline Chinese 网页.mq.md assemble (no listen).
-导入 网页:ext/web/网页.mq.md
-import nav:web-fixtures/components/nav.mq.md
-import side:web-fixtures/components/side.mq.md
-import foot:web-fixtures/components/foot.mq.md
-import articles:web-fixtures/db/articles.mq.md
-import json:lib/json.mq.md
----
-
-# main
-
-**store = > 网页.数据库 地址="sqlite:web-fixtures/data/zh-smoke.db"**
-**schema = > articles.schema**
-> `store`.初始化 名=articles 字段=`schema`
-> `store`.执行 sql="DELETE FROM articles"
-> `store`.执行 sql="DELETE FROM sqlite_sequence WHERE name='articles'"
-
-`layout` =
-
-| 组件 | 样式 |
-|------|------|
-| nav.`nav` | |
-| side.`side` | |
-| foot.`foot` | |
-
-`index` =
-
-| 属性 | 值 | 样式 |
-|------|-----|------|
-| title | articles.`articles`.title | |
-| body | articles.`articles`.body | |
-
-`seed` =
-
-| title | body |
-|-------|------|
-| 中文种子 | 正文 |
-
-> `store`.插入 表=articles 行=`seed`
-
-**page = > 网页.页面 标题="中文烟测" 引言="
中文
"**
-**page = > `page`.组件装配 组件=`layout`**
-**page = > `page`.主体装配 主体=`index`**
-
-**html = > `page`.渲染 数据库=`store`**
-1. `html`
- > print text=render-ok
-2. *
- > print text=render-fail
-
-**nav = > json.get value=`page` key="nav"**
-1. `nav`
- > print text=compose-ok
-2. *
- > print text=compose-fail
-
-`fields` =
-
-| 字段 | 标签 | 类型 | 必填 | 默认 |
-|------|------|------|------|------|
-| title | 标题 | text | true | |
-
-**f = > 网页.表单 表="articles" 动作="插入"**
-**f = > `f`.字段 字段=`fields`**
-**page = > `page`.表单装配 id="article" 表单=`f`**
-**fid = > json.get value=`page` key="form_id"**
-1. `fid` == "article"
- > print text=form-ok
-2. *
- > print text=form-fail
-
-**app = > 网页.应用 页面=`page` 数据库=`store` 主机=127.0.0.1 端口=18082**
-**about = > 网页.页面 标题="关于" 引言="
关于
"**
-**app = > `app`.路由 路径="/about" 页面=`about`**
-**routes = > json.get value=`app` key="routes"**
-**routed = > json.get value=`routes` key="/about"**
-1. `routed`
- > print text=route-ok
-2. *
- > print text=route-fail
diff --git a/tests/gold.rs b/tests/gold.rs
index 1d914cf..c2f5d34 100644
--- a/tests/gold.rs
+++ b/tests/gold.rs
@@ -1829,732 +1829,94 @@ fn ext_web_data_db_smoke() {
}
#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_smoke() {
+fn ext_web_use_smoke() {
+ ensure_web_plugin_built();
+ assert_out("tests/ext/web-use-smoke.mq.md", "use-ok");
+}
+
+#[test]
+fn ext_web_static_artifact_smoke() {
ensure_web_plugin_built();
assert_out(
- "tests/ext/web-smoke.mq.md",
- "render-ok
-compose-nav-ok
-compose-side-ok
-styles-ok
-compose-ok
-db-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_entrydir_smoke() {
- // Relative db paths must resolve against the *entry script* directory,
- // not the process cwd (host_query("entry_dir")). We run from the repo
- // root while the script lives in tests/ext, so the sqlite file must
- // land under tests/ext/entrydir-fixtures/data/ and NOT repo-root/.
- ensure_web_plugin_built();
-
- let script = "tests/ext/web-entrydir-smoke.mq.md";
- let fixture_data = std::path::Path::new("tests/ext/entrydir-fixtures/data");
- let db_path = fixture_data.join("entrydir.db");
- let _ = std::fs::remove_dir_all(fixture_data);
- let stale_root = std::path::Path::new("entrydir-fixtures");
- let _ = std::fs::remove_dir_all(stale_root);
-
- // cwd = repo root (CARGO_MANIFEST_DIR), script in tests/ext.
- let output = Command::new(env!("CARGO_BIN_EXE_marqdo"))
- .args(["run", script])
- .current_dir(env!("CARGO_MANIFEST_DIR"))
- .output()
- .expect("run web-entrydir-smoke");
- let code = output.status.code().unwrap_or(1);
- let stdout = String::from_utf8_lossy(&output.stdout);
- let stderr = String::from_utf8_lossy(&output.stderr);
- assert_eq!(code, 0, "{script} stderr={stderr}");
- assert!(
- stdout.contains("entrydir-db-ok"),
- "{script} stdout={stdout}"
- );
- assert!(
- db_path.is_file(),
- "expected db at {} (script dir), stdout={stdout} stderr={stderr}",
- db_path.display()
- );
- assert!(
- !stale_root.exists(),
- "db must not resolve against cwd (repo root): {} exists",
- stale_root.display()
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_form_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-form-smoke.mq.md",
- "validate-ok
-submit-ok
-db-ok
-render-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_admin_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-admin-smoke.mq.md",
- "schema-ok
-new-form-ok
-insert-ok
-get-ok
-update-ok
-edit-ok
-required-ok
-errors-echoed-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_net_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-net-smoke.mq.md",
- "session-new-ok
-session-set-ok
-session-get-ok
-session-del-ok
-session-del-confirm
-auth-login-ok
-auth-check-ok
-auth-bad-ok
-auth-zh-ok
-auth-logout-ok
-auth-logout-confirm
-ws-route-ok
-app-auth-ok
-ext-auth-ok
-ws-connect-error-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_route_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-route-smoke.mq.md",
- "about-ok
-docs-ok
-render-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_form_embed_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-form-embed-smoke.mq.md",
- "form-id-ok
-render-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_form_slot_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-form-slot-smoke.mq.md",
- "target-ok
-slot-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_form_source_live() {
- // Field sources: only body is client-editable; author/slug stamped from session/route.
- ensure_web_plugin_built();
-
- let script = "tests/ext/web-form-source-live-server.mq.md";
- let bin = env!("CARGO_BIN_EXE_marqdo");
- let mut child = Command::new(bin)
- .args(["run", script])
- .current_dir(env!("CARGO_MANIFEST_DIR"))
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .expect("spawn form-source live server");
-
- let base = "http://127.0.0.1:18117";
- let ready = std::time::Instant::now();
- loop {
- if ready.elapsed().as_secs() > 15 {
- let _ = child.kill();
- panic!("form-source live server did not start in time");
- }
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- &format!("{base}/post/hello"),
- ])
- .output()
- .expect("curl probe");
- if String::from_utf8_lossy(&out.stdout) == "200" {
- break;
- }
- std::thread::sleep(std::time::Duration::from_millis(300));
- }
-
- let page = Command::new("curl")
- .args(["-s", &format!("{base}/post/hello")])
- .output()
- .expect("curl post page");
- let html = String::from_utf8_lossy(&page.stdout);
- assert!(
- html.contains(r#"name="body""#),
- "body field missing: {html}"
- );
- assert!(
- !html.contains(r#"name="author""#),
- "author must not render (server-only): {html}"
- );
- assert!(
- !html.contains(r#"name="post_slug""#),
- "post_slug must not render (server-only): {html}"
- );
- assert!(
- html.contains("_mq_params") && html.contains("hello"),
- "expected _mq_params with slug: {html}"
- );
-
- let jar = std::env::temp_dir().join("marqdo-form-source-cookies.txt");
- let _ = std::fs::remove_file(&jar);
- let login = Command::new("curl")
- .args([
- "-s",
- "-c",
- jar.to_str().unwrap(),
- "-b",
- jar.to_str().unwrap(),
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- "-X",
- "POST",
- &format!("{base}/login"),
- "-d",
- "username=alice&password=secret",
- ])
- .output()
- .expect("curl login");
- let login_code = String::from_utf8_lossy(&login.stdout);
- assert!(
- login_code == "303" || login_code == "302" || login_code == "200",
- "login http_code={login_code}"
- );
-
- let post = Command::new("curl")
- .args([
- "-s",
- "-c",
- jar.to_str().unwrap(),
- "-b",
- jar.to_str().unwrap(),
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- "-X",
- "POST",
- &format!("{base}/_form/comment"),
- "--data-urlencode",
- "body=gold comment",
- "--data-urlencode",
- "author=forged-attacker",
- "--data-urlencode",
- "post_slug=evil-slug",
- "--data-urlencode",
- r#"_mq_params={"slug":"hello"}"#,
- "--data-urlencode",
- "_mq_return=/post/hello",
- ])
- .output()
- .expect("curl form post");
- let post_code = String::from_utf8_lossy(&post.stdout);
- assert!(
- post_code == "303" || post_code == "302",
- "form post http_code={post_code}"
- );
-
- let api = Command::new("curl")
- .args(["-s", &format!("{base}/api/comments")])
- .output()
- .expect("curl comments api");
- let body = String::from_utf8_lossy(&api.stdout);
- assert!(
- body.contains("\"author\":\"alice\"") && body.contains("gold comment"),
- "author must be session user, not forged: {body}"
- );
- assert!(
- body.contains("\"post_slug\":\"hello\""),
- "post_slug must be route param, not forged: {body}"
- );
- assert!(
- !body.contains("forged-attacker") && !body.contains("evil-slug"),
- "forged values must not persist: {body}"
- );
-
- let _ = child.kill();
- let _ = child.wait();
- let _ = std::fs::remove_file(&jar);
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_part_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-part-smoke.mq.md",
- "route-stamp-ok
-home-part-ok
-route-part-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_select_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-select-smoke.mq.md",
- "map-where-ok
-like-ok
-all-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_zh_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-zh-smoke.mq.md",
- "render-ok
-compose-ok
-form-ok
-route-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_static_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-static-smoke.mq.md",
+ "tests/ext/web-static-artifact-smoke.mq.md",
"dir-ok
-mount-ok
-custom-ok",
+mount-ok",
);
}
#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_assets_smoke() {
+fn ext_web_rbac_artifact_smoke() {
ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-assets-smoke.mq.md",
- "images-ok
-head-ok
-meta-icon-ok
-icons-ok
-site-head-ok
-make-images-ok
-make-head-ok",
- );
+ assert_out("tests/ext/web-rbac-artifact-smoke.mq.md", "rbac-ok");
}
#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_assets_live() {
+fn ext_web_cache_artifact_smoke() {
ensure_web_plugin_built();
+ assert_out("tests/ext/web-cache-artifact-smoke.mq.md", "cache-ok");
+}
- let script = "tests/ext/web-assets-live-server.mq.md";
+#[test]
+fn ext_web_artifact_endpoint_live() {
+ ensure_web_plugin_built();
let bin = env!("CARGO_BIN_EXE_marqdo");
+ let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ let site = root.join("tests/ext/web-artifact-site");
let mut child = Command::new(bin)
- .args(["run", script])
- .current_dir(env!("CARGO_MANIFEST_DIR"))
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
+ .args(["run", "serve.mq.md"])
+ .current_dir(&site)
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
.spawn()
- .expect("spawn assets live server");
-
- let base = "http://127.0.0.1:18092";
- let ready = std::time::Instant::now();
- loop {
- if ready.elapsed().as_secs() > 10 {
- let _ = child.kill();
- panic!("assets live server did not start in time");
- }
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- &format!("{base}/"),
- ])
- .output()
- .expect("curl probe");
- if String::from_utf8_lossy(&out.stdout) == "200" {
- break;
- }
- std::thread::sleep(std::time::Duration::from_millis(300));
- }
-
- let out = Command::new("curl")
- .args([
- "-s",
- "-D",
- "-",
- "-o",
- "/tmp/marqdo-favicon.bin",
- "-w",
- "\n%{http_code}",
- &format!("{base}/favicon.ico"),
- ])
- .output()
- .expect("curl favicon");
- let body = String::from_utf8_lossy(&out.stdout);
- assert!(
- body.contains("200") && body.to_ascii_lowercase().contains("image/"),
- "favicon headers={body}"
- );
-
- let out = Command::new("curl")
- .args(["-s", &format!("{base}/")])
- .output()
- .expect("curl home");
- let html = String::from_utf8_lossy(&out.stdout);
- assert!(
- html.contains("rel=\"icon\"") && html.contains("mq-images") && html.contains("apple-touch-icon"),
- "home html missing assets markers: {}",
- &html[..html.len().min(500)]
- );
-
- let _ = child.kill();
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_middleware_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-middleware-smoke.mq.md",
- "cors-origin-ok
-cors-method-ok
-cors-expose-ok
-cors-cred-ok
-security-frame-ok
-security-csp-ok
-compress-ok
-body-limit-ok
-json-get-ok
-json-table-ok
-json-order-ok
-json-limit-ok
-json-post-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_middleware_live() {
- // Boots a real HTTP server and verifies CORS / security headers /
- // gzip / JSON API / body limit over the wire.
- ensure_web_plugin_built();
-
- let script = "tests/ext/web-middleware-live-server.mq.md";
- let bin = env!("CARGO_BIN_EXE_marqdo");
- let mut child = Command::new(bin)
- .args(["run", script])
- .current_dir(env!("CARGO_MANIFEST_DIR"))
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .expect("spawn live server");
-
- // Wait for the listener to accept connections (up to ~10s).
- let base = "http://127.0.0.1:18099";
- let ready = std::time::Instant::now();
- loop {
- if ready.elapsed().as_secs() > 10 {
- let _ = child.kill();
- panic!("live server did not start in time");
- }
- let out = Command::new("curl")
- .args(["-s", "-o", "/dev/null", "-w", "%{http_code}", &format!("{base}/")])
- .output()
- .expect("curl probe");
- if String::from_utf8_lossy(&out.stdout) == "200" {
- break;
- }
- std::thread::sleep(std::time::Duration::from_millis(300));
- }
-
- let code = |args: &[&str]| {
- Command::new("curl")
- .args(args)
- .output()
- .expect("curl")
- };
-
- // JSON API: rows are served as application/json.
- let out = code(&["-s", &format!("{base}/api/posts")]);
- let body = String::from_utf8_lossy(&out.stdout);
- assert!(
- body.contains("\"title\":\"Hello\"") && body.contains("\"rows\""),
- "json api body={body}"
- );
-
- // CORS on the JSON endpoint (matching origin → allow headers).
- // Compare case-insensitively: Go net/http canonicalizes header names.
- let header_has = |headers: &str, needle: &str| -> bool {
- headers.to_ascii_lowercase().contains(&needle.to_ascii_lowercase())
- };
- let out = code(&[
- "-s", "-D", "-", "-o", "/dev/null", &format!("{base}/api/posts"),
- "-H", "Origin: https://a.example",
- ]);
- let headers = String::from_utf8_lossy(&out.stdout);
- assert!(
- header_has(&headers, "access-control-allow-origin: https://a.example"),
- "cors allow-origin headers={headers}"
- );
- assert!(
- header_has(&headers, "access-control-allow-credentials: true"),
- "cors credentials headers={headers}"
- );
- assert!(
- header_has(&headers, "access-control-expose-headers: x-total"),
- "cors expose headers={headers}"
- );
-
- // OPTIONS preflight.
- let out = code(&[
- "-s", "-D", "-", "-o", "/dev/null", "-X", "OPTIONS",
- &format!("{base}/api/posts"),
- "-H", "Origin: https://a.example",
- "-H", "Access-Control-Request-Method: GET",
- ]);
- let headers = String::from_utf8_lossy(&out.stdout);
- assert!(
- header_has(&headers, "access-control-allow-methods: GET"),
- "cors preflight headers={headers}"
- );
- assert!(
- header_has(&headers, "access-control-allow-origin"),
- "cors preflight origin headers={headers}"
- );
-
- // Security response headers on a page render.
- let out = code(&["-s", "-D", "-", "-o", "/dev/null", &format!("{base}/")]);
- let headers = String::from_utf8_lossy(&out.stdout);
- assert!(
- header_has(&headers, "x-frame-options: DENY"),
- "security headers={headers}"
- );
- assert!(
- header_has(&headers, "x-content-type-options: nosniff"),
- "security headers={headers}"
- );
-
- // gzip compression.
- let out = code(&[
- "-s", "-D", "-", "-o", "/dev/null", &format!("{base}/api/posts"),
- "-H", "Accept-Encoding: gzip",
- ]);
- let headers = String::from_utf8_lossy(&out.stdout);
- assert!(
- header_has(&headers, "content-encoding: gzip"),
- "gzip headers={headers}"
- );
-
- // Body limit: small POST ok, large POST → 413.
- let out = code(&[
- "-s", "-o", "/dev/null", "-w", "%{http_code}", "-X", "POST",
- &format!("{base}/api/publish"), "-H", "Content-Type: application/json",
- "-d", r#"{"title":"t1","body":"b1"}"#,
- ]);
- assert_eq!(
- String::from_utf8_lossy(&out.stdout).trim(),
- "200",
- "small POST should pass body limit"
- );
- let big = "x".repeat(2000);
- let out = code(&[
- "-s", "-o", "/dev/null", "-w", "%{http_code}", "-X", "POST",
- &format!("{base}/api/publish"), "-H", "Content-Type: application/json",
- "-d", &big,
- ]);
- assert_eq!(
- String::from_utf8_lossy(&out.stdout).trim(),
- "413",
- "large POST should exceed body limit"
- );
-
- let _ = child.kill();
- let _ = child.wait();
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_proxy_invoke_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-proxy-invoke-smoke.mq.md",
- "proxy-table-ok
-proxy-stream-ok
-proxy-env-ok
-proxy-method-ok
-invoke-table-ok
-invoke-method-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_hosting_live() {
- // Mock upstream SSE on 18142 + Marqdo web proxy/invoke on 18141.
- ensure_web_plugin_built();
-
- use std::io::{Read, Write};
- use std::net::TcpListener;
-
- let upstream = TcpListener::bind("127.0.0.1:18142").expect("bind mock upstream");
- upstream.set_nonblocking(true).ok();
- let upstream_thread = std::thread::spawn(move || {
- let deadline = std::time::Instant::now() + std::time::Duration::from_secs(20);
- loop {
- if std::time::Instant::now() > deadline {
- break;
- }
- match upstream.accept() {
- Ok((mut sock, _)) => {
- let mut buf = [0u8; 4096];
- let _ = sock.set_read_timeout(Some(std::time::Duration::from_secs(2)));
- let _ = sock.read(&mut buf);
- let body = "data: {\"id\":1}\n\ndata: {\"id\":2}\n\n";
- let resp = format!(
- "HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{}",
- body.len(),
- body
- );
- let _ = sock.write_all(resp.as_bytes());
- let _ = sock.flush();
- }
- Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
- std::thread::sleep(std::time::Duration::from_millis(50));
- }
- Err(_) => break,
- }
- }
- });
-
- let script = "tests/ext/web-hosting-live-server.mq.md";
- let bin = env!("CARGO_BIN_EXE_marqdo");
- let mut child = Command::new(bin)
- .args(["run", script])
- .current_dir(env!("CARGO_MANIFEST_DIR"))
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .expect("spawn hosting live server");
-
- let base = "http://127.0.0.1:18141";
+ .expect("spawn artifact site");
+ let base = "http://127.0.0.1:18110";
let ready = std::time::Instant::now();
loop {
if ready.elapsed().as_secs() > 15 {
let _ = child.kill();
- panic!("hosting live server did not start in time");
+ panic!("artifact site did not start");
}
let out = Command::new("curl")
.args(["-s", "-o", "/dev/null", "-w", "%{http_code}", &format!("{base}/")])
.output()
- .expect("curl probe");
+ .expect("curl");
if String::from_utf8_lossy(&out.stdout) == "200" {
break;
}
- std::thread::sleep(std::time::Duration::from_millis(300));
+ std::thread::sleep(std::time::Duration::from_millis(200));
}
-
- // Proxy SSE: expect both data frames.
- let out = Command::new("curl")
- .args([
- "-s",
- "-N",
- "-X",
- "POST",
- &format!("{base}/proxy/sse"),
- "-H",
- "Content-Type: application/json",
- "-d",
- "{}",
- ])
- .output()
- .expect("curl proxy");
- let body = String::from_utf8_lossy(&out.stdout);
+ let about = Command::new("curl").args(["-s", &format!("{base}/about")]).output().unwrap();
+ let about_s = String::from_utf8_lossy(&about.stdout);
+ assert!(about_s.contains("About"), "about={about_s}");
+ let ping = Command::new("curl").args(["-s", &format!("{base}/api/ping")]).output().unwrap();
+ let ping_s = String::from_utf8_lossy(&ping.stdout);
assert!(
- body.contains("data: {\"id\":1}") && body.contains("data: {\"id\":2}"),
- "proxy sse body={body}"
+ ping_s.contains("pong") || ping_s.contains("\"ok\""),
+ "ping={ping_s}"
);
-
- // Invoke twice: demo.echo nests a web.page plugin call; the second request
- // must still see GLOBAL_HOST (listen outer frame) — regression for 0.3.7.
- for (msg, label) in [("hi", "first"), ("again", "second")] {
- let out = Command::new("curl")
- .args([
- "-s",
- "-X",
- "POST",
- &format!("{base}/api/echo"),
- "-H",
- "Content-Type: application/json",
- "-d",
- &format!(r#"{{"msg":"{msg}"}}"#),
- ])
- .output()
- .expect("curl invoke");
- let body = String::from_utf8_lossy(&out.stdout);
- assert!(
- body.contains("\"ok\"")
- && body.contains(&format!("\"msg\":\"{msg}\""))
- && !body.contains("no active host context"),
- "invoke {label} body={body}"
- );
- }
-
let _ = child.kill();
- let _ = child.wait();
- let _ = upstream_thread.join();
}
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_db_cross_module_smoke() {
- ensure_web_plugin_built();
- assert_out("tests/ext/web-db-cross-module-smoke.mq.md", "cross-db-ok");
-}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#[test]
fn ext_agent_mcp_server_smoke() {
@@ -2604,609 +1966,18 @@ jev-alias-ok",
);
}
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_security_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-security-smoke.mq.md",
- "hash-ok
-auth-login-ok
-auth-bad-reject-ok",
- );
-}
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_content_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-content-smoke.mq.md",
- "meta-ok
-paginate-ok
-rss-ok",
- );
-}
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_drivers_smoke() {
- // W4 drivers: memory cache, file storage, postgres/s3 URL shape (offline).
- ensure_web_plugin_built();
- let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("tests/ext/web-fixtures/data/drivers-blobs");
- let _ = std::fs::remove_dir_all(&root);
- assert_out(
- "tests/ext/web-drivers-smoke.mq.md",
- "cache-ok
-cache-del-ok
-storage-ok
-storage-list-ok
-postgres-url-ok
-s3-open-ok",
- );
-}
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_upload_smoke() {
- ensure_web_plugin_built();
- let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("tests/ext/web-fixtures/data/upload-blobs");
- let _ = std::fs::remove_dir_all(&root);
- assert_out(
- "tests/ext/web-upload-smoke.mq.md",
- "validate-ok
-reject-type-ok
-reject-size-ok
-save-ok
-save-roundtrip-ok
-form-file-ok",
- );
-}
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_upload_live() {
- ensure_web_plugin_built();
- let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("tests/ext/web-fixtures/data/upload-live-blobs");
- let _ = std::fs::remove_dir_all(&root);
- let script = "tests/ext/web-upload-live-server.mq.md";
- let bin = env!("CARGO_BIN_EXE_marqdo");
- let mut child = Command::new(bin)
- .args(["run", script])
- .current_dir(env!("CARGO_MANIFEST_DIR"))
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .expect("spawn upload live server");
- let base = "http://127.0.0.1:18101";
- let ready = std::time::Instant::now();
- loop {
- if ready.elapsed().as_secs() > 10 {
- let _ = child.kill();
- panic!("upload live server did not start in time");
- }
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- &format!("{base}/"),
- ])
- .output()
- .expect("curl probe");
- if String::from_utf8_lossy(&out.stdout) == "200" {
- break;
- }
- std::thread::sleep(std::time::Duration::from_millis(300));
- }
- let fixture = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("tests/ext/web-fixtures/upload/sample.txt");
-
- // Happy path multipart upload.
- let out = Command::new("curl")
- .args([
- "-s",
- "-w",
- "\n%{http_code}",
- "-F",
- &format!("file=@{};type=text/plain", fixture.display()),
- &format!("{base}/_upload"),
- ])
- .output()
- .expect("curl upload");
- let body = String::from_utf8_lossy(&out.stdout);
- let (json_part, code) = body.rsplit_once('\n').unwrap_or((&body, ""));
- assert_eq!(code.trim(), "200", "upload body={body}");
- assert!(
- json_part.contains("\"ok\":true") && json_part.contains("\"key\""),
- "upload json={json_part}"
- );
- let key = {
- let v: serde_json::Value =
- serde_json::from_str(json_part).expect("upload json parse");
- v.get("key")
- .and_then(|k| k.as_str())
- .expect("key")
- .to_string()
- };
-
- // Download with Content-Disposition.
- let out = Command::new("curl")
- .args([
- "-s",
- "-D",
- "-",
- "-o",
- "/tmp/marqdo-upload-dl.txt",
- &format!("{base}/_media/{key}"),
- ])
- .output()
- .expect("curl download");
- let headers = String::from_utf8_lossy(&out.stdout).to_ascii_lowercase();
- assert!(
- headers.contains("content-disposition: attachment"),
- "download headers={headers}"
- );
- let dl = std::fs::read_to_string("/tmp/marqdo-upload-dl.txt").expect("dl body");
- assert_eq!(dl, "hello-upload");
-
- // Reject wrong type.
- let bad = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("tests/ext/web-fixtures/upload/bad.bin");
- let _ = std::fs::write(&bad, b"not-allowed");
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- "-F",
- &format!("file=@{};type=application/octet-stream", bad.display()),
- &format!("{base}/_upload"),
- ])
- .output()
- .expect("curl bad type");
- assert_eq!(
- String::from_utf8_lossy(&out.stdout).trim(),
- "400",
- "bad type should 400"
- );
-
- // Oversize (> max_bytes=1024).
- let big = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("tests/ext/web-fixtures/upload/big.txt");
- let _ = std::fs::write(&big, vec![b'x'; 2048]);
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- "-F",
- &format!("file=@{};type=text/plain", big.display()),
- &format!("{base}/_upload"),
- ])
- .output()
- .expect("curl oversize");
- assert_eq!(
- String::from_utf8_lossy(&out.stdout).trim(),
- "400",
- "oversize should 400"
- );
-
- let _ = child.kill();
- let _ = child.wait();
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_db_w6_smoke() {
- // W6: versioned migrate, FTS5 search, published filter + comments table.
- ensure_web_plugin_built();
-
- let db = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("tests/ext/web-fixtures/data/w6-smoke.db");
- for suffix in ["", "-wal", "-shm"] {
- let _ = std::fs::remove_file(format!("{}{}", db.display(), suffix));
- }
- assert_out(
- "tests/ext/web-db-w6-smoke.mq.md",
- "migrate-ok
-migrate-idempotent-ok
-published-filter-ok
-comments-ok
-fts-ok
-fts-row-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_ws_broadcast_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-ws-broadcast-smoke.mq.md",
- "ws-broadcast-route-ok
-access-log-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_w7_finish_smoke() {
- ensure_web_plugin_built();
- assert_out(
- "tests/ext/web-w7-finish-smoke.mq.md",
- "unique-ok
-sitemap-ok
-redirect-ok
-robots-ok
-cache-control-ok
-error-page-ok",
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_w7_live() {
- ensure_web_plugin_built();
-
- let script = "tests/ext/web-w7-live-server.mq.md";
- let bin = env!("CARGO_BIN_EXE_marqdo");
- let mut child = Command::new(bin)
- .args(["run", script])
- .current_dir(env!("CARGO_MANIFEST_DIR"))
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .expect("spawn w7 live server");
-
- let base = "http://127.0.0.1:18121";
- let ready = std::time::Instant::now();
- loop {
- if ready.elapsed().as_secs() > 10 {
- let _ = child.kill();
- panic!("w7 live server did not start in time");
- }
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- &format!("{base}/"),
- ])
- .output()
- .expect("curl probe");
- if String::from_utf8_lossy(&out.stdout) == "200" {
- break;
- }
- std::thread::sleep(std::time::Duration::from_millis(300));
- }
-
- // Permanent redirect
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}|%{redirect_url}",
- &format!("{base}/legacy"),
- ])
- .output()
- .expect("curl redirect");
- let redir = String::from_utf8_lossy(&out.stdout);
- assert!(
- redir.starts_with("301|") && redir.contains("/"),
- "redirect got {redir}"
- );
-
- // Custom 404
- let out = Command::new("curl")
- .args(["-s", "-w", "\n%{http_code}", &format!("{base}/no-such")])
- .output()
- .expect("curl 404");
- let body = String::from_utf8_lossy(&out.stdout);
- assert!(
- body.contains("Not Found Page") && body.trim_end().ends_with("404"),
- "404 body={body}"
- );
-
- // Sitemap
- let out = Command::new("curl")
- .args(["-s", &format!("{base}/sitemap.xml")])
- .output()
- .expect("curl sitemap");
- let sm = String::from_utf8_lossy(&out.stdout);
- assert!(
- sm.contains("
10 {
- let _ = child.kill();
- panic!("p3 live server did not start in time");
- }
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- &format!("{base}/"),
- ])
- .output()
- .expect("curl probe");
- if String::from_utf8_lossy(&out.stdout) == "200" {
- break;
- }
- std::thread::sleep(std::time::Duration::from_millis(300));
- }
-
- let out = Command::new("curl")
- .args(["-s", &format!("{base}/gallery")])
- .output()
- .expect("curl gallery");
- let gal = String::from_utf8_lossy(&out.stdout);
- assert!(
- gal.contains("P3 Gallery") && gal.contains("hello.txt"),
- "gallery={gal}"
- );
-
- let out = Command::new("curl")
- .args([
- "-s",
- "-D",
- "-",
- "-o",
- "/dev/null",
- &format!("{base}/_media/uploads/hello.txt"),
- ])
- .output()
- .expect("curl media");
- let headers_raw = String::from_utf8_lossy(&out.stdout);
- let headers = headers_raw.to_ascii_lowercase();
- assert!(headers.contains("etag:"), "media headers={headers}");
- let etag = headers_raw
- .lines()
- .find(|l| l.to_ascii_lowercase().starts_with("etag:"))
- .map(|l| l.split_once(':').map(|(_, v)| v.trim().trim_matches('\r').to_string()).unwrap_or_default())
- .expect("etag line");
-
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- "-H",
- &format!("If-None-Match: {etag}"),
- &format!("{base}/_media/uploads/hello.txt"),
- ])
- .output()
- .expect("curl 304");
- assert_eq!(
- String::from_utf8_lossy(&out.stdout),
- "304",
- "expected 304 for If-None-Match"
- );
-
- let _ = child.kill();
- let _ = child.wait();
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_ws_broadcast_live() {
- use futures_util::{SinkExt, StreamExt};
- use tokio_tungstenite::tungstenite::Message;
-
- ensure_web_plugin_built();
-
- let script = "tests/ext/web-ws-broadcast-live-server.mq.md";
- let bin = env!("CARGO_BIN_EXE_marqdo");
- let mut child = Command::new(bin)
- .args(["run", script])
- .current_dir(env!("CARGO_MANIFEST_DIR"))
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .spawn()
- .expect("spawn ws live server");
-
- let base = "http://127.0.0.1:18112";
- let ready = std::time::Instant::now();
- loop {
- if ready.elapsed().as_secs() > 10 {
- let _ = child.kill();
- panic!("ws live server did not start in time");
- }
- let out = Command::new("curl")
- .args([
- "-s",
- "-o",
- "/dev/null",
- "-w",
- "%{http_code}",
- &format!("{base}/"),
- ])
- .output()
- .expect("curl probe");
- if String::from_utf8_lossy(&out.stdout) == "200" {
- break;
- }
- std::thread::sleep(std::time::Duration::from_millis(300));
- }
-
- let rt = tokio::runtime::Runtime::new().expect("rt");
- rt.block_on(async {
- let (a, _) = tokio_tungstenite::connect_async("ws://127.0.0.1:18112/room")
- .await
- .expect("connect a");
- let (b, _) = tokio_tungstenite::connect_async("ws://127.0.0.1:18112/room")
- .await
- .expect("connect b");
- let (mut a_sink, mut a_src) = a.split();
- let (mut b_sink, mut b_src) = b.split();
-
- // Give subscriptions a moment to register.
- tokio::time::sleep(std::time::Duration::from_millis(50)).await;
-
- b_sink
- .send(Message::Text("ping-from-b".into()))
- .await
- .expect("send b");
-
- let got_a = tokio::time::timeout(
- std::time::Duration::from_secs(3),
- a_src.next(),
- )
- .await
- .expect("a timeout")
- .expect("a closed")
- .expect("a err");
- let got_b = tokio::time::timeout(
- std::time::Duration::from_secs(3),
- b_src.next(),
- )
- .await
- .expect("b timeout")
- .expect("b closed")
- .expect("b err");
-
- match got_a {
- Message::Text(t) => assert_eq!(t, "ping-from-b"),
- other => panic!("a unexpected {other:?}"),
- }
- match got_b {
- Message::Text(t) => assert_eq!(t, "ping-from-b"),
- other => panic!("b unexpected {other:?}"),
- }
-
- let _ = a_sink.close().await;
- let _ = b_sink.close().await;
- });
-
- // Access log should have recorded the probe GET /.
- let _ = child.kill();
- let out = child.wait_with_output().expect("wait");
- let stderr = String::from_utf8_lossy(&out.stderr);
- assert!(
- stderr.contains("marqdo web GET / 200"),
- "access log missing in stderr={stderr}"
- );
-}
-
-#[test]
-#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
-fn ext_web_db_w2_smoke() {
- // W2 data layer: transactions, connection pooling, pagination, query
- // expressiveness (IN/BETWEEN/OR), and row counting.
- ensure_web_plugin_built();
-
- let db = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .join("tests/ext/web-fixtures/data/w2-smoke.db");
- for suffix in ["", "-wal", "-shm"] {
- let _ = std::fs::remove_file(format!("{}{}", db.display(), suffix));
- }
- assert_out(
- "tests/ext/web-db-w2-smoke.mq.md",
- "count-ok
-count-where-ok
-page-ok
-page2-ok
-in-ok
-between-ok
-or-ok
-query-ok
-txn-commit-ok
-txn-rollback-ok",
- );
-}
#[test]
fn ext_linalg_doc_smoke() {