PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
import { describe, expect, it } from 'vitest';
import { validateTelegramNotifier } from './validateTelegramNotifier';
describe('validateTelegramNotifier', () => {
it('requires proxy URL when proxy is enabled for a new notifier', () => {
expect(
validateTelegramNotifier(true, {
botToken: 'token',
targetChatId: '123456',
isProxyEnabled: true,
}),
).toBe(false);
});
it('allows an empty proxy URL on update (keeps the existing one)', () => {
expect(
validateTelegramNotifier(false, {
botToken: '',
targetChatId: '123456',
isProxyEnabled: true,
}),
).toBe(true);
});
it('rejects proxy URLs with an unsupported scheme', () => {
expect(
validateTelegramNotifier(true, {
botToken: 'token',
targetChatId: '123456',
isProxyEnabled: true,
proxyUrl: 'ftp://proxy.example.com:3128',
}),
).toBe(false);
});
it('accepts http, https, socks5 and socks5h proxy URLs', () => {
for (const proxyUrl of [
'http://user:[email protected]:3128',
'https://proxy.example.com:8443',
'socks5://user:[email protected]:1080',
'socks5h://proxy.example.com:1080',
]) {
expect(
validateTelegramNotifier(true, {
botToken: 'token',
targetChatId: '123456',
isProxyEnabled: true,
proxyUrl,
}),
).toBe(true);
}
});
it('accepts an empty Bot API URL and plain http or https addresses', () => {
for (const botApiUrl of [
undefined,
'',
'http://localhost:8081',
'http://telegram-bot-api:8081',
'https://gateway.example.com',
'https://gateway.example.com/telegram/',
]) {
expect(
validateTelegramNotifier(true, { botToken: 'token', targetChatId: '123456', botApiUrl }),
).toBe(true);
}
});
it('rejects Bot API URLs with another scheme, no host, credentials, a query or a fragment', () => {
for (const botApiUrl of [
'ftp://telegram.example.com',
'telegram-bot-api:8081',
'https://',
'gateway.example.com/telegram',
'https://user:[email protected]',
'https://[email protected]',
'https://gateway.example.com/telegram?key=1',
'https://gateway.example.com/telegram?',
'https://gateway.example.com/#bot',
'https://gateway.example.com/#',
]) {
expect(
validateTelegramNotifier(true, { botToken: 'token', targetChatId: '123456', botApiUrl }),
).toBe(false);
}
});
});