Files
windmill/frontend/src/lib/components/instanceSettingsWebhookBaseUrl.test.ts
T
318c9f0073 feat(git-sync): dedicated base url for GitHub webhook delivery (#10411)
* feat(git-sync): let GitHub webhooks register a dedicated base url

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): validate the webhook base url and apply it on change

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore: pin ee ref for the git-sync webhook base url change

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): validate and reconcile the webhook base url on every write path

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): route every declarative settings writer through the same rules

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): let the reconciler own the webhook field write-back

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): make the webhook base url validators agree across UI and server

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): lock the workspace row across git_sync read-modify-writes

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test: pin the webhook base url validator to its server counterpart

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): retry a failed webhook move on every re-apply of the setting

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): retry pending webhook moves on every declarative re-apply

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): reject non-string webhook base urls and bound the sweep

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): reject credential-bearing webhook base urls

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): keep credentials out of webhook base url validation errors

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): redact through the last authority @ when reporting a bad url

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): stop echoing unparsed webhook base urls instead of scrubbing them

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): never echo a submitted webhook base url in validation errors

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): keep the submitted scheme out of validation errors

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* refactor(git-sync): drop the webhook sweep, surface stale receivers in settings

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): refresh the stale webhook list when settings are saved

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): mark registered_url nullable and drop the duplicated field error

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore: pin ee ref after dropping the reconcile lock and CAS

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(git-sync): refresh the stale webhook list on category saves too

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore: update ee-repo-ref to aa05ca8e97fc8265cd724753a80db37f83243254

This commit updates the EE repository reference after PR #695 was merged in windmill-ee-private.

Previous ee-repo-ref: 3e6cd9226b68707233ae2434511fe5131dce808b

New ee-repo-ref: aa05ca8e97fc8265cd724753a80db37f83243254

Automated by sync-ee-ref workflow.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-07-30 23:27:12 +02:00

55 lines
1.7 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'
]
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)
})
})