Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/create-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function createApp (argv) {
if (ldp.createAdmin) {
app.get('/', function (req, res) {
res.set('Content-Type', 'text/html')
var signup = path.resolve(__dirname + '/../static/signup.html')
var signup = path.resolve(__dirname, '/../static/signup.html')
res.sendFile(signup)
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"mocha": "^2.2.5",
"nock": "^7.0.2",
"rsvp": "^3.1.0",
"standard": "^5.4.1",
"standard": "^6.0.4",
"supertest": "^1.0.1"
},
"main": "index.js",
Expand Down
33 changes: 17 additions & 16 deletions test/acl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var assert = require('chai').assert
var fs = require('fs')
var $rdf = require('rdflib')
var request = require('request')
var path = require('path')

// Helper functions for the FS
var rm = require('./test-utils').rm
Expand All @@ -21,9 +22,9 @@ describe('ACL HTTP', function () {
var ldpHttpsServer
var ldp = ldnode.createServer({
mount: '/test',
root: __dirname + '/resources',
key: __dirname + '/keys/key.pem',
cert: __dirname + '/keys/cert.pem',
root: path.join(__dirname, '/resources'),
key: path.join(__dirname, '/keys/key.pem'),
cert: path.join(__dirname, '/keys/cert.pem'),
webid: true
})

Expand Down Expand Up @@ -56,12 +57,12 @@ describe('ACL HTTP', function () {
var user2 = 'https://user2.databox.me/profile/card#me'
var userCredentials = {
user1: {
cert: fs.readFileSync(__dirname + '/keys/user1-cert.pem'),
key: fs.readFileSync(__dirname + '/keys/user1-key.pem')
cert: fs.readFileSync(path.join(__dirname, '/keys/user1-cert.pem')),
key: fs.readFileSync(path.join(__dirname, '/keys/user1-key.pem'))
},
user2: {
cert: fs.readFileSync(__dirname + '/keys/user2-cert.pem'),
key: fs.readFileSync(__dirname + '/keys/user2-key.pem')
cert: fs.readFileSync(path.join(__dirname, '/keys/user2-cert.pem')),
key: fs.readFileSync(path.join(__dirname, '/keys/user2-key.pem'))
}
}

Expand Down Expand Up @@ -444,7 +445,7 @@ describe('ACL HTTP', function () {
})

describe('Read-only', function () {
var body = fs.readFileSync(__dirname + '/resources/acl/read-acl/.acl')
var body = fs.readFileSync(path.join(__dirname, '/resources/acl/read-acl/.acl'))
it('user1 should be able to access ACL file', function (done) {
var options = createOptions('/acl/read-acl/.acl', 'user1')
request.head(options, function (error, response, body) {
Expand Down Expand Up @@ -1019,14 +1020,14 @@ describe('ACL HTTP', function () {
it('should remove all files and dirs created', function (done) {
try {
// must remove the ACLs in sync
fs.unlinkSync(__dirname + '/resources/' + testDir + '/dir1/dir2/abcd.ttl')
fs.rmdirSync(__dirname + '/resources/' + testDir + '/dir1/dir2/')
fs.rmdirSync(__dirname + '/resources/' + testDir + '/dir1/')
fs.unlinkSync(__dirname + '/resources/' + abcFile)
fs.unlinkSync(__dirname + '/resources/' + testDirAclFile)
fs.unlinkSync(__dirname + '/resources/' + testDirMetaFile)
fs.rmdirSync(__dirname + '/resources/' + testDir)
fs.rmdirSync(__dirname + '/resources/acl/')
fs.unlinkSync(path.join(__dirname, '/resources/' + testDir + '/dir1/dir2/abcd.ttl'))
fs.rmdirSync(path.join(__dirname, '/resources/' + testDir + '/dir1/dir2/'))
fs.rmdirSync(path.join(__dirname, '/resources/' + testDir + '/dir1/'))
fs.unlinkSync(path.join(__dirname, '/resources/' + abcFile))
fs.unlinkSync(path.join(__dirname, '/resources/' + testDirAclFile))
fs.unlinkSync(path.join(__dirname, '/resources/' + testDirMetaFile))
fs.rmdirSync(path.join(__dirname, '/resources/' + testDir))
fs.rmdirSync(path.join(__dirname, '/resources/acl/'))
done()
} catch (e) {
done(e)
Expand Down
7 changes: 4 additions & 3 deletions test/errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var supertest = require('supertest')
var path = require('path')

// Helper functions for the FS
// var rm = require('./test-utils').rm
Expand All @@ -11,14 +12,14 @@ var ldnode = require('../index')
describe('Error pages', function () {
// LDP with error pages
var errorLdp = ldnode({
root: __dirname + '/resources',
errorPages: __dirname + '/resources/errorPages'
root: path.join(__dirname, '/resources'),
errorPages: path.join(__dirname, '/resources/errorPages')
})
var errorServer = supertest(errorLdp)

// LDP with no error pages
var noErrorLdp = ldnode({
root: __dirname + '/resources',
root: path.join(__dirname, '/resources'),
noErrorPages: true
})
var noErrorServer = supertest(noErrorLdp)
Expand Down
3 changes: 2 additions & 1 deletion test/formats.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var supertest = require('supertest')
var ldnode = require('../index')
var path = require('path')

describe('formats', function () {
var ldp = ldnode.createServer({
root: __dirname + '/resources'
root: path.join(__dirname, '/resources')
})

var server = supertest(ldp)
Expand Down
39 changes: 20 additions & 19 deletions test/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ var li = require('li')
var ldnode = require('../index')
var rm = require('./test-utils').rm
var RSVP = require('rsvp')
var path = require('path')

var suffixAcl = '.acl'
var suffixMeta = '.meta'
var ldpServer = ldnode({
root: __dirname + '/resources'
root: path.join(__dirname, '/resources')
})
var server = supertest(ldpServer)

Expand Down Expand Up @@ -158,8 +159,8 @@ describe('HTTP APIs', function () {
return done(err)
}

var size = fs.statSync(__dirname +
'/resources/sampleContainer/solid.png').size
var size = fs.statSync(path.join(__dirname,
'/resources/sampleContainer/solid.png')).size
if (res.body.length !== size) {
return done(new Error('files are not of the same size'))
}
Expand Down Expand Up @@ -313,8 +314,8 @@ describe('HTTP APIs', function () {
})

describe('PUT API', function () {
var putRequestBody = fs.readFileSync(__dirname +
'/resources/sampleContainer/put1.ttl', {
var putRequestBody = fs.readFileSync(path.join(__dirname,
'/resources/sampleContainer/put1.ttl'), {
'encoding': 'utf8'
})
it('should create new resource', function (done) {
Expand Down Expand Up @@ -398,12 +399,12 @@ describe('HTTP APIs', function () {
])
})

var postRequest1Body = fs.readFileSync(__dirname +
'/resources/sampleContainer/put1.ttl', {
var postRequest1Body = fs.readFileSync(path.join(__dirname,
'/resources/sampleContainer/put1.ttl'), {
'encoding': 'utf8'
})
var postRequest2Body = fs.readFileSync(__dirname +
'/resources/sampleContainer/post2.ttl', {
var postRequest2Body = fs.readFileSync(path.join(__dirname,
'/resources/sampleContainer/post2.ttl'), {
'encoding': 'utf8'
})
it('should create new resource', function (done) {
Expand Down Expand Up @@ -473,7 +474,7 @@ describe('HTTP APIs', function () {
.expect(201)
.end(function (err) {
if (err) return done(err)
var stats = fs.statSync(__dirname + '/resources/post-tests/loans/')
var stats = fs.statSync(path.join(__dirname, '/resources/post-tests/loans/'))
if (!stats.isDirectory()) {
return done(new Error('Cannot read file just created'))
}
Expand All @@ -498,19 +499,19 @@ describe('HTTP APIs', function () {
it('should create as many files as the ones passed in multipart',
function (done) {
server.post('/sampleContainer/')
.attach('timbl', __dirname + '/resources/timbl.jpg')
.attach('nicola', __dirname + '/resources/nicola.jpg')
.attach('timbl', path.join(__dirname, '/resources/timbl.jpg'))
.attach('nicola', path.join(__dirname, '/resources/nicola.jpg'))
.expect(200)
.end(function (err) {
if (err) return done(err)

var sizeNicola = fs.statSync(__dirname +
'/resources/nicola.jpg').size
var sizeTim = fs.statSync(__dirname + '/resources/timbl.jpg').size
var sizeNicolaLocal = fs.statSync(__dirname +
'/resources/sampleContainer/nicola.jpg').size
var sizeTimLocal = fs.statSync(__dirname +
'/resources/sampleContainer/timbl.jpg').size
var sizeNicola = fs.statSync(path.join(__dirname,
'/resources/nicola.jpg')).size
var sizeTim = fs.statSync(path.join(__dirname, '/resources/timbl.jpg')).size
var sizeNicolaLocal = fs.statSync(path.join(__dirname,
'/resources/sampleContainer/nicola.jpg')).size
var sizeTimLocal = fs.statSync(path.join(__dirname,
'/resources/sampleContainer/timbl.jpg')).size

if (sizeNicola === sizeNicolaLocal && sizeTim === sizeTimLocal) {
return done()
Expand Down
7 changes: 4 additions & 3 deletions test/identity-provider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var supertest = require('supertest')
var path = require('path')
// Helper functions for the FS
var rm = require('./test-utils').rm
// var write = require('./test-utils').write
Expand All @@ -14,9 +15,9 @@ describe('Identity Provider', function () {
var host = 'localhost:3457'
var ldpHttpsServer
var ldp = ldnode.createServer({
root: __dirname + '/resources/accounts/',
key: __dirname + '/keys/key.pem',
cert: __dirname + '/keys/cert.pem',
root: path.join(__dirname, '/resources/accounts/'),
key: path.join(__dirname, '/keys/key.pem'),
cert: path.join(__dirname, '/keys/cert.pem'),
webid: true,
idp: true
})
Expand Down
15 changes: 8 additions & 7 deletions test/ldp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var assert = require('chai').assert
var $rdf = require('rdflib')
var ns = require('../lib/vocab/ns.js').ns
var LDP = require('../lib/ldp')
var path = require('path')
var stringToStream = require('../lib/utils').stringToStream

// Helper functions for the FS
Expand All @@ -27,7 +28,7 @@ describe('LDP', function () {
it('return file if file exists', function (done) {
// file can be empty as well
write('hello world', 'fileExists.txt')
ldp.readFile(__dirname + '/resources/fileExists.txt', function (err, file) {
ldp.readFile(path.join(__dirname, '/resources/fileExists.txt'), function (err, file) {
rm('fileExists.txt')
assert.notOk(err)
assert.equal(file, 'hello world')
Expand All @@ -47,7 +48,7 @@ describe('LDP', function () {
it('should return content if metaFile exists', function (done) {
// file can be empty as well
write('This function just reads this, does not parse it', '.meta')
ldp.readContainerMeta(__dirname + '/resources/', function (err, metaFile) {
ldp.readContainerMeta(path.join(__dirname, '/resources/'), function (err, metaFile) {
rm('.meta')
assert.notOk(err)
assert.equal(metaFile, 'This function just reads this, does not parse it')
Expand All @@ -58,7 +59,7 @@ describe('LDP', function () {
it('should work also if trailing `/` is not passed', function (done) {
// file can be empty as well
write('This function just reads this, does not parse it', '.meta')
ldp.readContainerMeta(__dirname + '/resources', function (err, metaFile) {
ldp.readContainerMeta(path.join(__dirname, '/resources'), function (err, metaFile) {
rm('.meta')
assert.notOk(err)
assert.equal(metaFile, 'This function just reads this, does not parse it')
Expand Down Expand Up @@ -115,7 +116,7 @@ describe('LDP', function () {
' dcterms:title "This is a magic type" ;' +
' o:limit 500000.00 .', 'sampleContainer/magicType.ttl')

ldp.listContainer(__dirname + '/resources/sampleContainer/', 'https://server.tld', '', 'text/turtle', function (err, data) {
ldp.listContainer(path.join(__dirname, '/resources/sampleContainer/'), 'https://server.tld', '', 'text/turtle', function (err, data) {
if (err) done(err)
var graph = $rdf.graph()
$rdf.parse(
Expand Down Expand Up @@ -155,7 +156,7 @@ describe('LDP', function () {
' dcterms:title "This is a container" ;' +
' o:limit 500000.00 .', 'sampleContainer/basicContainerFile.ttl')

ldp.listContainer(__dirname + '/resources/sampleContainer/', 'https://server.tld', '', 'text/turtle', function (err, data) {
ldp.listContainer(path.join(__dirname, '/resources/sampleContainer/'), 'https://server.tld', '', 'text/turtle', function (err, data) {
if (err) done(err)
var graph = $rdf.graph()
$rdf.parse(
Expand Down Expand Up @@ -193,9 +194,9 @@ describe('LDP', function () {
})

it('should ldp:contains the same amount of files in dir', function (done) {
ldp.listContainer(__dirname + '/resources/sampleContainer/', 'https://server.tld', '', 'text/turtle', function (err, data) {
ldp.listContainer(path.join(__dirname, '/resources/sampleContainer/'), 'https://server.tld', '', 'text/turtle', function (err, data) {
if (err) done(err)
fs.readdir(__dirname + '/resources/sampleContainer/', function (err, files) {
fs.readdir(path.join(__dirname, '/resources/sampleContainer/'), function (err, files) {
var graph = $rdf.graph()
$rdf.parse(
data,
Expand Down
9 changes: 5 additions & 4 deletions test/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var assert = require('chai').assert
var supertest = require('supertest')
var nock = require('nock')
var async = require('async')
var path = require('path')
// Helper functions for the FS
var rm = require('./test-utils').rm
var write = require('./test-utils').write
Expand All @@ -13,7 +14,7 @@ var ldnode = require('../index')
describe('LDNODE params', function () {
describe('proxy', function () {
var ldp = ldnode({
root: __dirname + '/resources',
root: path.join(__dirname, '/resources'),
proxy: '/proxy'
})
var server = supertest(ldp)
Expand Down Expand Up @@ -142,9 +143,9 @@ describe('LDNODE params', function () {
var ldpHttpsServer
var ldp = ldnode.createServer({
forceUser: 'https://fakeaccount.com/profile#me',
root: __dirname + '/resources/acl/fake-account',
key: __dirname + '/keys/key.pem',
cert: __dirname + '/keys/cert.pem',
root: path.join(__dirname, '/resources/acl/fake-account'),
key: path.join(__dirname, '/keys/key.pem'),
cert: path.join(__dirname, '/keys/cert.pem'),
webid: true,
host: 'localhost:3457'
})
Expand Down
3 changes: 2 additions & 1 deletion test/patch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var ldnode = require('../')
var supertest = require('supertest')
var assert = require('chai').assert
var path = require('path')

// Helper functions for the FS
var rm = require('./test-utils').rm
Expand All @@ -11,7 +12,7 @@ var read = require('./test-utils').read
describe('PATCH', function () {
// Starting LDP
var ldp = ldnode({
root: __dirname + '/resources/sampleContainer',
root: path.join(__dirname, '/resources/sampleContainer'),
mount: '/test'
})
var server = supertest(ldp)
Expand Down
11 changes: 6 additions & 5 deletions test/test-utils.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
var fs = require('fs')
var fsExtra = require('fs-extra')
var rimraf = require('rimraf')
var path = require('path')

exports.rm = function (file) {
return rimraf.sync(__dirname + '/resources/' + file)
return rimraf.sync(path.join(__dirname, '/resources/' + file))
}

exports.write = function (text, file) {
return fs.writeFileSync(__dirname + '/resources/' + file, text)
return fs.writeFileSync(path.join(__dirname, '/resources/' + file), text)
}

exports.cp = function (src, dest) {
return fsExtra.copySync(
__dirname + '/resources/' + src,
__dirname + '/resources/' + dest)
path.join(__dirname, '/resources/' + src),
path.join(__dirname, '/resources/' + dest))
}

exports.read = function (file) {
return fs.readFileSync(__dirname + '/resources/' + file, {
return fs.readFileSync(path.join(__dirname, '/resources/' + file), {
'encoding': 'utf8'
})
}