From 3ae06847e616b56eda717f03e129db2d0278c13f Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Fri, 1 Sep 2017 13:37:05 -0400 Subject: [PATCH 1/2] Rename the idp option into multiuser. Closes #515. --- README.md | 4 +- bin/lib/options.js | 12 +++-- default-views/auth/reset-password.hbs | 2 +- lib/create-app.js | 4 +- lib/create-server.js | 8 ++- lib/handlers/allow.js | 2 +- lib/handlers/get.js | 4 +- lib/handlers/patch.js | 2 +- lib/header.js | 2 +- lib/ldp.js | 12 ++--- lib/models/account-manager.js | 18 +++---- lib/models/solid-host.js | 2 +- lib/requests/password-reset-email-request.js | 6 +-- lib/server-config.js | 5 +- lib/utils.js | 2 +- .../integration/account-creation-oidc-test.js | 4 +- test/integration/account-creation-tls-test.js | 2 +- test/integration/account-manager-test.js | 22 ++++---- test/integration/acl-oidc-test.js | 2 +- test/integration/authentication-oidc-test.js | 2 +- test/integration/capability-discovery-test.js | 2 +- test/integration/errors-oidc-test.js | 2 +- test/integration/header-test.js | 2 +- test/integration/patch-test.js | 2 +- test/unit/account-manager-test.js | 52 +++++++++---------- test/unit/add-cert-request-test.js | 12 ++--- test/unit/email-welcome-test.js | 2 +- test/unit/password-authenticator-test.js | 8 +-- .../unit/password-reset-email-request-test.js | 18 +++---- test/unit/tls-authenticator-test.js | 2 +- test/unit/user-accounts-api-test.js | 6 +-- 31 files changed, 117 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index 97b5239e7..737354f27 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ $ solid start Otherwise, if you want to use flags, this would be the equivalent ```bash -$ solid --idp --port 8443 --cert /path/to/cert --key /path/to/key --root ./accounts +$ solid --multiuser --port 8443 --cert /path/to/cert --key /path/to/key --root ./accounts ``` Your users will have a dedicated folder under `./accounts`. Also, your root domain's website will be in `./accounts/yourdomain.tld`. New users can create accounts on `/api/accounts/new` and create new certificates on `/api/accounts/cert`. An easy-to-use sign-up tool is found on `/api/accounts`. @@ -157,7 +157,7 @@ $ solid start --help --owner [value] Set the owner of the storage (overwrites the root ACL file) --ssl-key [value] Path to the SSL private key in PEM format --ssl-cert [value] Path to the SSL certificate key in PEM format - --idp Enable multi-user mode (users can sign up for accounts) + --multiuser Enable multi-user mode --corsProxy [value] Serve the CORS proxy on this path --file-browser [value] Url to file browser app (uses Warp by default) --data-browser Enable viewing RDF resources using a default data browser application (e.g. mashlib) diff --git a/bin/lib/options.js b/bin/lib/options.js index 85581a97f..f01cf9bf8 100644 --- a/bin/lib/options.js +++ b/bin/lib/options.js @@ -123,14 +123,18 @@ module.exports = [ prompt: false }, { - name: 'idp', - help: 'Enable multi-user mode (users can sign up for accounts)', - question: 'Enable multi-user mode (users can sign up for accounts)', - full: 'allow-signup', + name: 'multiuser', + help: 'Enable multi-user mode', + question: 'Enable multi-user mode', flag: true, default: false, prompt: true }, + { + name: 'idp', + help: 'Obsolete; use --multiuser', + prompt: false + }, { name: 'no-live', help: 'Disable live support through WebSockets', diff --git a/default-views/auth/reset-password.hbs b/default-views/auth/reset-password.hbs index 8821171ad..97add6cf7 100644 --- a/default-views/auth/reset-password.hbs +++ b/default-views/auth/reset-password.hbs @@ -22,7 +22,7 @@ {{/if}}
- {{#if multiUser}} + {{#if multiuser}}

Please enter your account name. A password reset link will be emailed to the address you provided during account registration.

diff --git a/lib/create-app.js b/lib/create-app.js index f621d840f..bbf006bb6 100644 --- a/lib/create-app.js +++ b/lib/create-app.js @@ -187,7 +187,7 @@ function initWebId (argv, app, ldp) { host: argv.host, accountTemplatePath: argv.templates.account, store: ldp, - multiUser: argv.idp + multiuser: argv.multiuser }) app.locals.accountManager = accountManager @@ -197,7 +197,7 @@ function initWebId (argv, app, ldp) { // Set up authentication-related API endpoints and app.locals initAuthentication(app, argv) - if (argv.idp) { + if (argv.multiuser) { app.use(vhost('*', LdpMiddleware(corsSettings))) } } diff --git a/lib/create-server.js b/lib/create-server.js index 2ec1fc2d5..f4c01f3be 100644 --- a/lib/create-server.js +++ b/lib/create-server.js @@ -22,9 +22,15 @@ function createServer (argv, app) { app.use(mount, ldpApp) debug.settings('Base URL (--mount): ' + mount) + if (argv.idp) { + console.error('The idp configuration option has been renamed to multiuser.') + argv.idp = argv.multiuser + delete argv.idp + } + var server var needsTLS = argv.sslKey || argv.sslCert || - (ldp.webid || ldp.idp) && !argv.certificateHeader + (ldp.webid || ldp.multiuser) && !argv.certificateHeader if (!needsTLS) { server = http.createServer(app) } else { diff --git a/lib/handlers/allow.js b/lib/handlers/allow.js index d5b156379..5a6abff8c 100644 --- a/lib/handlers/allow.js +++ b/lib/handlers/allow.js @@ -82,7 +82,7 @@ function readFile (uri, host, ldp, baseUri) { : uri // Determine the root file system folder to look in // TODO prettify this - var root = !ldp.idp ? ldp.root : ldp.root + host + '/' + var root = !ldp.multiuser ? ldp.root : ldp.root + host + '/' // Derive the file path for the resource var documentPath = utils.uriToFilename(newPath, root) var documentUri = url.parse(documentPath) diff --git a/lib/handlers/get.js b/lib/handlers/get.js index 084bdafc1..1c43d958a 100644 --- a/lib/handlers/get.js +++ b/lib/handlers/get.js @@ -137,7 +137,7 @@ function handler (req, res, next) { function globHandler (req, res, next) { var ldp = req.app.locals.ldp - var root = !ldp.idp ? ldp.root : ldp.root + req.hostname + '/' + var root = !ldp.multiuser ? ldp.root : ldp.root + req.hostname + '/' var filename = utils.uriToFilename(req.path, root) var uri = utils.getFullUri(req) const requestUri = url.resolve(uri, req.path) @@ -199,7 +199,7 @@ function aclAllow (match, req, res, callback) { return callback(true) } - var root = ldp.idp ? ldp.root + req.hostname + '/' : ldp.root + var root = ldp.multiuser ? ldp.root + req.hostname + '/' : ldp.root var relativePath = '/' + _path.relative(root, match) res.locals.path = relativePath allow('Read', req, res, function (err) { diff --git a/lib/handlers/patch.js b/lib/handlers/patch.js index 9e2f67923..a5a320bcb 100644 --- a/lib/handlers/patch.js +++ b/lib/handlers/patch.js @@ -26,7 +26,7 @@ function patchHandler (req, res, next) { // Obtain details of the target resource const ldp = req.app.locals.ldp - const root = !ldp.idp ? ldp.root : `${ldp.root}${req.hostname}/` + const root = !ldp.multiuser ? ldp.root : `${ldp.root}${req.hostname}/` const target = {} target.file = utils.uriToFilename(req.path, root) target.uri = utils.getBaseUri(req) + req.originalUrl diff --git a/lib/header.js b/lib/header.js index 0db7d3e44..c46350bbf 100644 --- a/lib/header.js +++ b/lib/header.js @@ -44,7 +44,7 @@ function addLinks (res, fileMetadata) { function linksHandler (req, res, next) { var ldp = req.app.locals.ldp - var root = !ldp.idp ? ldp.root : ldp.root + req.hostname + '/' + var root = !ldp.multiuser ? ldp.root : ldp.root + req.hostname + '/' var filename = utils.uriToFilename(req.url, root) filename = path.join(filename, req.path) diff --git a/lib/ldp.js b/lib/ldp.js index 5b3522955..368b0997f 100644 --- a/lib/ldp.js +++ b/lib/ldp.js @@ -86,7 +86,7 @@ class LDP { debug.settings('Filesystem Root: ' + this.root) debug.settings('Allow WebID authentication: ' + !!this.webid) debug.settings('Live-updates: ' + !!this.live) - debug.settings('Identity Provider: ' + !!this.idp) + debug.settings('Multi-user: ' + !!this.multiuser) debug.settings('Default file browser app: ' + this.fileBrowser) debug.settings('Suppress default data browser app: ' + this.suppressDataBrowser) debug.settings('Default data browser app file path: ' + this.dataBrowserPath) @@ -142,7 +142,7 @@ class LDP { listContainer (filename, reqUri, uri, containerData, contentType, callback) { var ldp = this // var host = url.parse(uri).hostname - // var root = !ldp.idp ? ldp.root : ldp.root + host + '/' + // var root = !ldp.multiuser ? ldp.root : ldp.root + host + '/' // var baseUri = utils.filenameToBaseUri(filename, uri, root) var resourceGraph = $rdf.graph() @@ -259,7 +259,7 @@ class LDP { put (host, resourcePath, stream, callback) { var ldp = this - var root = !ldp.idp ? ldp.root : ldp.root + host + '/' + var root = !ldp.multiuser ? ldp.root : ldp.root + host + '/' var filePath = utils.uriToFilename(resourcePath, root, host) // PUT requests not supported on containers. Use POST instead @@ -344,7 +344,7 @@ class LDP { baseUri = undefined } - var root = ldp.idp ? ldp.root + host + '/' : ldp.root + var root = ldp.multiuser ? ldp.root + host + '/' : ldp.root var filename = utils.uriToFilename(reqPath, root) ldp.readFile(filename, (err, body) => { @@ -363,7 +363,7 @@ class LDP { var range = options.range } var ldp = this - var root = !ldp.idp ? ldp.root : ldp.root + host + '/' + var root = !ldp.multiuser ? ldp.root : ldp.root + host + '/' var filename = utils.uriToFilename(reqPath, root) ldp.stat(filename, function (err, stats) { @@ -430,7 +430,7 @@ class LDP { delete (host, resourcePath, callback) { var ldp = this - var root = !ldp.idp ? ldp.root : ldp.root + host + '/' + var root = !ldp.multiuser ? ldp.root : ldp.root + host + '/' var filename = utils.uriToFilename(resourcePath, root) ldp.stat(filename, function (err, stats) { if (err) { diff --git a/lib/models/account-manager.js b/lib/models/account-manager.js index d891ee074..6793bdd58 100644 --- a/lib/models/account-manager.js +++ b/lib/models/account-manager.js @@ -27,8 +27,8 @@ class AccountManager { * @param [options.emailService] {EmailService} * @param [options.tokenService] {TokenService} * @param [options.host] {SolidHost} - * @param [options.multiUser=false] {boolean} (argv.idp) Is the server running - * in multiUser mode (users can sign up for accounts) or single user + * @param [options.multiuser=false] {boolean} (argv.multiuser) Is the server running + * in multiuser mode (users can sign up for accounts) or single user * (such as a personal website). * @param [options.store] {LDP} * @param [options.pathCard] {string} @@ -45,7 +45,7 @@ class AccountManager { this.emailService = options.emailService this.tokenService = options.tokenService this.authMethod = options.authMethod || defaults.auth - this.multiUser = options.multiUser || false + this.multiuser = options.multiuser || false this.store = options.store this.pathCard = options.pathCard || 'profile/card' this.suffixURI = options.suffixURI || '#me' @@ -56,7 +56,7 @@ class AccountManager { * Factory method for new account manager creation. Usage: * * ``` - * let options = { host, multiUser, store } + * let options = { host, multiuser, store } * let accontManager = AccountManager.from(options) * ``` * @@ -137,7 +137,7 @@ class AccountManager { accountDirFor (accountName) { let accountDir - if (this.multiUser) { + if (this.multiuser) { let uri = this.accountUriFor(accountName) let hostname = url.parse(uri).hostname accountDir = path.join(this.store.root, hostname) @@ -165,11 +165,11 @@ class AccountManager { * @param [accountName] {string} * * @throws {Error} If `this.host` has not been initialized with serverUri, - * or if in multiUser mode and accountName is not provided. + * or if in multiuser mode and accountName is not provided. * @return {string} */ accountUriFor (accountName) { - let accountUri = this.multiUser + let accountUri = this.multiuser ? this.host.accountUriFor(accountName) : this.host.serverUri // single user mode @@ -335,7 +335,7 @@ class AccountManager { * @param [userData.email] {string} * @param [userData.name] {string} * - * @throws {Error} (via `accountWebIdFor()`) If in multiUser mode and no + * @throws {Error} (via `accountWebIdFor()`) If in multiuser mode and no * username passed * * @return {UserAccount} @@ -378,7 +378,7 @@ class AccountManager { } usernameFromWebId (webId) { - if (!this.multiUser) { + if (!this.multiuser) { return DEFAULT_ADMIN_USERNAME } diff --git a/lib/models/solid-host.js b/lib/models/solid-host.js index 79304fcc6..1a926e97e 100644 --- a/lib/models/solid-host.js +++ b/lib/models/solid-host.js @@ -38,7 +38,7 @@ class SolidHost { } /** - * Composes and returns an account URI for a given username, in multiUser mode. + * Composes and returns an account URI for a given username, in multi-user mode. * Usage: * * ``` diff --git a/lib/requests/password-reset-email-request.js b/lib/requests/password-reset-email-request.js index 4bff4594f..4c0f5e9ec 100644 --- a/lib/requests/password-reset-email-request.js +++ b/lib/requests/password-reset-email-request.js @@ -105,7 +105,7 @@ class PasswordResetEmailRequest extends AuthRequest { * @throws {Error} */ validate () { - if (this.accountManager.multiUser && !this.username) { + if (this.accountManager.multiuser && !this.username) { throw new Error('Username required') } } @@ -168,7 +168,7 @@ class PasswordResetEmailRequest extends AuthRequest { let params = { error: error.message, returnToUrl: this.returnToUrl, - multiUser: this.accountManager.multiUser + multiuser: this.accountManager.multiuser } res.status(error.statusCode || 400) @@ -182,7 +182,7 @@ class PasswordResetEmailRequest extends AuthRequest { renderForm () { let params = { returnToUrl: this.returnToUrl, - multiUser: this.accountManager.multiUser + multiuser: this.accountManager.multiuser } this.response.render('auth/reset-password', params) diff --git a/lib/server-config.js b/lib/server-config.js index 80e0b9387..8894a380e 100644 --- a/lib/server-config.js +++ b/lib/server-config.js @@ -37,12 +37,11 @@ function ensureDirCopyExists (fromDir, toDir) { * @param argv {Function} Express.js app object */ function ensureWelcomePage (argv) { - let multiUser = argv.idp + let { multiuser, templates } = argv let rootDir = path.resolve(argv.root) - let templates = argv.templates let serverRootDir - if (multiUser) { + if (multiuser) { serverRootDir = path.join(rootDir, argv.host.hostname) } else { serverRootDir = rootDir diff --git a/lib/utils.js b/lib/utils.js index ec4b7c19d..07851a507 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -239,6 +239,6 @@ function stripLineEndings (obj) { function reqToPath (req) { var ldp = req.app.locals.ldp - var root = ldp.idp ? ldp.root + req.hostname + '/' : ldp.root + var root = ldp.multiuser ? ldp.root + req.hostname + '/' : ldp.root return uriToFilename(req.path, root) } diff --git a/test/integration/account-creation-oidc-test.js b/test/integration/account-creation-oidc-test.js index 9bfdb7a79..0640677f2 100644 --- a/test/integration/account-creation-oidc-test.js +++ b/test/integration/account-creation-oidc-test.js @@ -20,7 +20,7 @@ describe('AccountManager (OIDC account creation tests)', function () { sslCert: path.join(__dirname, '../keys/cert.pem'), auth: 'oidc', webid: true, - idp: true, + multiuser: true, strictOrigin: true, dbPath, serverUri @@ -212,7 +212,7 @@ describe('Single User signup page', () => { sslKey: path.join(__dirname, '../keys/key.pem'), sslCert: path.join(__dirname, '../keys/cert.pem'), webid: true, - idp: false, + multiuser: false, strictOrigin: true }) const server = supertest(serverUri) diff --git a/test/integration/account-creation-tls-test.js b/test/integration/account-creation-tls-test.js index d345915d9..6ca99ffcc 100644 --- a/test/integration/account-creation-tls-test.js +++ b/test/integration/account-creation-tls-test.js @@ -18,7 +18,7 @@ // sslCert: path.join(__dirname, '../keys/cert.pem'), // auth: 'tls', // webid: true, -// idp: true, +// multiuser: true, // strictOrigin: true // }) // diff --git a/test/integration/account-manager-test.js b/test/integration/account-manager-test.js index 264aa8c27..215e21339 100644 --- a/test/integration/account-manager-test.js +++ b/test/integration/account-manager-test.js @@ -28,9 +28,9 @@ describe('AccountManager', () => { let host = SolidHost.from({ serverUri: 'https://localhost' }) describe('in multi user mode', () => { - let multiUser = true - let store = new LDP({ root: testAccountsDir, idp: multiUser }) - let options = { multiUser, store, host } + let multiuser = true + let store = new LDP({ root: testAccountsDir, multiuser }) + let options = { multiuser, store, host } let accountManager = AccountManager.from(options) it('resolves to true if a directory for the account exists in root', () => { @@ -51,14 +51,14 @@ describe('AccountManager', () => { }) describe('in single user mode', () => { - let multiUser = false + let multiuser = false it('resolves to true if root .acl exists in root storage', () => { let store = new LDP({ root: path.join(testAccountsDir, 'tim.localhost'), - idp: multiUser + multiuser }) - let options = { multiUser, store, host } + let options = { multiuser, store, host } let accountManager = AccountManager.from(options) return accountManager.accountExists() @@ -70,9 +70,9 @@ describe('AccountManager', () => { it('resolves to false if root .acl does not exist in root storage', () => { let store = new LDP({ root: testAccountsDir, - idp: multiUser + multiuser }) - let options = { multiUser, store, host } + let options = { multiuser, store, host } let accountManager = AccountManager.from(options) return accountManager.accountExists() @@ -85,9 +85,9 @@ describe('AccountManager', () => { describe('createAccountFor()', () => { it('should create an account directory', () => { - let multiUser = true - let store = new LDP({ root: testAccountsDir, idp: multiUser }) - let options = { host, multiUser, store, accountTemplatePath } + let multiuser = true + let store = new LDP({ root: testAccountsDir, multiuser }) + let options = { host, multiuser, store, accountTemplatePath } let accountManager = AccountManager.from(options) let userData = { diff --git a/test/integration/acl-oidc-test.js b/test/integration/acl-oidc-test.js index 20d7089ed..7b1df49cf 100644 --- a/test/integration/acl-oidc-test.js +++ b/test/integration/acl-oidc-test.js @@ -51,7 +51,7 @@ const argv = { sslKey: path.join(__dirname, '../keys/key.pem'), sslCert: path.join(__dirname, '../keys/cert.pem'), webid: true, - idp: true, + multiuser: true, auth: 'oidc', strictOrigin: true, host: { serverUri } diff --git a/test/integration/authentication-oidc-test.js b/test/integration/authentication-oidc-test.js index cd7a0a2ec..cd84ffea3 100644 --- a/test/integration/authentication-oidc-test.js +++ b/test/integration/authentication-oidc-test.js @@ -44,7 +44,7 @@ describe('Authentication API (OIDC)', () => { dataBrowser: false, fileBrowser: false, webid: true, - idp: false, + multiuser: false, configPath } diff --git a/test/integration/capability-discovery-test.js b/test/integration/capability-discovery-test.js index 0bbf13db9..e8d420be7 100644 --- a/test/integration/capability-discovery-test.js +++ b/test/integration/capability-discovery-test.js @@ -21,7 +21,7 @@ describe('API', () => { dataBrowser: false, fileBrowser: false, webid: true, - idp: false, + multiuser: false, configPath } diff --git a/test/integration/errors-oidc-test.js b/test/integration/errors-oidc-test.js index bd6445b89..d085920a5 100644 --- a/test/integration/errors-oidc-test.js +++ b/test/integration/errors-oidc-test.js @@ -16,7 +16,7 @@ describe('OIDC error handling', function () { sslCert: path.join(__dirname, '../keys/cert.pem'), auth: 'oidc', webid: true, - idp: false, + multiuser: false, strictOrigin: true, dbPath, serverUri diff --git a/test/integration/header-test.js b/test/integration/header-test.js index fc4cb6c75..5e76bf53a 100644 --- a/test/integration/header-test.js +++ b/test/integration/header-test.js @@ -5,7 +5,7 @@ const supertest = require('supertest') const serverOptions = { root: path.join(__dirname, '../resources/headers'), - idp: false, + multiuser: false, webid: true, sslKey: path.join(__dirname, '../keys/key.pem'), sslCert: path.join(__dirname, '../keys/cert.pem'), diff --git a/test/integration/patch-test.js b/test/integration/patch-test.js index cd4aa5b9f..e517d8dfe 100644 --- a/test/integration/patch-test.js +++ b/test/integration/patch-test.js @@ -13,7 +13,7 @@ const root = path.join(__dirname, '../resources/patch') const serverOptions = { root, serverUri, - idp: false, + multiuser: false, webid: true, sslKey: path.join(__dirname, '../keys/key.pem'), sslCert: path.join(__dirname, '../keys/cert.pem'), diff --git a/test/unit/account-manager-test.js b/test/unit/account-manager-test.js index 9080cb9b7..01872c2e4 100644 --- a/test/unit/account-manager-test.js +++ b/test/unit/account-manager-test.js @@ -32,7 +32,7 @@ describe('AccountManager', () => { let config = { host, authMethod: 'oidc', - multiUser: true, + multiuser: true, store: {}, emailService: {}, tokenService: {} @@ -41,7 +41,7 @@ describe('AccountManager', () => { let mgr = AccountManager.from(config) expect(mgr.host).to.equal(config.host) expect(mgr.authMethod).to.equal(config.authMethod) - expect(mgr.multiUser).to.equal(config.multiUser) + expect(mgr.multiuser).to.equal(config.multiuser) expect(mgr.store).to.equal(config.store) expect(mgr.emailService).to.equal(config.emailService) expect(mgr.tokenService).to.equal(config.tokenService) @@ -56,7 +56,7 @@ describe('AccountManager', () => { describe('accountUriFor', () => { it('should compose account uri for an account in multi user mode', () => { let options = { - multiUser: true, + multiuser: true, host: SolidHost.from({ serverUri: 'https://localhost' }) } let mgr = AccountManager.from(options) @@ -67,7 +67,7 @@ describe('AccountManager', () => { it('should compose account uri for an account in single user mode', () => { let options = { - multiUser: false, + multiuser: false, host: SolidHost.from({ serverUri: 'https://localhost' }) } let mgr = AccountManager.from(options) @@ -80,7 +80,7 @@ describe('AccountManager', () => { describe('accountWebIdFor()', () => { it('should compose a web id uri for an account in multi user mode', () => { let options = { - multiUser: true, + multiuser: true, host: SolidHost.from({ serverUri: 'https://localhost' }) } let mgr = AccountManager.from(options) @@ -90,7 +90,7 @@ describe('AccountManager', () => { it('should compose a web id uri for an account in single user mode', () => { let options = { - multiUser: false, + multiuser: false, host: SolidHost.from({ serverUri: 'https://localhost' }) } let mgr = AccountManager.from(options) @@ -101,9 +101,9 @@ describe('AccountManager', () => { describe('accountDirFor()', () => { it('should match the solid root dir config, in single user mode', () => { - let multiUser = false - let store = new LDP({ root: testAccountsDir, idp: multiUser }) - let options = { multiUser, store, host } + let multiuser = false + let store = new LDP({ root: testAccountsDir, multiuser }) + let options = { multiuser, store, host } let accountManager = AccountManager.from(options) let accountDir = accountManager.accountDirFor('alice') @@ -111,10 +111,10 @@ describe('AccountManager', () => { }) it('should compose the account dir in multi user mode', () => { - let multiUser = true - let store = new LDP({ root: testAccountsDir, idp: multiUser }) + let multiuser = true + let store = new LDP({ root: testAccountsDir, multiuser }) let host = SolidHost.from({ serverUri: 'https://localhost' }) - let options = { multiUser, store, host } + let options = { multiuser, store, host } let accountManager = AccountManager.from(options) let accountDir = accountManager.accountDirFor('alice') @@ -124,11 +124,11 @@ describe('AccountManager', () => { describe('userAccountFrom()', () => { describe('in multi user mode', () => { - let multiUser = true + let multiuser = true let options, accountManager beforeEach(() => { - options = { host, multiUser } + options = { host, multiuser } accountManager = AccountManager.from(options) }) @@ -172,11 +172,11 @@ describe('AccountManager', () => { }) describe('in single user mode', () => { - let multiUser = false + let multiuser = false let options, accountManager beforeEach(() => { - options = { host, multiUser } + options = { host, multiuser } accountManager = AccountManager.from(options) }) @@ -247,7 +247,7 @@ describe('AccountManager', () => { it('should throw an error if webId is missing', (done) => { let emptyUserData = {} let userAccount = UserAccount.from(emptyUserData) - let options = { host, multiUser: true } + let options = { host, multiuser: true } let accountManager = AccountManager.from(options) accountManager.getProfileGraphFor(userAccount) @@ -267,7 +267,7 @@ describe('AccountManager', () => { let userData = { webId } let userAccount = UserAccount.from(userData) - let options = { host, multiUser: true, store } + let options = { host, multiuser: true, store } let accountManager = AccountManager.from(options) expect(userAccount.webId).to.equal(webId) @@ -289,7 +289,7 @@ describe('AccountManager', () => { let userData = { webId } let userAccount = UserAccount.from(userData) - let options = { host, multiUser: true, store } + let options = { host, multiuser: true, store } let accountManager = AccountManager.from(options) let profileGraph = rdf.graph() @@ -302,8 +302,8 @@ describe('AccountManager', () => { describe('rootAclFor()', () => { it('should return the server root .acl in single user mode', () => { - let store = new LDP({ suffixAcl: '.acl', idp: false }) - let options = { host, multiUser: false, store } + let store = new LDP({ suffixAcl: '.acl', multiuser: false }) + let options = { host, multiuser: false, store } let accountManager = AccountManager.from(options) let userAccount = UserAccount.from({ username: 'alice' }) @@ -314,8 +314,8 @@ describe('AccountManager', () => { }) it('should return the profile root .acl in multi user mode', () => { - let store = new LDP({ suffixAcl: '.acl', idp: true }) - let options = { host, multiUser: true, store } + let store = new LDP({ suffixAcl: '.acl', multiuser: true }) + let options = { host, multiuser: true, store } let accountManager = AccountManager.from(options) let userAccount = UserAccount.from({ username: 'alice' }) @@ -342,7 +342,7 @@ describe('AccountManager', () => { getGraph: sinon.stub().resolves(rootAclGraph) } - let options = { host, multiUser: true, store } + let options = { host, multiuser: true, store } let accountManager = AccountManager.from(options) return accountManager.loadAccountRecoveryEmail(userAccount) @@ -361,7 +361,7 @@ describe('AccountManager', () => { getGraph: sinon.stub().resolves(emptyGraph) } - let options = { host, multiUser: true, store } + let options = { host, multiuser: true, store } let accountManager = AccountManager.from(options) return accountManager.loadAccountRecoveryEmail(userAccount) @@ -374,7 +374,7 @@ describe('AccountManager', () => { describe('passwordResetUrl()', () => { it('should return a token reset validation url', () => { let tokenService = new TokenService() - let options = { host, multiUser: true, tokenService } + let options = { host, multiuser: true, tokenService } let accountManager = AccountManager.from(options) diff --git a/test/unit/add-cert-request-test.js b/test/unit/add-cert-request-test.js index 1d1544c12..f6e7f2ce4 100644 --- a/test/unit/add-cert-request-test.js +++ b/test/unit/add-cert-request-test.js @@ -30,8 +30,8 @@ beforeEach(() => { describe('AddCertificateRequest', () => { describe('fromParams()', () => { it('should throw a 401 error if session.userId is missing', () => { - let multiUser = true - let options = { host, multiUser, authMethod: 'oidc' } + let multiuser = true + let options = { host, multiuser, authMethod: 'oidc' } let accountManager = AccountManager.from(options) let req = { @@ -49,10 +49,10 @@ describe('AddCertificateRequest', () => { }) describe('createRequest()', () => { - let multiUser = true + let multiuser = true it('should call certificate.generateCertificate()', () => { - let options = { host, multiUser, authMethod: 'oidc' } + let options = { host, multiuser, authMethod: 'oidc' } let accountManager = AccountManager.from(options) let req = { @@ -78,10 +78,10 @@ describe('AddCertificateRequest', () => { }) describe('accountManager.addCertKeyToGraph()', () => { - let multiUser = true + let multiuser = true it('should add certificate data to a graph', () => { - let options = { host, multiUser, authMethod: 'oidc' } + let options = { host, multiuser, authMethod: 'oidc' } let accountManager = AccountManager.from(options) let userData = { username: 'alice' } diff --git a/test/unit/email-welcome-test.js b/test/unit/email-welcome-test.js index e81769b70..86e3935b2 100644 --- a/test/unit/email-welcome-test.js +++ b/test/unit/email-welcome-test.js @@ -26,7 +26,7 @@ beforeEach(() => { host, emailService, authMethod: 'oidc', - multiUser: true + multiuser: true } accountManager = AccountManager.from(mgrConfig) }) diff --git a/test/unit/password-authenticator-test.js b/test/unit/password-authenticator-test.js index c93c094f0..e57b63f1e 100644 --- a/test/unit/password-authenticator-test.js +++ b/test/unit/password-authenticator-test.js @@ -138,11 +138,11 @@ describe('PasswordAuthenticator', () => { }) describe('in Multi User mode', () => { - let multiUser = true + let multiuser = true let serverUri = 'https://example.com' let host = SolidHost.from({ serverUri }) - let accountManager = AccountManager.from({ multiUser, host }) + let accountManager = AccountManager.from({ multiuser, host }) let aliceRecord = { webId: 'https://alice.example.com/profile/card#me' } let mockUserStore = { @@ -187,11 +187,11 @@ describe('PasswordAuthenticator', () => { }) describe('in Single User mode', () => { - let multiUser = false + let multiuser = false let serverUri = 'https://localhost:8443' let host = SolidHost.from({ serverUri }) - let accountManager = AccountManager.from({ multiUser, host }) + let accountManager = AccountManager.from({ multiuser, host }) let aliceRecord = { webId: 'https://localhost:8443/profile/card#me' } let mockUserStore = { diff --git a/test/unit/password-reset-email-request-test.js b/test/unit/password-reset-email-request-test.js index 74fed9035..9bda0e210 100644 --- a/test/unit/password-reset-email-request-test.js +++ b/test/unit/password-reset-email-request-test.js @@ -60,7 +60,7 @@ describe('PasswordResetEmailRequest', () => { it('should create an instance and render a reset password form', () => { let returnToUrl = 'https://example.com/resource' let username = 'alice' - let accountManager = { multiUser: true } + let accountManager = { multiuser: true } let req = { app: { locals: { accountManager } }, @@ -73,7 +73,7 @@ describe('PasswordResetEmailRequest', () => { PasswordResetEmailRequest.get(req, res) expect(res.render).to.have.been.calledWith('auth/reset-password', - { returnToUrl, multiUser: true }) + { returnToUrl, multiuser: true }) }) }) @@ -87,7 +87,7 @@ describe('PasswordResetEmailRequest', () => { let store = { suffixAcl: '.acl' } - let accountManager = AccountManager.from({ host, multiUser: true, store }) + let accountManager = AccountManager.from({ host, multiuser: true, store }) accountManager.accountExists = sinon.stub().resolves(true) accountManager.loadAccountRecoveryEmail = sinon.stub().resolves('alice@example.com') accountManager.sendPasswordResetEmail = sinon.stub().resolves() @@ -107,9 +107,9 @@ describe('PasswordResetEmailRequest', () => { }) describe('validate()', () => { - it('should throw an error if username is missing in multiUser mode', () => { + it('should throw an error if username is missing in multi-user mode', () => { let host = SolidHost.from({ serverUri: 'https://example.com' }) - let accountManager = AccountManager.from({ host, multiUser: true }) + let accountManager = AccountManager.from({ host, multiuser: true }) let request = new PasswordResetEmailRequest({ accountManager }) @@ -118,7 +118,7 @@ describe('PasswordResetEmailRequest', () => { it('should not throw an error if username is missing in single user mode', () => { let host = SolidHost.from({ serverUri: 'https://example.com' }) - let accountManager = AccountManager.from({ host, multiUser: false }) + let accountManager = AccountManager.from({ host, multiuser: false }) let request = new PasswordResetEmailRequest({ accountManager }) @@ -130,7 +130,7 @@ describe('PasswordResetEmailRequest', () => { it('should handle the post request', () => { let host = SolidHost.from({ serverUri: 'https://example.com' }) let store = { suffixAcl: '.acl' } - let accountManager = AccountManager.from({ host, multiUser: true, store }) + let accountManager = AccountManager.from({ host, multiuser: true, store }) accountManager.loadAccountRecoveryEmail = sinon.stub().resolves('alice@example.com') accountManager.sendPasswordResetEmail = sinon.stub().resolves() accountManager.accountExists = sinon.stub().resolves(true) @@ -159,7 +159,7 @@ describe('PasswordResetEmailRequest', () => { it('should return a UserAccount instance based on username', () => { let host = SolidHost.from({ serverUri: 'https://example.com' }) let store = { suffixAcl: '.acl' } - let accountManager = AccountManager.from({ host, multiUser: true, store }) + let accountManager = AccountManager.from({ host, multiuser: true, store }) accountManager.accountExists = sinon.stub().resolves(true) let username = 'alice' @@ -175,7 +175,7 @@ describe('PasswordResetEmailRequest', () => { it('should throw an error if the user does not exist', done => { let host = SolidHost.from({ serverUri: 'https://example.com' }) let store = { suffixAcl: '.acl' } - let accountManager = AccountManager.from({ host, multiUser: true, store }) + let accountManager = AccountManager.from({ host, multiuser: true, store }) accountManager.accountExists = sinon.stub().resolves(false) let username = 'alice' diff --git a/test/unit/tls-authenticator-test.js b/test/unit/tls-authenticator-test.js index 12596bd2b..27c2be391 100644 --- a/test/unit/tls-authenticator-test.js +++ b/test/unit/tls-authenticator-test.js @@ -14,7 +14,7 @@ const SolidHost = require('../../lib/models/solid-host') const AccountManager = require('../../lib/models/account-manager') const host = SolidHost.from({ serverUri: 'https://example.com' }) -const accountManager = AccountManager.from({ host, multiUser: true }) +const accountManager = AccountManager.from({ host, multiuser: true }) describe('TlsAuthenticator', () => { describe('fromParams()', () => { diff --git a/test/unit/user-accounts-api-test.js b/test/unit/user-accounts-api-test.js index 4436064fd..f420dd002 100644 --- a/test/unit/user-accounts-api-test.js +++ b/test/unit/user-accounts-api-test.js @@ -25,11 +25,11 @@ beforeEach(() => { describe('api/accounts/user-accounts', () => { describe('newCertificate()', () => { describe('in multi user mode', () => { - let multiUser = true - let store = new LDP({ root: testAccountsDir, idp: multiUser }) + let multiuser = true + let store = new LDP({ root: testAccountsDir, multiuser }) it('should throw a 400 error if spkac param is missing', done => { - let options = { host, store, multiUser, authMethod: 'oidc' } + let options = { host, store, multiuser, authMethod: 'oidc' } let accountManager = AccountManager.from(options) let req = { From 9e1b59fa631008a98c06b1f0689711fbfe775793 Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Sun, 3 Sep 2017 19:21:05 -0400 Subject: [PATCH 2/2] Make renamed configuration options warnings. --- lib/create-app.js | 2 +- lib/create-server.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/create-app.js b/lib/create-app.js index bbf006bb6..025148713 100644 --- a/lib/create-app.js +++ b/lib/create-app.js @@ -56,7 +56,7 @@ function createApp (argv = {}) { // Add CORS proxy if (argv.proxy) { - console.error('The proxy configuration option has been renamed to corsProxy.') + console.warn('The proxy configuration option has been renamed to corsProxy.') argv.corsProxy = argv.proxy delete argv.proxy } diff --git a/lib/create-server.js b/lib/create-server.js index f4c01f3be..216a6f774 100644 --- a/lib/create-server.js +++ b/lib/create-server.js @@ -23,7 +23,7 @@ function createServer (argv, app) { debug.settings('Base URL (--mount): ' + mount) if (argv.idp) { - console.error('The idp configuration option has been renamed to multiuser.') + console.warn('The idp configuration option has been renamed to multiuser.') argv.idp = argv.multiuser delete argv.idp }