Testing #307

Merged
bones7242 merged 16 commits from testing into master 2017-12-19 00:30:32 +01:00
5 changed files with 35 additions and 23 deletions
Showing only changes of commit c52a5f87e4 - Show all commits

View file

@ -29,6 +29,7 @@ module.exports = {
}; };
}, },
parsePublishApiRequestFiles ({file}) { parsePublishApiRequestFiles ({file}) {
logger.debug('file', file);
// make sure a file was provided // make sure a file was provided
if (!file) { if (!file) {
throw new Error('no file with key of [file] found in request'); throw new Error('no file with key of [file] found in request');

View file

@ -126,6 +126,7 @@ module.exports = (app) => {
// route to run a publish request on the daemon // route to run a publish request on the daemon
app.post('/api/claim-publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => { app.post('/api/claim-publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => {
logger.debug('api/claim-publish body:', body); logger.debug('api/claim-publish body:', body);
logger.debug('api/claim-publish files:', files);
let name, fileName, filePath, fileType, nsfw, license, title, description, thumbnail, channelName, channelPassword; let name, fileName, filePath, fileType, nsfw, license, title, description, thumbnail, channelName, channelPassword;
// validate the body and files of the request // validate the body and files of the request
try { try {
@ -134,7 +135,7 @@ module.exports = (app) => {
({fileName, filePath, fileType} = parsePublishApiRequestFiles(files)); ({fileName, filePath, fileType} = parsePublishApiRequestFiles(files));
({channelName, channelPassword} = parsePublishApiChannel(body, user)); ({channelName, channelPassword} = parsePublishApiChannel(body, user));
} catch (error) { } catch (error) {
logger.debug('publish request rejected, insufficient request parameters'); logger.debug('publish request rejected, insufficient request parameters', error);
return res.status(400).json({success: false, message: error.message}); return res.status(400).json({success: false, message: error.message});
} }
// check channel authorization // check channel authorization

View file

@ -2,12 +2,14 @@ const chai = require('chai');
const expect = chai.expect; const expect = chai.expect;
const chaiHttp = require('chai-http'); const chaiHttp = require('chai-http');
const { host } = require('../../config/speechConfig.js').site; const { host } = require('../../config/speechConfig.js').site;
const timeout = 600000; const requestTimeout = 20000;
const publishTimeout = 120000;
const fs = require('fs');
chai.use(chaiHttp); chai.use(chaiHttp);
function testFor200StatusResponse (host, url) { function testFor200StatusResponse (host, url) {
return it(`should receive a status code 200 within ${timeout}ms`, function (done) { return it(`should receive a status code 200 within ${requestTimeout}ms`, function (done) {
chai.request(host) chai.request(host)
.get(url) .get(url)
.end(function (err, res) { .end(function (err, res) {
@ -15,11 +17,11 @@ function testFor200StatusResponse (host, url) {
expect(res).to.have.status(200); expect(res).to.have.status(200);
done(); done();
}); });
}).timeout(timeout); }).timeout(requestTimeout);
} }
function testShowRequestFor200StatusResponse (host, url) { function testShowRequestFor200StatusResponse (host, url) {
return it(`should receive a status code 200 within ${timeout}ms`, function (done) { return it(`should receive a status code 200 within ${requestTimeout}ms`, function (done) {
chai.request(host) chai.request(host)
.get(url) .get(url)
.set('accept', 'text/html') .set('accept', 'text/html')
@ -28,7 +30,7 @@ function testShowRequestFor200StatusResponse (host, url) {
expect(res).to.have.status(200); expect(res).to.have.status(200);
done(); done();
}); });
}).timeout(timeout); }).timeout(requestTimeout);
} }
describe('end-to-end', function () { describe('end-to-end', function () {
@ -79,4 +81,29 @@ describe('end-to-end', function () {
testShowRequestFor200StatusResponse(host, claimUrlWithShortClaimId); testShowRequestFor200StatusResponse(host, claimUrlWithShortClaimId);
}); });
}); });
describe('publish', function () {
const publishUrl = '/api/claim-publish';
const name = 'test-name2';
const filePath = './test/mock-files/bird.jpeg';
const fileName = 'byrd.jpeg';
describe(publishUrl, function () {
it(`should receive a status code 200 within ${publishTimeout}ms`, function (done) {
chai.request(host)
.post(publishUrl)
.type('form')
.attach('file', fs.readFileSync(filePath), fileName)
.field('name', name)
.end(function (err, res) {
// expect(err).to.be.null;
expect(res).to.have.status(200);
done();
});
}).timeout(publishTimeout);
});
});
}); });

BIN
test/mock-files/bird.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

View file

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Page</title>
</head>
<body>
<img src="https://dev1.spee.ch/zackmath"/>
<!--<img src="https://dev1.spee.ch/8/zackmath"/>-->
<!--<img src="https://dev1.spee.ch/zackmath.ext"/>-->
<!--<img src="https://dev1.spee.ch/8/zackmath.ext"/>-->
<video width="50%" controls poster="https://dev1.spee.ch/assets/img/video_thumb_default.png" src="https://dev1.spee.ch/LBRY-Hype"></video>
<!--<video width="50%" controls poster="https://dev1.spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/a/LBRY-Hype"></video>-->
<!--<video width="50%" controls poster="https://dev1.spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/LBRY-Hype.test"></video>-->
<!--<video width="50%" controls poster="https://dev1.spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/a/LBRY-Hype.test"></video>-->
</body>
</html>