Testing #307
5 changed files with 35 additions and 23 deletions
|
@ -29,6 +29,7 @@ module.exports = {
|
|||
};
|
||||
},
|
||||
parsePublishApiRequestFiles ({file}) {
|
||||
logger.debug('file', file);
|
||||
// make sure a file was provided
|
||||
if (!file) {
|
||||
throw new Error('no file with key of [file] found in request');
|
||||
|
|
|
@ -126,6 +126,7 @@ module.exports = (app) => {
|
|||
// route to run a publish request on the daemon
|
||||
app.post('/api/claim-publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => {
|
||||
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;
|
||||
// validate the body and files of the request
|
||||
try {
|
||||
|
@ -134,7 +135,7 @@ module.exports = (app) => {
|
|||
({fileName, filePath, fileType} = parsePublishApiRequestFiles(files));
|
||||
({channelName, channelPassword} = parsePublishApiChannel(body, user));
|
||||
} 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});
|
||||
}
|
||||
// check channel authorization
|
||||
|
|
|
@ -2,12 +2,14 @@ const chai = require('chai');
|
|||
const expect = chai.expect;
|
||||
const chaiHttp = require('chai-http');
|
||||
const { host } = require('../../config/speechConfig.js').site;
|
||||
const timeout = 600000;
|
||||
const requestTimeout = 20000;
|
||||
const publishTimeout = 120000;
|
||||
const fs = require('fs');
|
||||
|
||||
chai.use(chaiHttp);
|
||||
|
||||
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)
|
||||
.get(url)
|
||||
.end(function (err, res) {
|
||||
|
@ -15,11 +17,11 @@ function testFor200StatusResponse (host, url) {
|
|||
expect(res).to.have.status(200);
|
||||
done();
|
||||
});
|
||||
}).timeout(timeout);
|
||||
}).timeout(requestTimeout);
|
||||
}
|
||||
|
||||
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)
|
||||
.get(url)
|
||||
.set('accept', 'text/html')
|
||||
|
@ -28,7 +30,7 @@ function testShowRequestFor200StatusResponse (host, url) {
|
|||
expect(res).to.have.status(200);
|
||||
done();
|
||||
});
|
||||
}).timeout(timeout);
|
||||
}).timeout(requestTimeout);
|
||||
}
|
||||
|
||||
describe('end-to-end', function () {
|
||||
|
@ -79,4 +81,29 @@ describe('end-to-end', function () {
|
|||
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
BIN
test/mock-files/bird.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 KiB |
|
@ -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>
|
Loading…
Reference in a new issue