mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-30 00:07:30 +00:00
fix: refuse app component runs with both a path and an id
This commit is contained in:
@@ -388,3 +388,49 @@ async fn test_app_preview_authorization(db: Pool<Postgres>) -> anyhow::Result<()
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx::test(fixtures("base"))]
|
||||
async fn test_path_with_id_is_refused(db: Pool<Postgres>) -> anyhow::Result<()> {
|
||||
initialize_tracing().await;
|
||||
let server = ApiServer::start(db.clone()).await?;
|
||||
let ws = format!(
|
||||
"http://localhost:{}/api/w/test-workspace",
|
||||
server.addr.port()
|
||||
);
|
||||
|
||||
let app_path = "u/test-user/path_with_id";
|
||||
let resp = authed(client().post(format!("{ws}/apps/create")), "SECRET_TOKEN")
|
||||
.json(&json!({
|
||||
"path": app_path,
|
||||
"summary": "",
|
||||
"value": {},
|
||||
"policy": {
|
||||
"execution_mode": "viewer",
|
||||
"triggerables_v2": {
|
||||
"comp:script/u/test-user/ok": { "static_inputs": {}, "one_of_inputs": {} }
|
||||
}
|
||||
}
|
||||
}))
|
||||
.send()
|
||||
.await?;
|
||||
assert_eq!(resp.status(), 201, "create app: {}", resp.text().await?);
|
||||
|
||||
let resp = authed(
|
||||
client().post(format!("{ws}/apps_u/execute_component/{app_path}")),
|
||||
"SECRET_TOKEN",
|
||||
)
|
||||
.json(&json!({
|
||||
"args": {},
|
||||
"component": "comp",
|
||||
"path": "script/u/test-user/ok",
|
||||
"id": 1
|
||||
}))
|
||||
.send()
|
||||
.await?;
|
||||
let status = resp.status();
|
||||
let body = resp.text().await?;
|
||||
assert_eq!(status, 400, "path with id must be refused: {body}");
|
||||
assert!(body.contains("path and id cannot be set"), "got: {body}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -16240,6 +16240,7 @@ paths:
|
||||
#flow: flow/<path>
|
||||
path:
|
||||
type: string
|
||||
description: Runnable to run. Cannot be sent with `raw_code` or `id`.
|
||||
version:
|
||||
type: integer
|
||||
args: {}
|
||||
@@ -16269,6 +16270,7 @@ paths:
|
||||
- language
|
||||
id:
|
||||
type: integer
|
||||
description: ID of a deployed inline script, sent with `raw_code`. Cannot be sent with `path`.
|
||||
force_viewer_static_fields:
|
||||
type: object
|
||||
force_viewer_one_of_fields:
|
||||
|
||||
@@ -4577,6 +4577,11 @@ async fn execute_component(
|
||||
"path and raw_code cannot be set at the same time".to_string(),
|
||||
))
|
||||
}
|
||||
(true, false) if payload.id.is_some() => {
|
||||
return Err(Error::BadRequest(
|
||||
"path and id cannot be set at the same time".to_string(),
|
||||
))
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user