You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-11-27 22:38:10 +02:00
Add URI parsing tests #1053
This commit is contained in:
10
package-lock.json
generated
10
package-lock.json
generated
@@ -60,7 +60,7 @@
|
||||
"@types/cookie-parser": "1.4.9",
|
||||
"@types/cookie-session": "2.0.49",
|
||||
"@types/ejs": "3.1.5",
|
||||
"@types/express": "4.17.23",
|
||||
"@types/express": "4.17.25",
|
||||
"@types/fluent-ffmpeg": "2.1.27",
|
||||
"@types/gulp": "4.0.17",
|
||||
"@types/gulp-sourcemaps": "0.0.38",
|
||||
@@ -7222,16 +7222,16 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/express": {
|
||||
"version": "4.17.23",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.23.tgz",
|
||||
"integrity": "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ==",
|
||||
"version": "4.17.25",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.25.tgz",
|
||||
"integrity": "sha512-dVd04UKsfpINUnK0yBoYHDF3xu7xVH4BuDotC/xGuycx4CgbP48X/KF/586bcObxT0HENHXEU8Nqtu6NR+eKhw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/body-parser": "*",
|
||||
"@types/express-serve-static-core": "^4.17.33",
|
||||
"@types/qs": "*",
|
||||
"@types/serve-static": "*"
|
||||
"@types/serve-static": "^1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/express-serve-static-core": {
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
"@types/cookie-parser": "1.4.9",
|
||||
"@types/cookie-session": "2.0.49",
|
||||
"@types/ejs": "3.1.5",
|
||||
"@types/express": "4.17.23",
|
||||
"@types/express": "4.17.25",
|
||||
"@types/fluent-ffmpeg": "2.1.27",
|
||||
"@types/gulp": "4.0.17",
|
||||
"@types/gulp-sourcemaps": "0.0.38",
|
||||
|
||||
@@ -246,7 +246,7 @@ export class GalleryMWs {
|
||||
} catch (e) {
|
||||
return next(
|
||||
new ErrorDTO(
|
||||
ErrorCodes.GENERAL_ERROR,
|
||||
ErrorCodes.PATH_ERROR,
|
||||
'no such file:' + req.params['mediaPath'],
|
||||
'can\'t find file: ' + fullMediaPath
|
||||
)
|
||||
|
||||
@@ -19,6 +19,7 @@ export enum ErrorCodes {
|
||||
USER_MANAGEMENT_DISABLED = 40,
|
||||
|
||||
INPUT_ERROR = 50,
|
||||
PATH_ERROR = 51,
|
||||
|
||||
SETTINGS_ERROR = 60,
|
||||
TASK_ERROR = 61,
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import {Config} from '../../../../src/common/config/private/Config';
|
||||
import {Server} from '../../../../src/backend/server';
|
||||
import * as path from 'path';
|
||||
import * as chai from 'chai';
|
||||
import {expect} from 'chai';
|
||||
import {SuperAgentStatic} from 'superagent';
|
||||
import {ProjectPath} from '../../../../src/backend/ProjectPath';
|
||||
import {DBTestHelper} from '../../DBTestHelper';
|
||||
import {ReIndexingSensitivity} from '../../../../src/common/config/private/PrivateConfig';
|
||||
import {TestHelper} from '../../../TestHelper';
|
||||
import * as chai from "chai";
|
||||
import {default as chaiHttp, request} from "chai-http";
|
||||
import {default as chaiHttp, request} from 'chai-http';
|
||||
import {ErrorCodes} from '../../../../src/common/entities/Error';
|
||||
|
||||
process.env.NODE_ENV = 'test';
|
||||
chai.should();
|
||||
@@ -76,6 +77,52 @@ describe('GalleryRouter', (sqlHelper: DBTestHelper) => {
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('express uri parsing', async () => {
|
||||
|
||||
|
||||
beforeEach(setUp);
|
||||
afterEach(tearDown);
|
||||
|
||||
it('express should parse path orientation/JPEG', async () => {
|
||||
Config.Indexing.reIndexingSensitivity = ReIndexingSensitivity.low;
|
||||
const result = await (request.execute(server.Server) as SuperAgentStatic)
|
||||
.get(Config.Server.apiPath + '/gallery/content/orientation/JPEG');
|
||||
|
||||
|
||||
(result.should as any).have.status(200);
|
||||
expect(result.body.error).to.not.be.equal(null);
|
||||
expect(result.body.result).to.be.equal(null);
|
||||
expect(result.body.error.code).to.be.equal(ErrorCodes.PATH_ERROR);
|
||||
});
|
||||
|
||||
|
||||
it('express should parse path orientation encoded', async () => {
|
||||
Config.Indexing.reIndexingSensitivity = ReIndexingSensitivity.low;
|
||||
const result = await (request.execute(server.Server) as SuperAgentStatic)
|
||||
.get(Config.Server.apiPath + '/gallery/content/' + encodeURIComponent('orientation'));
|
||||
|
||||
|
||||
(result.should as any).have.status(200);
|
||||
expect(result.body.error).to.be.equal(null);
|
||||
expect(result.body.result).to.not.be.equal(null);
|
||||
expect(result.body.result.directory).to.not.be.equal(null);
|
||||
});
|
||||
|
||||
it('express should parse path orientation/JPEG encoded', async () => {
|
||||
Config.Indexing.reIndexingSensitivity = ReIndexingSensitivity.low;
|
||||
const result = await (request.execute(server.Server) as SuperAgentStatic)
|
||||
.get(Config.Server.apiPath + '/gallery/content/' + encodeURIComponent('orientation/JPEG'));
|
||||
|
||||
|
||||
(result.should as any).have.status(200);
|
||||
expect(result.body.error).to.not.be.equal(null);
|
||||
expect(result.body.result).to.be.equal(null);
|
||||
expect(result.body.error.code).to.be.equal(ErrorCodes.PATH_ERROR);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('/GET /api/gallery/content/video.mp4/bestFit', async () => {
|
||||
|
||||
Reference in New Issue
Block a user