mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-11 13:49:03 +00:00
a8f73b05b9
Use documentation-range 203.0.113.10 so Secret Scan (betterdesk-internal-lan-ip) passes on the main→dev sync PR.
35 lines
1.4 KiB
JavaScript
35 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const {
|
|
isValidOidcRedirectUrl,
|
|
parseOidcRedirectUrl,
|
|
suggestOidcRedirectUrl,
|
|
} = require('../lib/oidcRedirectUrl');
|
|
|
|
describe('oidcRedirectUrl', () => {
|
|
it('accepts panel and API callback paths', () => {
|
|
expect(isValidOidcRedirectUrl('https://host:5443/api/auth/oidc/callback')).toBe(true);
|
|
expect(isValidOidcRedirectUrl('http://host:21114/api/auth/oidc/callback')).toBe(true);
|
|
expect(isValidOidcRedirectUrl('https://host:21121/api/oidc/callback')).toBe(true);
|
|
expect(isValidOidcRedirectUrl('https://host/api/auth/oidc/callback/')).toBe(true);
|
|
});
|
|
|
|
it('rejects wrong path, scheme, or empty', () => {
|
|
expect(isValidOidcRedirectUrl('')).toBe(false);
|
|
expect(isValidOidcRedirectUrl('https://host:5443/login')).toBe(false);
|
|
expect(isValidOidcRedirectUrl('https://host:5443/api/auth/oidc/session')).toBe(false);
|
|
expect(isValidOidcRedirectUrl('ftp://host/api/auth/oidc/callback')).toBe(false);
|
|
expect(parseOidcRedirectUrl('not a url').ok).toBe(false);
|
|
});
|
|
|
|
it('suggests panel callback URL', () => {
|
|
expect(suggestOidcRedirectUrl('https://203.0.113.10:5443')).toBe(
|
|
'https://203.0.113.10:5443/api/auth/oidc/callback'
|
|
);
|
|
expect(suggestOidcRedirectUrl('https://example.com/')).toBe(
|
|
'https://example.com/api/auth/oidc/callback'
|
|
);
|
|
expect(suggestOidcRedirectUrl('')).toBe('');
|
|
});
|
|
});
|