chore: update node support and versions
This commit is contained in:
parent
eb11b4d660
commit
1854769986
|
@ -1,5 +1,5 @@
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "4"
|
|
||||||
- "6"
|
- "6"
|
||||||
- "8"
|
- "8"
|
||||||
|
- "10"
|
||||||
|
|
28
package.json
28
package.json
|
@ -2,7 +2,7 @@
|
||||||
"name": "loopback-component-storage",
|
"name": "loopback-component-storage",
|
||||||
"description": "Loopback Storage Service",
|
"description": "Loopback Storage Service",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=6"
|
||||||
},
|
},
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
@ -12,22 +12,22 @@
|
||||||
"posttest": "npm run lint"
|
"posttest": "npm run lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^2.1.5",
|
"async": "^2.6.1",
|
||||||
"debug": "^3.1.0",
|
"debug": "^3.1.0",
|
||||||
"formidable": "^1.0.16",
|
"formidable": "^1.2.1",
|
||||||
"pkgcloud": "^1.1.0",
|
"pkgcloud": "^1.5.0",
|
||||||
"strong-globalize": "^2.6.2",
|
"strong-globalize": "^4.1.1",
|
||||||
"uuid": "^3.0.1"
|
"uuid": "^3.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^3.17.1",
|
"eslint": "^4.19.1",
|
||||||
"eslint-config-loopback": "^8.0.0",
|
"eslint-config-loopback": "^10.0.0",
|
||||||
"express": "^4.11.0",
|
"express": "^4.16.3",
|
||||||
"loopback": "^3.0.0",
|
"loopback": "^3.20.0",
|
||||||
"mkdirp": "^0.5.0",
|
"mkdirp": "^0.5.1",
|
||||||
"mocha": "^3.2.0",
|
"mocha": "^5.2.0",
|
||||||
"supertest": "^3.0.0",
|
"supertest": "^3.1.0",
|
||||||
"semver": "^5.3.0"
|
"semver": "^5.5.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -24,13 +24,17 @@ describe('FileSystem based storage provider', function() {
|
||||||
describe('container apis', function() {
|
describe('container apis', function() {
|
||||||
var client = null;
|
var client = null;
|
||||||
it('should require an existing directory as the root', function(done) {
|
it('should require an existing directory as the root', function(done) {
|
||||||
client = new FileSystemProvider({root: path.join(__dirname, 'storage')});
|
client = new FileSystemProvider({
|
||||||
|
root: path.join(__dirname, 'storage'),
|
||||||
|
});
|
||||||
process.nextTick(done);
|
process.nextTick(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should complain if the root directory doesn\'t exist', function(done) {
|
it('should complain if the root directory doesn\'t exist', function(done) {
|
||||||
try {
|
try {
|
||||||
client = new FileSystemProvider({root: path.join(__dirname, '_storage')});
|
client = new FileSystemProvider({
|
||||||
|
root: path.join(__dirname, '_storage'),
|
||||||
|
});
|
||||||
process.nextTick(done.bind(null, 'Error'));
|
process.nextTick(done.bind(null, 'Error'));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Should be here
|
// Should be here
|
||||||
|
@ -94,7 +98,9 @@ describe('FileSystem based storage provider', function() {
|
||||||
|
|
||||||
describe('file apis', function() {
|
describe('file apis', function() {
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var client = new FileSystemProvider({root: path.join(__dirname, 'storage')});
|
var client = new FileSystemProvider({
|
||||||
|
root: path.join(__dirname, 'storage'),
|
||||||
|
});
|
||||||
|
|
||||||
it('should create a new container', function(done) {
|
it('should create a new container', function(done) {
|
||||||
client.createContainer({name: 'c1'}, function(err, container) {
|
client.createContainer({name: 'c1'}, function(err, container) {
|
||||||
|
@ -110,6 +116,7 @@ describe('FileSystem based storage provider', function() {
|
||||||
writer.on('error', done);
|
writer.on('error', done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* eslint-disable mocha/handle-done-callback */
|
||||||
it('should fail to upload a file with invalid characters', function(done) {
|
it('should fail to upload a file with invalid characters', function(done) {
|
||||||
var writer = client.upload({container: 'c1', remote: 'a/f1.txt'});
|
var writer = client.upload({container: 'c1', remote: 'a/f1.txt'});
|
||||||
fs.createReadStream(path.join(__dirname, 'files/f1.txt')).pipe(writer);
|
fs.createReadStream(path.join(__dirname, 'files/f1.txt')).pipe(writer);
|
||||||
|
@ -124,20 +131,26 @@ describe('FileSystem based storage provider', function() {
|
||||||
cb = clearCb;
|
cb = clearCb;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
/* eslint-enable mocha/handle-done-callback */
|
||||||
|
|
||||||
it('should download a file', function(done) {
|
it('should download a file', function(done) {
|
||||||
var reader = client.download({
|
var reader = client.download({
|
||||||
container: 'c1',
|
container: 'c1',
|
||||||
remote: 'f1.txt',
|
remote: 'f1.txt',
|
||||||
});
|
});
|
||||||
reader.pipe(fs.createWriteStream(path.join(__dirname, 'files/f1_downloaded.txt')));
|
reader.pipe(
|
||||||
|
fs.createWriteStream(path.join(__dirname, 'files/f1_downloaded.txt'))
|
||||||
|
);
|
||||||
reader.on('end', done);
|
reader.on('end', done);
|
||||||
reader.on('error', done);
|
reader.on('error', done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* eslint-disable mocha/handle-done-callback */
|
||||||
it('should fail to download a file with invalid characters', function(done) {
|
it('should fail to download a file with invalid characters', function(done) {
|
||||||
var reader = client.download({container: 'c1', remote: 'a/f1.txt'});
|
var reader = client.download({container: 'c1', remote: 'a/f1.txt'});
|
||||||
reader.pipe(fs.createWriteStream(path.join(__dirname, 'files/a-f1_downloaded.txt')));
|
reader.pipe(
|
||||||
|
fs.createWriteStream(path.join(__dirname, 'files/a-f1_downloaded.txt'))
|
||||||
|
);
|
||||||
var cb = done;
|
var cb = done;
|
||||||
var clearCb = function() {};
|
var clearCb = function() {};
|
||||||
reader.on('error', function() {
|
reader.on('error', function() {
|
||||||
|
@ -149,6 +162,7 @@ describe('FileSystem based storage provider', function() {
|
||||||
cb = clearCb;
|
cb = clearCb;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
/* eslint-enable mocha/handle-done-callback */
|
||||||
|
|
||||||
it('should get files for a container', function(done) {
|
it('should get files for a container', function(done) {
|
||||||
client.getFiles('c1', function(err, files) {
|
client.getFiles('c1', function(err, files) {
|
||||||
|
|
|
@ -199,14 +199,27 @@ describe('storage service', function() {
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, function(err, res) {
|
.expect(200, function(err, res) {
|
||||||
assert.deepEqual(res.body, {'result': {'files': {'image': [
|
assert.deepEqual(res.body, {
|
||||||
{'container': 'album1', 'name': 'test.jpg', 'type': 'image/jpeg', 'field': 'image', 'size': 60475},
|
result: {
|
||||||
]}, 'fields': {}}});
|
files: {
|
||||||
|
image: [
|
||||||
|
{
|
||||||
|
container: 'album1',
|
||||||
|
name: 'test.jpg',
|
||||||
|
type: 'image/jpeg',
|
||||||
|
field: 'image',
|
||||||
|
size: 60475,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
fields: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails to upload using dotdot file path', function(done) {
|
it('fails to upload using dotdot file path (1)', function(done) {
|
||||||
request('http://localhost:' + app.get('port'))
|
request('http://localhost:' + app.get('port'))
|
||||||
.post('/containers/%2e%2e/upload')
|
.post('/containers/%2e%2e/upload')
|
||||||
.expect(200, function(err, res) {
|
.expect(200, function(err, res) {
|
||||||
|
@ -215,7 +228,7 @@ describe('storage service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails to upload using dotdot file path', function(done) {
|
it('fails to upload using dotdot file path (2)', function(done) {
|
||||||
request('http://localhost:' + app.get('port'))
|
request('http://localhost:' + app.get('port'))
|
||||||
.post('%2e%2e/containers/upload')
|
.post('%2e%2e/containers/upload')
|
||||||
.expect(200, function(err, res) {
|
.expect(200, function(err, res) {
|
||||||
|
@ -224,7 +237,7 @@ describe('storage service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails to upload using dotdot file path', function(done) {
|
it('fails to upload using dotdot file path (3)', function(done) {
|
||||||
request('http://localhost:' + app.get('port'))
|
request('http://localhost:' + app.get('port'))
|
||||||
.post('%2e%2e')
|
.post('%2e%2e')
|
||||||
.expect(200, function(err, res) {
|
.expect(200, function(err, res) {
|
||||||
|
@ -233,7 +246,7 @@ describe('storage service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fails to upload using dotdot file path', function(done) {
|
it('fails to upload using dotdot file path (4)', function(done) {
|
||||||
request('http://localhost:' + app.get('port'))
|
request('http://localhost:' + app.get('port'))
|
||||||
.post('/containers/upload/%2e%2e')
|
.post('/containers/upload/%2e%2e')
|
||||||
.expect(200, function(err, res) {
|
.expect(200, function(err, res) {
|
||||||
|
@ -249,9 +262,24 @@ describe('storage service', function() {
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, function(err, res) {
|
.expect(200, function(err, res) {
|
||||||
assert.deepEqual(res.body, {'result': {'files': {'image': [
|
assert.deepEqual(res.body, {
|
||||||
{'container': 'album1', 'name': 'image-test.jpg', 'originalFilename': 'test.jpg', 'type': 'image/jpeg', 'field': 'image', 'acl': 'public-read', 'size': 60475},
|
result: {
|
||||||
]}, 'fields': {}}});
|
files: {
|
||||||
|
image: [
|
||||||
|
{
|
||||||
|
container: 'album1',
|
||||||
|
name: 'image-test.jpg',
|
||||||
|
originalFilename: 'test.jpg',
|
||||||
|
type: 'image/jpeg',
|
||||||
|
field: 'image',
|
||||||
|
acl: 'public-read',
|
||||||
|
size: 60475,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
fields: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -291,10 +319,14 @@ describe('storage service', function() {
|
||||||
.set('Connection', 'keep-alive')
|
.set('Connection', 'keep-alive')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(400, function(err, res) {
|
.expect(400, function(err, res) {
|
||||||
var indexOfMsg =
|
var indexOfMsg = res.body.error.message
|
||||||
res.body.error.message.toLowerCase().indexOf('no file');
|
.toLowerCase()
|
||||||
assert.notEqual(indexOfMsg, -1,
|
.indexOf('no file');
|
||||||
'Error message does not contain \"no file\"');
|
assert.notEqual(
|
||||||
|
indexOfMsg,
|
||||||
|
-1,
|
||||||
|
'Error message does not contain "no file"'
|
||||||
|
);
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -304,8 +336,10 @@ describe('storage service', function() {
|
||||||
.set('Connection', 'keep-alive')
|
.set('Connection', 'keep-alive')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(500, function(err, res) {
|
.expect(500, function(err, res) {
|
||||||
assert.equal(res.body.error.message,
|
assert.equal(
|
||||||
'bad content-type header, no content-type');
|
res.body.error.message,
|
||||||
|
'bad content-type header, no content-type'
|
||||||
|
);
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -421,22 +455,37 @@ describe('storage service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should upload a file with custom route accessing directly to the ' +
|
it(
|
||||||
'storage connector with renamer', function(done) {
|
'should upload a file with custom route accessing directly to the ' +
|
||||||
request('http://localhost:' + app.get('port'))
|
'storage connector with renamer',
|
||||||
.post('/custom/upload')
|
function(done) {
|
||||||
.attach('customimagefield', path.join(__dirname, './fixtures/test.jpg'))
|
request('http://localhost:' + app.get('port'))
|
||||||
.set('Accept', 'application/json')
|
.post('/custom/upload')
|
||||||
.expect('Content-Type', /json/)
|
.attach('customimagefield', path.join(__dirname, './fixtures/test.jpg'))
|
||||||
.expect(200, function(err, res) {
|
.set('Accept', 'application/json')
|
||||||
assert.deepEqual(res.body, {'result': {'files': {'customimagefield': [
|
.expect('Content-Type', /json/)
|
||||||
{'container': 'album1', 'name': 'customimagefield_test.jpg',
|
.expect(200, function(err, res) {
|
||||||
'originalFilename': 'test.jpg', 'type': 'image/jpeg',
|
assert.deepEqual(res.body, {
|
||||||
'field': 'customimagefield', 'size': 60475},
|
result: {
|
||||||
]}, 'fields': {}}});
|
files: {
|
||||||
done();
|
customimagefield: [
|
||||||
});
|
{
|
||||||
});
|
container: 'album1',
|
||||||
|
name: 'customimagefield_test.jpg',
|
||||||
|
originalFilename: 'test.jpg',
|
||||||
|
type: 'image/jpeg',
|
||||||
|
field: 'customimagefield',
|
||||||
|
size: 60475,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
fields: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
it('should upload a file with container param', function(done) {
|
it('should upload a file with container param', function(done) {
|
||||||
request('http://localhost:' + app.get('port'))
|
request('http://localhost:' + app.get('port'))
|
||||||
|
@ -445,11 +494,23 @@ describe('storage service', function() {
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200, function(err, res) {
|
.expect(200, function(err, res) {
|
||||||
assert.deepEqual(res.body, {'result': {'files': {'customimagefield1': [
|
assert.deepEqual(res.body, {
|
||||||
{'container': 'album1', 'name': 'customimagefield1_test.jpg',
|
result: {
|
||||||
'originalFilename': 'test.jpg', 'type': 'image/jpeg',
|
files: {
|
||||||
'field': 'customimagefield1', 'size': 60475},
|
customimagefield1: [
|
||||||
]}, 'fields': {}}});
|
{
|
||||||
|
container: 'album1',
|
||||||
|
name: 'customimagefield1_test.jpg',
|
||||||
|
originalFilename: 'test.jpg',
|
||||||
|
type: 'image/jpeg',
|
||||||
|
field: 'customimagefield1',
|
||||||
|
size: 60475,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
fields: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue