Skip to content

Commit ef9ef9a

Browse files
Refactor config defaults. (webid: true by default)
1 parent 308061a commit ef9ef9a

16 files changed

Lines changed: 39 additions & 23 deletions

config/defaults.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict'
22

33
module.exports = {
4-
'AUTH_METHOD': 'tls',
5-
'DEFAULT_PORT': 8443,
6-
'DEFAULT_URI': 'https://localhost:8443' // default serverUri
4+
'auth': 'tls',
5+
'dbPath': './.db',
6+
'port': 8443,
7+
'serverUri': 'https://localhost:8443',
8+
'webid': true
79
}

lib/create-app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ const corsSettings = cors({
3535
})
3636

3737
function createApp (argv = {}) {
38+
argv = Object.assign({}, defaults, argv)
39+
3840
argv.host = SolidHost.from({ port: argv.port, serverUri: argv.serverUri })
39-
argv.auth = argv.auth || defaults.AUTH_METHOD
41+
4042
argv.templates = initTemplates()
4143

4244
let ldp = new LDP(argv)

lib/models/account-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AccountManager {
4141
}
4242
this.host = options.host
4343
this.emailService = options.emailService
44-
this.authMethod = options.authMethod || defaults.AUTH_METHOD
44+
this.authMethod = options.authMethod || defaults.auth
4545
this.multiUser = options.multiUser || false
4646
this.store = options.store
4747
this.pathCard = options.pathCard || 'profile/card'

lib/models/solid-host.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class SolidHost {
1818
* server is listening on, e.g. `https://databox.me`
1919
*/
2020
constructor (options = {}) {
21-
this.port = options.port || defaults.DEFAULT_PORT
22-
this.serverUri = options.serverUri || defaults.DEFAULT_URI
21+
this.port = options.port || defaults.port
22+
this.serverUri = options.serverUri || defaults.serverUri
2323

2424
this.parsedUri = url.parse(this.serverUri)
2525
this.host = this.parsedUri.host

test/integration/account-creation-oidc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const $rdf = require('rdflib')
55
const { rm, read } = require('../test-utils')
66
const ldnode = require('../../index')
77
const path = require('path')
8+
const fs = require('fs-extra')
89

910
describe('AccountManager (OIDC account creation tests)', function () {
1011
this.timeout(10000)
@@ -13,6 +14,8 @@ describe('AccountManager (OIDC account creation tests)', function () {
1314
var serverUri = 'https://localhost:3457'
1415
var host = 'localhost:3457'
1516
var ldpHttpsServer
17+
let dbPath = path.join(__dirname, '../resources/.db')
18+
1619
var ldp = ldnode.createServer({
1720
root: path.join(__dirname, '../resources/accounts/'),
1821
sslKey: path.join(__dirname, '../keys/key.pem'),
@@ -21,7 +24,7 @@ describe('AccountManager (OIDC account creation tests)', function () {
2124
webid: true,
2225
idp: true,
2326
strictOrigin: true,
24-
dbPath: path.join(__dirname, '../resources/db/oidc'),
27+
dbPath,
2528
serverUri
2629
})
2730

@@ -31,6 +34,7 @@ describe('AccountManager (OIDC account creation tests)', function () {
3134

3235
after(function () {
3336
if (ldpHttpsServer) ldpHttpsServer.close()
37+
fs.removeSync(dbPath)
3438
})
3539

3640
var server = supertest(serverUri)

test/integration/authentication-oidc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ describe('Authentication API (OIDC)', () => {
6767
after(() => {
6868
if (aliceServer) aliceServer.close()
6969
if (bobServer) bobServer.close()
70-
fs.removeSync(aliceDbPath)
71-
fs.removeSync(bobDbPath)
70+
// fs.removeSync(aliceDbPath)
71+
// fs.removeSync(bobDbPath)
7272
})
7373

7474
describe('Provider Discovery (POST /api/auth/discover)', () => {

test/integration/errors.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ describe('Error pages', function () {
1313
// LDP with error pages
1414
var errorLdp = ldnode({
1515
root: path.join(__dirname, '../resources'),
16-
errorPages: path.join(__dirname, '../resources/errorPages')
16+
errorPages: path.join(__dirname, '../resources/errorPages'),
17+
webid: false
1718
})
1819
var errorServer = supertest(errorLdp)
1920

2021
// LDP with no error pages
2122
var noErrorLdp = ldnode({
2223
root: path.join(__dirname, '../resources'),
23-
noErrorPages: true
24+
noErrorPages: true,
25+
webid: false
2426
})
2527
var noErrorServer = supertest(noErrorLdp)
2628

test/integration/formats.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ var path = require('path')
44

55
describe('formats', function () {
66
var ldp = ldnode.createServer({
7-
root: path.join(__dirname, '../resources')
7+
root: path.join(__dirname, '../resources'),
8+
webid: false
89
})
910

1011
var server = supertest(ldp)

test/integration/http.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ var ldpServer = ldnode.createServer({
1111
live: true,
1212
dataBrowserPath: 'default',
1313
root: path.join(__dirname, '../resources'),
14-
auth: 'oidc'
14+
auth: 'oidc',
15+
webid: false
1516
})
1617
var server = supertest(ldpServer)
1718
var assert = require('chai').assert

test/integration/ldp.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ var fs = require('fs')
1414

1515
describe('LDP', function () {
1616
var ldp = new LDP({
17-
root: path.join(__dirname, '..')
17+
root: path.join(__dirname, '..'),
18+
webid: false
1819
})
1920

2021
describe('readFile', function () {

0 commit comments

Comments
 (0)