mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-18 08:03:11 +00:00
* feat: add an api base url instance setting for displayed urls * feat: show the api base url as cli remote, keep mcp url on origin * fix: keep push captures on origin and load the api base url on svix page * fix: reject shell metacharacters in webhook and api base urls * test: drop the trivial api base url resolver test * feat: hide the api base url setting behind a toggle * fix: let the quick setup toggle reveal the api base url field * chore: update ee-repo-ref to 017710bdd0a10de857f0f40800dde238cdb1ad24 This commit updates the EE repository reference after PR #863 was merged in windmill-ee-private. Previous ee-repo-ref: f67cd621bd45840e6389e0469a67378864f269a0 New ee-repo-ref: 017710bdd0a10de857f0f40800dde238cdb1ad24 Automated by sync-ee-ref workflow. --------- Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { isValidWebhookBaseUrl } from './instanceSettings'
|
|
|
|
/**
|
|
* Kept in lockstep with `webhook_base_url_matches_the_ui_validator` in
|
|
* backend/windmill-common/src/global_settings.rs — the same table on both sides, so
|
|
* a value this field accepts can never be rejected on save, and vice versa. Add
|
|
* cases to both or neither.
|
|
*/
|
|
const ACCEPTED = [
|
|
'https://hooks.example.com',
|
|
'http://hooks.example.com:8080',
|
|
'https://example.com/windmill',
|
|
' https://hooks.example.com ',
|
|
'https://[::1]:8000'
|
|
]
|
|
|
|
const REJECTED = [
|
|
'httpss://hooks.example.com',
|
|
'hooks.example.com',
|
|
'ftp://hooks.example.com',
|
|
'https://',
|
|
'https://hooks.example.com?token=x',
|
|
'https://hooks.example.com#frag',
|
|
'https://hooks example.com',
|
|
'https://hooks.example.com/',
|
|
'https://hooks.example.com:abc',
|
|
'https://x/a b',
|
|
'https://hooks.example.com?',
|
|
'https://hooks.example.com#',
|
|
'https://user:password@hooks.example.com',
|
|
'https://user@hooks.example.com',
|
|
'https://hooks.example.com/$(uname)',
|
|
'https://hooks.example.com/`uname`',
|
|
'https://hooks.example.com/a;b'
|
|
]
|
|
|
|
describe('isValidWebhookBaseUrl', () => {
|
|
it.each(ACCEPTED)('accepts %j', (value) => {
|
|
expect(isValidWebhookBaseUrl(value)).toBe(true)
|
|
})
|
|
|
|
it.each(REJECTED)('rejects %j', (value) => {
|
|
expect(isValidWebhookBaseUrl(value)).toBe(false)
|
|
})
|
|
|
|
it.each([true, 42, {}, [], null] as unknown[])(
|
|
'rejects the non-string %j without throwing',
|
|
(value) => {
|
|
// `Setting.isValid` is typed `any` and YAML mode can supply any JSON shape.
|
|
expect(isValidWebhookBaseUrl(value as never)).toBe(value === null)
|
|
}
|
|
)
|
|
|
|
it('treats unset and blank as valid, since the setting is optional', () => {
|
|
expect(isValidWebhookBaseUrl(undefined)).toBe(true)
|
|
expect(isValidWebhookBaseUrl('')).toBe(true)
|
|
expect(isValidWebhookBaseUrl(' ')).toBe(true)
|
|
})
|
|
})
|