Skip to content

Commit

Permalink
Try again
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudswept committed May 24, 2019
1 parent ade5686 commit 0c0a0c5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
43 changes: 27 additions & 16 deletions test/integration/ldp-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,34 @@ var fs = require('fs')

describe('LDP', function () {
var root = path.join(__dirname, '..')
var rootNoQuota = path.join(__dirname, '../no-quota')

var resourceMapper = new ResourceMapper({
rootUrl: 'https://localhost:8443/',
rootPath: root,
includeHost: false
})

var resourceMapperNoQuota = new ResourceMapper({
rootUrl: 'https://localhost:8443/',
rootPath: rootNoQuota,
includeHost: false
})

var ldp = new LDP({
resourceMapper,
serverUri: 'https://localhost',
multiuser: true,
webid: false
})

var ldpNoQuota = new LDP({
resourceMapper: resourceMapperNoQuota,
serverUri: 'https://localhost',
multiuser: true,
webid: false
})

describe('readResource', function () {
it('return 404 if file does not exist', () => {
return ldp.readResource('/resources/unexistent.ttl').catch(err => {
Expand Down Expand Up @@ -139,18 +153,15 @@ describe('LDP', function () {

it.skip('with a larger file to exceed allowed quota', function () {
var randstream = stringToStream(randomBytes(2100))
return ldp.put('/resources/testQuota.txt', randstream).catch((err) => {
return ldp.put('localhost', '/resources/testQuota.txt', randstream).catch((err) => {
assert.notOk(err)
})
})
it('should fail if a over quota', async function () {
var hellostream = stringToStream(randomBytes(999999))
await ldp.put('/resources/testOverQuota.txt', hellostream, 'text/plain')
const withError = await ldp.put('/resources/testOverQuota.txt', hellostream, 'text/plain')
.then(() => false)
.catch((error) => error.status === 413)
await ldp.delete('/resources/testOverQuota.txt')
assert(withError, 'No error for put')
it('should fail if a over quota', function () {
var hellostream = stringToStream('hello world')
return ldp.put('localhost', '/resources/testOverQuota.txt', hellostream).catch((err) => {
assert.equal(err.status, 413)
})
})

it('should fail if a trailing `/` is passed without content type', () => {
Expand All @@ -177,36 +188,36 @@ describe('LDP', function () {
const streamAcl = stringToStream('')
const stream = stringToStream('hello world')

await ldp.put('/resources/testDeleteACL.txt.acl', streamAcl, 'text/turtle')
await ldp.put('/resources/testDeleteACL.txt', stream, 'text/plain')
await ldpNoQuota.put('/resources/testDeleteACL.txt.acl', streamAcl, 'text/turtle')
await ldpNoQuota.put('/resources/testDeleteACL.txt', stream, 'text/plain')

await Promise.all([
new Promise(
(resolve, reject) => fs.stat(
ldp.resourceMapper._rootPath + '/resources/testDeleteACL.txt.acl',
ldpNoQuota.resourceMapper._rootPath + '/resources/testDeleteACL.txt.acl',
(error) => error ? reject(error) : resolve()
)
),
new Promise(
(resolve, reject) => fs.stat(
ldp.resourceMapper._rootPath + '/resources/testDeleteACL.txt',
ldpNoQuota.resourceMapper._rootPath + '/resources/testDeleteACL.txt',
(error) => error ? reject(error) : resolve()
)
)
])

await ldp.delete('/resources/testDeleteACL.txt')
await ldpNoQuota.delete('/resources/testDeleteACL.txt')

await Promise.all([
new Promise(
(resolve, reject) => fs.stat(
ldp.resourceMapper._rootPath + '/resources/testDeleteACL.txt.acl',
ldpNoQuota.resourceMapper._rootPath + '/resources/testDeleteACL.txt.acl',
(error) => error ? resolve() : reject('Still exists')
)
),
new Promise(
(resolve, reject) => fs.stat(
ldp.resourceMapper._rootPath + '/resources/testDeleteACL.txt',
ldpNoQuota.resourceMapper._rootPath + '/resources/testDeleteACL.txt',
(error) => error ? resolve() : reject('Still exists')
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"client_id":"24dc4f2ccf3ffce7392d33e6761f5a71","redirect_uris":["https://app.example.com/callback"],"response_types":["id_token token"],"grant_types":["implicit"],"application_type":"web","id_token_signed_response_alg":"RS256","token_endpoint_auth_method":"client_secret_basic","frontchannel_logout_session_required":false}
2 changes: 1 addition & 1 deletion test/settings/serverSide.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
dct:description "Administrative settings for the server that are only readable to the user." .

</>
solid:storageQuota "999999" .
solid:storageQuota "1230" .


0 comments on commit 0c0a0c5

Please sign in to comment.