release: prepare 0629001 portal updates
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { validateWechatShareSignatureUrl } from './wechat-share.mjs';
|
||||
|
||||
test('validateWechatShareSignatureUrl accepts public H5 page urls without login state', () => {
|
||||
assert.equal(
|
||||
validateWechatShareSignatureUrl('https://m.tkmind.cn/u/john/pages/demo#section', {
|
||||
publicBaseUrl: 'https://m.tkmind.cn',
|
||||
requestHost: '127.0.0.1:8081',
|
||||
}),
|
||||
'https://m.tkmind.cn/u/john/pages/demo',
|
||||
);
|
||||
});
|
||||
|
||||
test('validateWechatShareSignatureUrl accepts current request host for local verification', () => {
|
||||
assert.equal(
|
||||
validateWechatShareSignatureUrl('http://127.0.0.1:8081/MindSpace/user-1/public/demo.html', {
|
||||
publicBaseUrl: 'https://m.tkmind.cn',
|
||||
requestHost: '127.0.0.1:8081',
|
||||
}),
|
||||
'http://127.0.0.1:8081/MindSpace/user-1/public/demo.html',
|
||||
);
|
||||
});
|
||||
|
||||
test('validateWechatShareSignatureUrl rejects foreign hosts', () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
validateWechatShareSignatureUrl('https://evil.example/u/john/pages/demo', {
|
||||
publicBaseUrl: 'https://m.tkmind.cn',
|
||||
requestHost: '127.0.0.1:8081',
|
||||
}),
|
||||
(error) => error.code === 'host_not_allowed',
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user