
* first attempt to upgrade express to v5 Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * try to fix https://github.com/maptiler/tileserver-gl/issues/1411 Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup server.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup serve_font.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup sever_rendered.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup server_data.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup serve_style Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * Update serve_style.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * Move UV_THREADPOOL_SIZE to main thred Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup utils.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * Use common app.get for images and static images Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * add allowedTileSizes and option Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup error responses Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * fix /style/id.json with next('route') Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * improve sprite path Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * add parseFloadts around zxy Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * simplify server_data Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * move tile fetch and add fix verbose logging Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * add Handling request to verbose logging Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * first attempt to upgrade express to v5 Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * try to fix https://github.com/maptiler/tileserver-gl/issues/1411 Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup server.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup serve_font.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup sever_rendered.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup server_data.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup serve_style Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * Update serve_style.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * Move UV_THREADPOOL_SIZE to main thred Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup utils.js Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * Use common app.get for images and static images Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * add allowedTileSizes and option Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * cleanup error responses Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * fix /style/id.json with next('route') Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * improve sprite path Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * add parseFloadts around zxy Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * simplify server_data Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * move tile fetch and add fix verbose logging Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * add Handling request to verbose logging Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net> * merge elevation changes * lint format * add verbose logging, improve headers * try to fix codeql Information exposure through a stack trace * test * all tests passing * cleanup unneeded changes * cleanup * try to fix codeql error * font fixes * fix tile size issue * try to improve scale + codeql * codeql for sprite logging * codeql serve fonts * codeql fixes * fix failing test with multiple fonts * Update serve_font.js * codeql * codeql * codeql * Update utils.js * codeql * codeql * codeql * codeql * codeql sanitize * Update serve_font.js * Update serve_font.js * remove useless assignment * move isGzipped * add if-modified-since and cache-control * use consistent cache control * reformat * codeql * codeql * codeql * codeql * codeql * codeql * codeql * Update serve_font.js * Update serve_font.js * Update serve_font.js * Update serve_style.js * Update serve_style.js * Update serve_style.js * Revert "Update serve_style.js" This reverts commite0574b1887
. * Revert "Update serve_style.js" This reverts commitb1e1d72f25
. * Revert "Update serve_style.js" This reverts commit0f3629c752
. * Add readFile function * use readFile, add path.normalize * Update serve_rendered.js * simplify input checking * Update utils.js * codeql * Revert "codeql" This reverts commite18874fda0
. * Revert "Update utils.js" This reverts commit5de617dfe2
. * Revert "simplify input checking" This reverts commit62a3212629
. * move allowed functions to utils.js * use xy[0],xy[1], * uprade canvas per https://github.com/maptiler/tileserver-gl/issues/1433 * make font regex less restrictive * fix regex error * Add version and changelog * Update CHANGELOG.md * Update CHANGELOG.md
210 lines
5.2 KiB
JavaScript
210 lines
5.2 KiB
JavaScript
const testStatic = function (prefix, q, format, status, scale, type, query) {
|
|
if (scale) q += '@' + scale + 'x';
|
|
let path = '/styles/' + prefix + '/static/' + q + '.' + format;
|
|
if (query) {
|
|
path += query;
|
|
}
|
|
it(path + ' returns ' + status, function (done) {
|
|
const test = supertest(app).get(path);
|
|
if (status) test.expect(status);
|
|
if (type) test.expect('Content-Type', type);
|
|
test.end(done);
|
|
});
|
|
};
|
|
|
|
const prefix = 'test-style';
|
|
|
|
describe('Static endpoints', function () {
|
|
describe('center-based', function () {
|
|
describe('valid requests', function () {
|
|
describe('various formats', function () {
|
|
testStatic(
|
|
prefix,
|
|
'0,0,0/256x256',
|
|
'png',
|
|
200,
|
|
undefined,
|
|
/image\/png/,
|
|
);
|
|
testStatic(
|
|
prefix,
|
|
'0,0,0/256x256',
|
|
'jpg',
|
|
200,
|
|
undefined,
|
|
/image\/jpeg/,
|
|
);
|
|
testStatic(
|
|
prefix,
|
|
'0,0,0/256x256',
|
|
'jpeg',
|
|
200,
|
|
undefined,
|
|
/image\/jpeg/,
|
|
);
|
|
testStatic(
|
|
prefix,
|
|
'0,0,0/256x256',
|
|
'webp',
|
|
200,
|
|
undefined,
|
|
/image\/webp/,
|
|
);
|
|
});
|
|
|
|
describe('different parameters', function () {
|
|
testStatic(prefix, '0,0,0/300x300', 'png', 200, 2);
|
|
testStatic(prefix, '0,0,0/300x300', 'png', 200, 3);
|
|
|
|
testStatic(prefix, '0,0,1.5/256x256', 'png', 200);
|
|
|
|
testStatic(prefix, '80,40,20/600x300', 'png', 200, 3);
|
|
testStatic(prefix, '8.5,40.5,20/300x150', 'png', 200, 3);
|
|
testStatic(prefix, '-8.5,-40.5,20/300x150', 'png', 200, 3);
|
|
|
|
testStatic(prefix, '8,40,2@0,0/300x150', 'png', 200);
|
|
testStatic(prefix, '8,40,2@180,45/300x150', 'png', 200, 2);
|
|
testStatic(prefix, '8,40,2@10/300x150', 'png', 200, 3);
|
|
testStatic(prefix, '8,40,2@10.3,20.4/300x300', 'png', 200);
|
|
testStatic(prefix, '0,0,2@390,120/300x300', 'png', 200);
|
|
});
|
|
});
|
|
|
|
describe('invalid requests return 4xx', function () {
|
|
testStatic(prefix, '190,0,0/256x256', 'png', 400);
|
|
testStatic(prefix, '0,86,0/256x256', 'png', 400);
|
|
testStatic(prefix, '80,40,20/0x0', 'png', 400);
|
|
testStatic(prefix, '0,0,0/256x256', 'gif', 400);
|
|
testStatic(prefix, '0,0,0/256x256', 'png', 404, 1);
|
|
|
|
testStatic(prefix, '0,0,-1/256x256', 'png', 404);
|
|
testStatic(prefix, '0,0,0/256.5x256.5', 'png', 400);
|
|
|
|
testStatic(prefix, '0,0,0,/256x256', 'png', 404);
|
|
testStatic(prefix, '0,0,0,0,/256x256', 'png', 404);
|
|
});
|
|
});
|
|
|
|
describe('area-based', function () {
|
|
describe('valid requests', function () {
|
|
describe('various formats', function () {
|
|
testStatic(
|
|
prefix,
|
|
'-180,-80,180,80/10x10',
|
|
'png',
|
|
200,
|
|
undefined,
|
|
/image\/png/,
|
|
);
|
|
testStatic(
|
|
prefix,
|
|
'-180,-80,180,80/10x10',
|
|
'jpg',
|
|
200,
|
|
undefined,
|
|
/image\/jpeg/,
|
|
);
|
|
testStatic(
|
|
prefix,
|
|
'-180,-80,180,80/10x10',
|
|
'jpeg',
|
|
200,
|
|
undefined,
|
|
/image\/jpeg/,
|
|
);
|
|
testStatic(
|
|
prefix,
|
|
'-180,-80,180,80/10x10',
|
|
'webp',
|
|
200,
|
|
undefined,
|
|
/image\/webp/,
|
|
);
|
|
});
|
|
|
|
describe('different parameters', function () {
|
|
testStatic(prefix, '-180,-90,180,90/20x20', 'png', 200, 2);
|
|
testStatic(prefix, '0,0,1,1/200x200', 'png', 200, 3);
|
|
|
|
testStatic(prefix, '-280,-80,0,80/280x160', 'png', 200);
|
|
});
|
|
});
|
|
|
|
describe('invalid requests return 4xx', function () {
|
|
testStatic(prefix, '0,87,1,88/5x2', 'png', 400);
|
|
|
|
testStatic(prefix, '0,0,1,1/1x1', 'gif', 400);
|
|
|
|
testStatic(prefix, '-180,-80,180,80/0.5x2.6', 'png', 400);
|
|
});
|
|
});
|
|
|
|
describe('autofit path', function () {
|
|
describe('valid requests', function () {
|
|
testStatic(
|
|
prefix,
|
|
'auto/256x256',
|
|
'png',
|
|
200,
|
|
undefined,
|
|
/image\/png/,
|
|
'?path=10,10|20,20',
|
|
);
|
|
|
|
describe('different parameters', function () {
|
|
testStatic(
|
|
prefix,
|
|
'auto/20x20',
|
|
'png',
|
|
200,
|
|
2,
|
|
/image\/png/,
|
|
'?path=10,10|20,20',
|
|
);
|
|
testStatic(
|
|
prefix,
|
|
'auto/200x200',
|
|
'png',
|
|
200,
|
|
3,
|
|
/image\/png/,
|
|
'?path=-10,-10|-20,-20',
|
|
);
|
|
});
|
|
|
|
describe('encoded path', function () {
|
|
testStatic(
|
|
prefix,
|
|
'auto/20x20',
|
|
'png',
|
|
200,
|
|
2,
|
|
/image\/png/,
|
|
'?path=' + encodeURIComponent('enc:{{biGwvyGoUi@s_A|{@'),
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('invalid requests return 4xx', function () {
|
|
testStatic(prefix, 'auto/256x256', 'png', 400);
|
|
testStatic(
|
|
prefix,
|
|
'auto/256x256',
|
|
'png',
|
|
400,
|
|
undefined,
|
|
undefined,
|
|
'?path=invalid',
|
|
);
|
|
testStatic(
|
|
prefix,
|
|
'auto/2560x2560',
|
|
'png',
|
|
400,
|
|
undefined,
|
|
undefined,
|
|
'?path=10,10|20,20',
|
|
);
|
|
});
|
|
});
|
|
});
|